Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help:the O_LARGEFILE option of open()

614 views
Skip to first unread message

Jt

unread,
May 13, 2003, 6:53:04 AM5/13/03
to
I have to save a file larger than 2G so I use the O_LARGEFILE option of
open();
and I've found the O_LARGEFILE's definition in bits/fcntl.h.
If include <bits/fcntl.h> the compiler tells me include <fcntl.h> instead;
but if include <fcntl.h> it tells me O_LARGEFILE not defined.
I've heard that O_LARGEFILE is supported in linux 2.4.0 and later.
Who has any experience?
Thanks a lot!

Kasper Dupont

unread,
May 13, 2003, 11:11:41 AM5/13/03
to

Does any of this help?
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#O_LARGEFILE

--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:aaa...@daimi.au.dk
for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

Marcus

unread,
May 13, 2003, 1:34:20 PM5/13/03
to
Jt wrote:
> If include <bits/fcntl.h> the compiler tells me include <fcntl.h> instead;
> but if include <fcntl.h> it tells me O_LARGEFILE not defined.
> I've heard that O_LARGEFILE is supported in linux 2.4.0 and later.
> Who has any experience?

On my i386 system, you have to do the following:

#define __USE_LARGEFILE64
#include <fcntl.h>

In that order. (or just compile with -D__USE_LARGEFILE64) Then you
should have the definition, so you can open(2) the file according to
Kasper's page.

-Marcus

Erik de Castro Lopo

unread,
May 13, 2003, 5:11:58 PM5/13/03
to

Yes it is.

> Who has any experience?

Me. What is your question? :-)

To get large file access to work, you need to

#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#define _LARGE_FILES

before you include any other header files. This enables large
file access for the open/read/write/lseek/close family of
functions. I'm not sure if it also works for fopen/fread etc.

The above should work form most platforms. If you want to detect
this stuff using GNU Autoconf you can use the AC_SYS_LARGEFILE
macro. However, I found that didn't work too well and wrapped
some other stuff around it for libsndfile:

http://www.zip.com.au/~erikd/libsndfile/

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nos...@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"If you don't know what you need Windows NT for, you don't need it."
- Bill Gates

Andreas Jaeger

unread,
May 14, 2003, 12:32:15 AM5/14/03
to
Marcus <marcus@cs._no_spam__.nmt.edu> writes:

> Jt wrote:
>> If include <bits/fcntl.h> the compiler tells me include <fcntl.h> instead;
>> but if include <fcntl.h> it tells me O_LARGEFILE not defined.
>> I've heard that O_LARGEFILE is supported in linux 2.4.0 and later.
>> Who has any experience?
>
> On my i386 system, you have to do the following:
>
> #define __USE_LARGEFILE64
> #include <fcntl.h>

Read the glibc manual on "Feature Test Macros" or check <features.h>
directly. You have to define _LARGEFILE_SOURCE before the inclusion
of any header.

Andreas
--
Andreas Jaeger
SuSE Labs a...@suse.de
private a...@arthur.inka.de
http://www.suse.de/~aj

Jt

unread,
May 14, 2003, 2:13:11 AM5/14/03
to
I add the following into my source file and it works!

#ifndef O_LARGEFILE
#define O_LARGEFILE 0100000
#endif


"Jt" <globa...@sina.com> 写入消息新闻:b9qjs7$7q$1...@mail.cn99.com...

0 new messages