Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

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

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


kirill at shutemov

Sep 16, 2008, 5:22 AM

Post #1 of 10 (924 views)
Permalink
[PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace

<linux/fcntl.h> conflicts with glibc's <fcntl.h>.

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

Signed-off-by: Kirill A. Shutemov <kirill [at] shutemov>
Cc: Ulrich Drepper <drepper [at] redhat>
Cc: Davide Libenzi <davidel [at] xmailserver>
Cc: David Woodhouse <dwmw2 [at] infradead>
Cc: Andrew Morton <akpm [at] linux-foundation>
---
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 <linux/fcntl.h>
+#endif
#include <linux/types.h>

/*
--
1.5.6.5.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bunk at kernel

Sep 16, 2008, 5:58 AM

Post #2 of 10 (896 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 03:22:43PM +0300, Kirill A. Shutemov wrote:
> <linux/fcntl.h> conflicts with glibc's <fcntl.h>.
>
> It breaks building kdelibs, kdepim and pinot.

We should rather fix the actual bug.

What is the error message?

>...
> --- 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 <linux/fcntl.h>
> +#endif
>...

This breaks the header for users of IN_CLOEXEC/IN_NONBLOCK.

cu
Adrian

--

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


kirill at shutemov

Sep 16, 2008, 6:02 AM

Post #3 of 10 (897 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 03:58:02PM +0300, Adrian Bunk wrote:
> On Tue, Sep 16, 2008 at 03:22:43PM +0300, Kirill A. Shutemov wrote:
> > <linux/fcntl.h> conflicts with glibc's <fcntl.h>.
> >
> > It breaks building kdelibs, kdepim and pinot.
>
> We should rather fix the actual bug.
>
> What is the error message?

/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
flock64'

>
> >...
> > --- 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 <linux/fcntl.h>
> > +#endif
> >...
>
> This breaks the header for users of IN_CLOEXEC/IN_NONBLOCK.
>
> cu
> Adrian
>
> --
>
> "Is there not promise of rain?" Ling Tan asked suddenly out
> of the darkness. There had been need of rain for many days.
> "Only a promise," Lao Er said.
> Pearl S. Buck - Dragon Seed
>

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
Attachments: signature.asc (0.19 KB)


bunk at kernel

Sep 16, 2008, 6:31 AM

Post #4 of 10 (891 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 04:02:36PM +0300, Kirill A. Shutemov wrote:
> On Tue, Sep 16, 2008 at 03:58:02PM +0300, Adrian Bunk wrote:
> > On Tue, Sep 16, 2008 at 03:22:43PM +0300, Kirill A. Shutemov wrote:
> > > <linux/fcntl.h> conflicts with glibc's <fcntl.h>.
> > >
> > > It breaks building kdelibs, kdepim and pinot.
> >
> > We should rather fix the actual bug.
> >
> > What is the error message?
>
> /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
> flock64'
>...

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


But I'm wondering, why is kdelibs doing

<-- snip -->

...
#include <fcntl.h>
#include <sys/syscall.h>
#include <linux/types.h>
// Linux kernel headers are documented to not compile
#define _S390_BITOPS_H
#include <linux/inotify.h>

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

<-- snip -->


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


inotify_init(2) already documents the following usage:

<-- snip -->

...
#include <sys/inotify.h>

int inotify_init(void);
...

<-- snip -->


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

--

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


drepper at redhat

Sep 16, 2008, 7:10 AM

Post #5 of 10 (896 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

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

Kirill A. Shutemov wrote:
>> What is the error message?
>
> /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> flock'

And? None of these programs should use <linux/inotify.h>. There has
for the longest time been a <sys/inotify.h> header which doesn't need
any kernel headers. In fact, <linux/inotify.h> 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-----
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


kirill at shutemov

Sep 16, 2008, 7:43 AM

Post #6 of 10 (894 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 07:10:25AM -0700, Ulrich Drepper wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Kirill A. Shutemov wrote:
> >> What is the error message?
> >
> > /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> > flock'
>
> And? None of these programs should use <linux/inotify.h>. There has
> for the longest time been a <sys/inotify.h> header which doesn't need
> any kernel headers. In fact, <linux/inotify.h> should not be exported.

Ok. Let's unexport <linux/inotify.h>.

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 += igmp.h
unifdef-y += inet_diag.h
unifdef-y += in.h
unifdef-y += in6.h
-unifdef-y += inotify.h
unifdef-y += input.h
unifdef-y += ip.h
unifdef-y += 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 <linux/fcntl.h>
#include <linux/types.h>
+#include <linux/dcache.h>
+#include <linux/fs.h>

/*
* 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

-#ifdef __KERNEL__
-
-#include <linux/dcache.h>
-#include <linux/fs.h>
-
/*
* struct inotify_watch - represents a watch request on a specific inode
*
@@ -230,6 +227,4 @@ static inline void put_inotify_watch(struct inotify_watch *watch)

#endif /* CONFIG_INOTIFY */

-#endif /* __KERNEL __ */
-
#endif /* _LINUX_INOTIFY_H */

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
Attachments: signature.asc (0.19 KB)


bunk at kernel

Sep 16, 2008, 9:09 AM

Post #7 of 10 (891 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 07:10:25AM -0700, Ulrich Drepper wrote:
> Kirill A. Shutemov wrote:
> >> What is the error message?
> >
> > /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> > flock'
>
> And? None of these programs should use <linux/inotify.h>. There has
> for the longest time been a <sys/inotify.h> header which doesn't need
> any kernel headers. In fact, <linux/inotify.h> should not be exported.

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

--

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


kirill at shutemov

Sep 17, 2008, 2:32 AM

Post #8 of 10 (885 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Tue, Sep 16, 2008 at 07:09:02PM +0300, Adrian Bunk wrote:
> On Tue, Sep 16, 2008 at 07:10:25AM -0700, Ulrich Drepper wrote:
> > Kirill A. Shutemov wrote:
> > >> What is the error message?
> > >
> > > /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> > > flock'
> >
> > And? None of these programs should use <linux/inotify.h>. There has
> > for the longest time been a <sys/inotify.h> header which doesn't need
> > any kernel headers. In fact, <linux/inotify.h> should not be exported.
>
> 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.

glibc and dietlibc provide <sys/inotify.h>. newlib and uclibc don't. klibc
provides <sys/inotify.h> but it depends on <linux/inotify.h>

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
Attachments: signature.asc (0.19 KB)


kirill at shutemov

Sep 17, 2008, 3:04 AM

Post #9 of 10 (883 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Wed, Sep 17, 2008 at 12:32:40PM +0300, Kirill A. Shutemov wrote:
> On Tue, Sep 16, 2008 at 07:09:02PM +0300, Adrian Bunk wrote:
> > On Tue, Sep 16, 2008 at 07:10:25AM -0700, Ulrich Drepper wrote:
> > > Kirill A. Shutemov wrote:
> > > >> What is the error message?
> > > >
> > > > /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> > > > flock'
> > >
> > > And? None of these programs should use <linux/inotify.h>. There has
> > > for the longest time been a <sys/inotify.h> header which doesn't need
> > > any kernel headers. In fact, <linux/inotify.h> should not be exported.
> >
> > 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.
>
> glibc and dietlibc provide <sys/inotify.h>. newlib and uclibc don't. klibc
> provides <sys/inotify.h> but it depends on <linux/inotify.h>

Oh.. Sorry. uclibc provides <sys/inotify.h>.

So unexporting <linux/inotify.h> breaks only klibc.

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
Attachments: signature.asc (0.19 KB)


bunk at kernel

Sep 17, 2008, 3:12 AM

Post #10 of 10 (883 views)
Permalink
Re: [PATCH] linux/inotify.h: do not include <linux/fcntl.h> in userspace [In reply to]

On Wed, Sep 17, 2008 at 01:04:23PM +0300, Kirill A. Shutemov wrote:
> On Wed, Sep 17, 2008 at 12:32:40PM +0300, Kirill A. Shutemov wrote:
> > On Tue, Sep 16, 2008 at 07:09:02PM +0300, Adrian Bunk wrote:
> > > On Tue, Sep 16, 2008 at 07:10:25AM -0700, Ulrich Drepper wrote:
> > > > Kirill A. Shutemov wrote:
> > > > >> What is the error message?
> > > > >
> > > > > /usr/include/asm-generic/fcntl.h:117: error: redefinition of 'struct
> > > > > flock'
> > > >
> > > > And? None of these programs should use <linux/inotify.h>. There has
> > > > for the longest time been a <sys/inotify.h> header which doesn't need
> > > > any kernel headers. In fact, <linux/inotify.h> should not be exported.
> > >
> > > 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.
> >
> > glibc and dietlibc provide <sys/inotify.h>. newlib and uclibc don't. klibc
> > provides <sys/inotify.h> but it depends on <linux/inotify.h>
>
> Oh.. Sorry. uclibc provides <sys/inotify.h>.
>
> So unexporting <linux/inotify.h> breaks only klibc.

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 <linux/inotify.h>, but ideally in the long term all
libc implementations should use <linux/inotify.h>.

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

cu
Adrian

--

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.