diff mbox

libc-compat.h for <bits/fcntl-linux.h>

Message ID 572F9425.6000100@redhat.com
State New, archived
Headers show

Commit Message

Florian Weimer May 8, 2016, 7:31 p.m. UTC
On 05/08/2016 09:17 PM, Eric Neblock wrote:
> Hello everyone,
>    I've been doing some kernel hacking and added some new flags to the
> Linux kernel. I want to use these flags in userland without having to in
> an additional header (<asm-generic/fcntl.h>) and even then, there are
> conflicts, because almost everything is already defined.
>
>    As such, I filed a feature request (20050) and was informed about
> about the process to have compatibility.
>
>    I've attached a patch that shouldn't break anything. Incidentally,
> everything in the Linux Kernel matches what is done by glibc.

I've converted the patch to a forward patch in unified/git diff format, 
for easier review.

Thanks,
Florian
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
index 7e5b0ae..b55fb0c 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
@@ -38,11 +38,16 @@ 
 # include <bits/uio.h>
 #endif
 
+/* If the user has added in the kernel header, then we use those definations */
+#ifndef __UAPI_DEF_FCNTL_H
+#define __BITS_FCNTL_LINUX_H 1
 /* open/fcntl.  */
 #define O_ACCMODE	   0003
 #define O_RDONLY	     00
 #define O_WRONLY	     01
 #define O_RDWR		     02
+#endif
+
 #ifndef O_CREAT
 # define O_CREAT	   0100	/* Not fcntl.  */
 #endif
@@ -129,10 +134,12 @@ 
    last reference to the the file description against which they were acquired
    is put. */
 #ifdef __USE_GNU
+#ifndef __UAPI_DEF_FCNTL
 # define F_OFD_GETLK	36
 # define F_OFD_SETLK	37
 # define F_OFD_SETLKW	38
-#endif
+#endif /* __UAPI_DEF_FCNTL */
+#endif /* __USE_GNU */
 
 #ifdef __USE_LARGEFILE64
 # define O_LARGEFILE __O_LARGEFILE
@@ -163,12 +170,14 @@ 
 # endif
 #endif
 
+#ifndef __UAPI_DEF_FCNTL_H
 /* Values for the second argument to `fcntl'.  */
 #define F_DUPFD		0	/* Duplicate file descriptor.  */
 #define F_GETFD		1	/* Get file descriptor flags.  */
 #define F_SETFD		2	/* Set file descriptor flags.  */
 #define F_GETFL		3	/* Get file status flags.  */
 #define F_SETFL		4	/* Set file status flags.  */
+#endif
 
 #ifndef __F_SETOWN
 # define __F_SETOWN	8
@@ -176,9 +185,11 @@ 
 #endif
 
 #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+#ifndef __UAPI_DEF_FCNTL_H
 # define F_SETOWN	__F_SETOWN /* Get owner (process receiving SIGIO).  */
 # define F_GETOWN	__F_GETOWN /* Set owner (process receiving SIGIO).  */
-#endif
+#endif /* __UAPI_DEF_FCNTL_H */
+#endif /* __USE_UNIX98 || __USE_XOPEN2K8 */
 
 #ifndef __F_SETSIG
 # define __F_SETSIG	10	/* Set number of signal to be sent.  */
@@ -190,11 +201,13 @@ 
 #endif
 
 #ifdef __USE_GNU
+#ifndef __UAPI_DEF_FCNTL_H
 # define F_SETSIG	__F_SETSIG	/* Set number of signal to be sent.  */
 # define F_GETSIG	__F_GETSIG	/* Get number of signal to be sent.  */
 # define F_SETOWN_EX	__F_SETOWN_EX	/* Get owner (thread receiving SIGIO).  */
 # define F_GETOWN_EX	__F_GETOWN_EX	/* Set owner (thread receiving SIGIO).  */
-#endif
+#endif /* __UAPI_DEF_FCNTL_H */
+#endif /* __USE_GNU */
 
 #ifdef __USE_GNU
 # define F_SETLEASE	1024	/* Set a lease.	 */
@@ -208,8 +221,10 @@ 
 				   close-on-exit set.  */
 #endif
 
+#ifndef __UAPI_DEF_FCNTL_H
 /* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* Actually anything with low bit set goes */
+#endif
 
 #ifndef F_RDLCK
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
@@ -225,6 +240,7 @@ 
 # define F_SHLCK		8	/* or 4 */
 #endif
 
+#ifndef __UAPI_DEF_FCNTL_H
 #ifdef __USE_MISC
 /* Operations for BSD flock, also used by the kernel implementation.  */
 # define LOCK_SH	1	/* Shared lock.  */
@@ -232,14 +248,15 @@ 
 # define LOCK_NB	4	/* Or'd with one of the above to prevent
 				   blocking.  */
 # define LOCK_UN	8	/* Remove lock.  */
-#endif
+#endif /* __USE_MISC */
 
 #ifdef __USE_GNU
 # define LOCK_MAND	32	/* This is a mandatory flock:	*/
 # define LOCK_READ	64	/* ... which allows concurrent read operations.	 */
 # define LOCK_WRITE	128	/* ... which allows concurrent write operations.  */
 # define LOCK_RW	192	/* ... Which allows concurrent read & write operations.	 */
-#endif
+#endif /* __USE_MISC */
+#endif /* __UAPI_DEF_FCNTL_H */
 
 #ifdef __USE_GNU
 /* Types of directory notifications that may be requested with F_NOTIFY.  */