This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken


>>>>> Andreas Jaeger wrote long ago:

 > struct flock is defined with different sizes if you compile with
 > -D_FILE_OFFSET_BITS=64.  The following example will break in this case
 > since the kernel expects a struct with a different size:

 > struct flock fl;
 > fcntl (fd, F_GETLK, &fl);

 > What can we do?  I see two alternatives:

 > A) Use in <bits/fcntl.h>:
 > #ifndef __USE_FILE_OFFSET64
 > #define F_GETLK       5       /* Get record locking info.  */
 > #define F_SETLK       6       /* Set record locking info (non-blocking).  */
 > #define F_SETLKW       7       /* Set record locking info (blocking).  */
 > #else
 > #define F_GETLK       F_GETLK64       /* Get record locking info.  */
 > #define F_SETLK       F_SETLK64       /* Set record locking info (non-blocking).  */
 > #define F_SETLKW       F_SETLKW64       /* Set record locking info (blocking).  */
 > #endif

 > B) The other alternative is to add fcntl64 and handle it the usual
 >    way:

 > # ifndef __USE_FILE_OFFSET64
 > extern int fcntl (...
 > # else
 > # ifdef __REDIRECT
 > extern int __REDIRECT (fcntl, ..., fcntl64);
 > # else
 > #  define fcntl fcntl64
 > # endif
 > # endif

 > What do you think?  Which alternative is better - or does it work
 > already without problems?

Ok, fcntl64 and the constants have found their way into the kernel and
we can use them now.  It's time to clean up this mess.

I'm adding a patch for the first alternative, the second alternative
is way too messy.

What do you think?  Shall I commit this?

Andreas


2000-08-12  Andreas Jaeger  <aj@suse.de>

	* sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Handle
	__USE_FILE_OFFSET64 correctly for locking.

============================================================
Index: sysdeps/unix/sysv/linux/i386/bits/fcntl.h
--- sysdeps/unix/sysv/linux/i386/bits/fcntl.h	2000/08/12 07:20:28	1.6
+++ sysdeps/unix/sysv/linux/i386/bits/fcntl.h	2000/08/12 11:19:35
@@ -65,9 +65,15 @@
 #define F_SETFD		2	/* Set file descriptor flags.  */
 #define F_GETFL		3	/* Get file status flags.  */
 #define F_SETFL		4	/* Set file status flags.  */
-#define F_GETLK		5	/* Get record locking info.  */
-#define F_SETLK		6	/* Set record locking info (non-blocking).  */
-#define F_SETLKW	7	/* Set record locking info (blocking).  */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK	5	/* Get record locking info.  */
+# define F_SETLK	6	/* Set record locking info (non-blocking).  */
+# define F_SETLKW	7	/* Set record locking info (blocking).  */
+#else
+# define F_GETLK	F_GETLK64  /* Get record locking info.  */
+# define F_SETLK	F_SETLK64  /* Set record locking info (non-blocking).  */
+# define F_SETLKW	F_SETLKW64 /* Set record locking info (blocking).  */
+#endif
 #define F_GETLK64	12	/* Get record locking info.  */
 #define F_SETLK64	13	/* Set record locking info (non-blocking).  */
 #define F_SETLKW64	14	/* Set record locking info (blocking).  */

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]