l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2003 May 21 07:50

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] [C] randomly accessing file data in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] [C] randomly accessing file data in C

Never mind... got it figured out.  I had forgotten to put a couple flags.
Heh... it happens now and then :P  I'm now using POSIX calls instead of
the C library calls -- probably safer to interact directly with the kernel
rather than through the C library -- one less layer of large file support
to worry about.

Anyway, as always, Jeff has some productive things to say here so let
me reply...:

On Tue, 20 May 2003, Jeff Newmiller wrote:

> You need to be careful how you open it... if you are using open, you
> probably want O_RDWR mode... if fopen, "r+".

If I'm reading one file, then writing another, I only need "r" for the
file I'm reading and "w" for the file I'm writing, don't I?  Why would
you open it "r+"?

Anyway, I'm now opening the output file with (O_WRONLY | O_CREAT |
O_LARGEFILE).  Should I open it with (O_RDWR | O_CREAT | O_LARGEFILE)

> Google sez http://www.suse.de/~aj/linux_lfs.html.  Note that the gory
> details are described in the document linked at the bottom of the "Using
> LFS" section.

This is great!  Thank you for the link!!! ^_^

> I say be scrupulous about using typedefs like off_t or you will be sorry,
> and beware of shared libraries that aren't set up for large file support.

Thanks for the warning!

> PS: Looked at your code... it is always a red flag to me when you place
> your own prototypes for library functions in your source file.  Use the
> defines described in the document referenced above.  Also, you are using
> "w+b" instead of "r+b".

Yeah, I'm weary, too.  I couldn't figure out how to do it properly but
your link above showed the right way.  Thank you sooooo much!! ^_^


PS: Someone really should document the LFS API into the man pages.
Anyone got time? ^_^

Mark K. Kim
PGP key available upon request.

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!