Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace

Previous thread: sys_paccept: disable paccept() until API design is resolved by Michael Kerrisk on Tuesday, September 16, 2008 - 5:05 am. (8 messages)

Next thread: looking for a function by Xu Yang on Tuesday, September 16, 2008 - 5:50 am. (8 messages)
From: Kirill A. Shutemov
Date: Tuesday, September 16, 2008 - 5:22 am

&lt;linux/fcntl.h&gt; conflicts with glibc's &lt;fcntl.h&gt;.

It breaks building kdelibs, kdepim and pinot. It's regression itroduced
by commit 4006553.

Signed-off-by: Kirill A. Shutemov &lt;kirill@shutemov.name&gt;
Cc: Ulrich Drepper &lt;drepper@redhat.com&gt;
Cc: Davide Libenzi &lt;davidel@xmailserver.org&gt;
Cc: David Woodhouse &lt;dwmw2@infradead.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
---
 include/linux/inotify.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index bd57857..792b6f0 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -7,8 +7,10 @@
 #ifndef _LINUX_INOTIFY_H
 #define _LINUX_INOTIFY_H
 
+#ifdef __KERNEL__
 /* For O_CLOEXEC and O_NONBLOCK */
 #include &lt;linux/fcntl.h&gt;
+#endif
 #include &lt;linux/types.h&gt;
 
 /*
-- 
1.5.6.5.GIT

--

From: Adrian Bunk
Date: Tuesday, September 16, 2008 - 5:58 am

We should rather fix the actual bug.


This breaks the header for users of IN_CLOEXEC/IN_NONBLOCK.

cu
Adrian

-- 

       &quot;Is there not promise of rain?&quot; Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       &quot;Only a promise,&quot; Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Kirill A. Shutemov
Date: Tuesday, September 16, 2008 - 6:02 am

/usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
flock'
/usr/include/bits/fcntl.h:142: error: previous definition of 'struct
flock'
/usr/include/asm-generic/fcntl.h:140: error: redefinition of 'struct
flock64'
/usr/include/bits/fcntl.h:157: error: previous definition of 'struct

--=20
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
From: Adrian Bunk
Date: Tuesday, September 16, 2008 - 6:31 am

Kernel headers and glibc headers are an own story, Ulrich might know 
best about that.


But I'm wondering, why is kdelibs doing

&lt;--  snip  --&gt;

...
#include &lt;fcntl.h&gt;
#include &lt;sys/syscall.h&gt;
#include &lt;linux/types.h&gt;
// Linux kernel headers are documented to not compile
#define _S390_BITOPS_H
#include &lt;linux/inotify.h&gt;

static inline int inotify_init (void)
{
  return syscall (__NR_inotify_init);
}
...

&lt;--  snip  --&gt;


pinot even contains a file with the inotify syscall numbers for all 
architectures.


inotify_init(2) already documents the following usage:

&lt;--   snip  --&gt;

...
#include &lt;sys/inotify.h&gt;

int inotify_init(void);
...

&lt;--  snip  --&gt;


Unless someone knows a good reason against that (and no matter how the 
kernel situation will change) I'll send patches to get KDE fixed in this 
respect.


cu
Adrian

-- 

       &quot;Is there not promise of rain?&quot; Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       &quot;Only a promise,&quot; Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Ulrich Drepper
Date: Tuesday, September 16, 2008 - 7:10 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


And?  None of these programs should use &lt;linux/inotify.h&gt;.  There has
for the longest time been a &lt;sys/inotify.h&gt; header which doesn't need
any kernel headers.  In fact, &lt;linux/inotify.h&gt; should not be exported.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkjPvlEACgkQ2ijCOnn/RHTO0ACfR2NrTZ97pK34xZKM5pzlRbL6
Nb4AoJ27y9MU+Udr50GZVfZZXjg3ENWg
=7Pol
-----END PGP SIGNATURE-----
--

From: Kirill A. Shutemov
Date: Tuesday, September 16, 2008 - 7:43 am

Ok. Let's unexport &lt;linux/inotify.h&gt;.

diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index b68ec09..dbb8107 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -240,7 +240,6 @@ unifdef-y +=3D igmp.h
 unifdef-y +=3D inet_diag.h
 unifdef-y +=3D in.h
 unifdef-y +=3D in6.h
-unifdef-y +=3D inotify.h
 unifdef-y +=3D input.h
 unifdef-y +=3D ip.h
 unifdef-y +=3D ipc.h
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index bd57857..0188b6a 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -10,6 +10,8 @@
 /* For O_CLOEXEC and O_NONBLOCK */
 #include &lt;linux/fcntl.h&gt;
 #include &lt;linux/types.h&gt;
+#include &lt;linux/dcache.h&gt;
+#include &lt;linux/fs.h&gt;
=20
 /*
  * struct inotify_event - structure read from the inotify device for each =
event
@@ -69,11 +71,6 @@ struct inotify_event {
 #define IN_CLOEXEC O_CLOEXEC
 #define IN_NONBLOCK O_NONBLOCK
=20
-#ifdef __KERNEL__
-
-#include &lt;linux/dcache.h&gt;
-#include &lt;linux/fs.h&gt;
-
 /*
  * struct inotify_watch - represents a watch request on a specific inode
  *
@@ -230,6 +227,4 @@ static inline void put_inotify_watch(struct inotify_wat=
ch *watch)
=20
 #endif	/* CONFIG_INOTIFY */
=20
-#endif	/* __KERNEL __ */
-
 #endif	/* _LINUX_INOTIFY_H */

--=20
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
From: Adrian Bunk
Date: Tuesday, September 16, 2008 - 9:09 am

Even if userspace applications shouldn't use it directly this doesn't 
sound right:

We shouldn't force all libc implementations to copy the contents into a 
private header.

cu
Adrian

-- 

       &quot;Is there not promise of rain?&quot; Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       &quot;Only a promise,&quot; Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Kirill A. Shutemov
Date: Wednesday, September 17, 2008 - 2:32 am

glibc and dietlibc provide &lt;sys/inotify.h&gt;. newlib and uclibc don't. klibc
provides &lt;sys/inotify.h&gt; but it depends on &lt;linux/inotify.h&gt;

--=20
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
From: Kirill A. Shutemov
Date: Wednesday, September 17, 2008 - 3:04 am

Oh.. Sorry. uclibc provides &lt;sys/inotify.h&gt;.

So unexporting &lt;linux/inotify.h&gt; breaks only klibc.

--=20
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
From: Adrian Bunk
Date: Wednesday, September 17, 2008 - 3:12 am

klibc is actually doing the right thing.

The userspace kernel headers situation used to be a complete mess, and 
it is therefore understandable that some libc implementations are 
currently not using &lt;linux/inotify.h&gt;, but ideally in the long term all 
libc implementations should use &lt;linux/inotify.h&gt;.

Whether, and if yes when, libc implementations starts using 
&lt;linux/inotify.h&gt; is not our business, but we have to ensure that it 
works for the libc implementations that do use it.

cu
Adrian

-- 

       &quot;Is there not promise of rain?&quot; Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       &quot;Only a promise,&quot; Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

Previous thread: sys_paccept: disable paccept() until API design is resolved by Michael Kerrisk on Tuesday, September 16, 2008 - 5:05 am. (8 messages)

Next thread: looking for a function by Xu Yang on Tuesday, September 16, 2008 - 5:50 am. (8 messages)