Skip to contentSkip to conversation

Duplicate ustat structure

parisc-linux Jeff Bailey 2 participants 4 messages Jul 16, 2006 – Jul 25, 2006 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Carlos,

This patch is needed to work around a compilation failure with ustat.c when using kernel headers produced from the output of "make headers_install".

The problem is that bits/ustat.h includes the definition of struct ustat. However, sys/types.h eventually winds up pulling in linux/types.h which also defines struct ustat. Since this definition forms part of the kernel ABI, the kernel header is the correct place to define this.

Ubuntu and Fedora are now using these headers. Debian will be shortly. I beleive that Gentoo either has or is about to move to them.

tks,
Jeff Bailey

2006-07-16 Jeff Bailey <[email protected]>

* sysdeps/unix/sysv/linux/hppa/bits/ustat.h: New file.

unix/sysv/linux/hppa/bits/ustat.h new file +34 -0
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 2002, 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_USTAT_H
+# error "Never include <bits/ustat.h> directly; use <sys/ustat.h> instead."
+#endif
+
+#include <sys/types.h>
+
+#if 0
+/* On hppa, sys/types.h pulls in linux/types.h which defines this */
+struct ustat
+  {
+    __daddr_t f_tfree;		/* Number of free blocks.  */
+    __ino_t f_tinode;		/* Number of free inodes.  */
+    char f_fname[6];
+    char f_fpack[6];
+  };
+#endif
Signature · 7 lines
I do not agree with a word you say, but I will defend to the death your
right to say it. 
 - Voltaire
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Andreas Schwab
Quoted 3 lines

The problem is that bits/ustat.h includes the definition of struct ustat. However, sys/types.h eventually winds up pulling in linux/types.h which also defines struct ustat.

<sys/types.h> should not include <linux/types.h> in the first place.

It seems like it ought to now that the kernel is exporting a set of headers that are intended to be used by userspace. struct ustat is defined in linux/types.h.

But in general, this is the path by which it gets included:

include/sys/types.h includes thread_db.h

nptl_db/thread_db.h includes procfs.h

ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h includes asm/elf.h for elf_gregset_t and elf_fpregset_t

asm-parisc/elf.h includes asm/ptrace.h unnecessarily, but relies on it to pull in linux/types for __u32

asm-parisc/ptrace.h includes linux/types.h for __u64

So the following patch would work instead, but I think this type of fix used to be right when the kernel folks didn't want to provide userspace headers. Now that they are doing so, I think it's more correct for us to use them.

2006-07-16 Jeff Bailey <[email protected]>

* sysdeps/unix/sysv/linux/hppa/sys/procfs.h: Don't include elf.h.
Declare elf_greg_t, elf_gregset_t, elf_fpreg_t, and elf_fpregset_t.

Index: sysdeps/unix/sysv/linux/hppa/sys/procfs.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h,v retrieving revision 1.2

unix/sysv/linux/hppa/sys/procfs.h +9 -1
diff -u -p -r1.2 procfs.h
@@ -34,10 +34,18 @@
 #include <sys/types.h>
 #include <sys/ucontext.h>
 #include <sys/user.h>
-#include <asm/elf.h>
 
 __BEGIN_DECLS
 
+typedef unsigned long elf_greg_t;
+#define ELF_NGREG 80    /* We only need 64 at present, but leave space
+			                              for expansion. */
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+#define ELF_NFPREG 32
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
 struct elf_siginfo
   {
     int si_signo;			/* Signal number.  */
Signature · 7 lines
I do not agree with a word you say, but I will defend to the death your
right to say it. 
 - Voltaire
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
#3 lore raw
Quoted 11 lines · Jeff Bailey
Quoted 5 lines · Andreas Schwab
Quoted 3 lines

The problem is that bits/ustat.h includes the definition of struct ustat. However, sys/types.h eventually winds up pulling in linux/types.h which also defines struct ustat.

<sys/types.h> should not include <linux/types.h> in the first place.

It seems like it ought to now that the kernel is exporting a set of headers that are intended to be used by userspace. struct ustat is defined in linux/types.h.

In which case this patch should go upstream to libc-alpha, where the generic version of ustat.h should be changed.

Cheers,
Carlos.
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

#4 lore raw
Quoted 7 lines · Carlos O'Donell
Quoted 6 lines · Jeff Bailey
Quoted 4 lines · Andreas Schwab
Quoted 3 lines

The problem is that bits/ustat.h includes the definition of struct ustat. However, sys/types.h eventually winds up pulling in linux/types.h which also defines struct ustat.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

<sys/types.h> should not include <linux/types.h> in the first place.

It seems like it ought to now that the kernel is exporting a set of headers that are intended to be used by userspace. struct ustat is defined in linux/types.h.

In which case this patch should go upstream to libc-alpha, where the generic version of ustat.h should be changed.

Certainly, but could you apply the second patch in the meantime? That's what all the other arch's do right now, and it will at least make current glibc buildable with current kernel headers. I'll try and pitch the concept of using kernel headers instead of copying values into glibc when I have enough time and energy to fight that battle.

Tks,
Jeff Bailey

Signature · 9 lines
Although when you're in the situation that RMS is telling you that
you're being too ideological about freedom, maybe, just maybe, it's
true.
- Matthew Wilcox

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux