From patchwork Sun May 8 19:31:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 12146 Received: (qmail 39166 invoked by alias); 8 May 2016 19:31:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 39147 invoked by uid 89); 8 May 2016 19:31:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=filed, ord, lease, 2256 X-HELO: mx1.redhat.com Subject: Re: [PATCH] libc-compat.h for To: Eric Neblock , libc-alpha@sourceware.org References: <589a6293-be0f-4b55-3a0b-2c180773ad94@member.fsf.org> From: Florian Weimer Message-ID: <572F9425.6000100@redhat.com> Date: Sun, 8 May 2016 21:31:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <589a6293-be0f-4b55-3a0b-2c180773ad94@member.fsf.org> 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 () 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 --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 #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. */