This is the mail archive of the libc-hacker@sourceware.cygnus.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]

struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken



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?

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de


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