Skip to contentSkip to conversation

Mask out O_LARGEFILE in F_GETFL

PATCH In review Andi Kleen 2 participants 2 messages Sep 25, 2003 – Oct 1, 2003

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Mask out O_LARGEFILE in F_GETFL

This fixes a test in the LSB test suite.

The kernel sets O_LARGEFILE implicitely on 64bit hosts. According to POSIX it should not appear on F_GETFL then. Just mask it out always.

This will also mask it out for explicitely set O_LARGEFILE, but that seems to be ok.

Any flames for this please to the POSIX comittee, not to me.

-Andi

fs/fcntl.c +1 -1
diff -X ../../KDIFX -burpN linux-2.4.23-pre5/fs/fcntl.c linux-merge/fs/fcntl.c
@@ -270,7 +270,7 @@ static long do_fcntl(unsigned int fd, un
 			set_close_on_exec(fd, arg&1);
 			break;
 		case F_GETFL:
-			err = filp->f_flags;
+			err = filp->f_flags & ~O_LARGEFILE;
 			break;
 		case F_SETFL:
 			lock_kernel();
#1 lore raw

Hi,

Quoted 19 lines · Andi Kleen

This fixes a test in the LSB test suite.

The kernel sets O_LARGEFILE implicitely on 64bit hosts. According to POSIX it should not appear on F_GETFL then. Just mask it out always.

This will also mask it out for explicitely set O_LARGEFILE, but that seems to be ok.

Any flames for this please to the POSIX comittee, not to me.

-Andi

diff -X ../../KDIFX -burpN linux-2.4.23-pre5/fs/fcntl.c linux-merge/fs/fcntl.c

fs/fcntl.c static long do_fcntl(unsigned int fd, un · line 276

Quoted 8 lines
fs/fcntl.c +1 -1
@@ -270,7 +270,7 @@ static long do_fcntl(unsigned int fd, un
 			set_close_on_exec(fd, arg&1);
 			break;
 		case F_GETFL:
-			err = filp->f_flags;
+			err = filp->f_flags & ~O_LARGEFILE;
 			break;
 		case F_SETFL:
 			lock_kernel();

I guess you got bitten because you're running 64bit where glibc isn't supposed to deal with it.

AFIK it's up to glibc to clean it up on 32bit systems if you don't ask for largefile mode.

this is what I've on my tree since a long time and it should be the right fix.

#if BITS_PER_LONG != 32
			err = filp->f_flags & ~O_LARGEFILE;
#else
			err = filp->f_flags;

#endif

	http://www.us.kernel.org/pub/linux/kernel/people/andrea/kernels/v2.4/2.4.22aa1/00_fcntl_getfl-largefile-1

Andrea - If you prefer relying on open source software, check these links:

	    rsync.kernel.org::pub/scm/linux/kernel/bkcvs/linux-2.[45]/
	    http://www.cobite.com/cvsps/