[LV] [PATCH] Define "struct stat" and "struct stat64" reasonably

Maciej W. Rozycki macro at linux-mips.org
Mon May 18 01:58:15 CEST 2009


 Our "struct stat" and "struct stat64" definitions make them less then 
useful for actual use as some of the fields are narrower than the types 
used by the kernel to hold the respective data entities internally.  Take 
the opportunity from our port being immature (despite the age :( ) and 
define them in a way userland expects them to look like.  This way no 
overhead from on-the-fly conversion between the kernel and the user format 
is incurred in the C library as is the case for most other platforms.  
The structures have been laid out such as to avoid unnecessary padding due 
to misalignment.

Signed-off-by: Maciej W. Rozycki <macro at linux-mips.org>
---
 A news entry on our page states there was a problem with uClibc and 
stat() -- there's no mention as to whether it has been rectified or not; 
given the state of the structures, probably not.  This patch constitutes a 
user-visible ABI change, but I think is worth doing rather than trying to 
keep the breakage working somehow and introducing new syscalls operating 
on the data in the correct way.  Of course uClibc would have to be 
adjusted if anybody cared.

 If anybody thinks the breakage of the ABI would be a real problem, then 
please speak out and I can think about a possible solution, but even then 
my sugestion would simply be to retire the old syscall numbers without 
providing compatible handlers.

 Otherwise, please apply.

  Maciej

patch-mips-2.6.25-20080422-vax-stat-0
diff -up --recursive --new-file linux-mips-2.6.25-20080422.macro/include/asm-vax/stat.h linux-mips-2.6.25-20080422/include/asm-vax/stat.h
--- linux-mips-2.6.25-20080422.macro/include/asm-vax/stat.h	2008-05-01 00:00:00.000000000 +0000
+++ linux-mips-2.6.25-20080422/include/asm-vax/stat.h	2009-05-05 19:08:20.000000000 +0000
@@ -1,79 +1,44 @@
 #ifndef _VAX_STAT_H
 #define _VAX_STAT_H
 
-/* lifted from i386 port */
-
-struct __old_kernel_stat {
-	unsigned short st_dev;
-	unsigned short st_ino;
-	unsigned short st_mode;
-	unsigned short st_nlink;
-	unsigned short st_uid;
-	unsigned short st_gid;
-	unsigned short st_rdev;
-	unsigned long  st_size;
-	unsigned long  st_atime;
-	unsigned long  st_mtime;
-	unsigned long  st_ctime;
-};
-
+/* This matches struct stat in glibc 2.4.  */
 struct stat {
-	unsigned short st_dev;
-	unsigned short __pad1;
-	unsigned long st_ino;
-	unsigned short st_mode;
-	unsigned short st_nlink;
-	unsigned short st_uid;
-	unsigned short st_gid;
-	unsigned short st_rdev;
-	unsigned short __pad2;
-	unsigned long  st_size;
-	unsigned long  st_blksize;
-	unsigned long  st_blocks;
-	unsigned long  st_atime;
-	unsigned long  st_atime_nsec;
-	unsigned long  st_mtime;
-	unsigned long  st_mtime_nsec;
-	unsigned long  st_ctime;
-	unsigned long  st_ctime_nsec;
-	unsigned long  __unused4;
-	unsigned long  __unused5;
+	unsigned long long	st_dev;
+	unsigned long		st_ino;
+	unsigned int		st_mode;
+	unsigned int		st_nlink;
+	unsigned int		st_uid;
+	unsigned int		st_gid;
+	long			st_size;
+	unsigned long long	st_rdev;
+	long			st_blocks;
+	long			st_blksize;
+	long			st_atime;
+	long			st_atime_nsec;
+	long			st_mtime;
+	long			st_mtime_nsec;
+	long			st_ctime;
+	long			st_ctime_nsec;
 };
 
-/* This matches struct stat64 in glibc2.1, hence the absolutely
- * insane amounts of padding around dev_t's.
- */
+/* This matches struct stat64 in glibc 2.4.  */
 struct stat64 {
-        unsigned short  st_dev;
-        unsigned char   __pad0[6];
-
-        unsigned long long st_ino;
-        unsigned int    st_mode;
-        unsigned int    st_nlink;
-
-        unsigned long   st_uid;
-        unsigned long   st_gid;
-
-        unsigned short  st_rdev;
-        unsigned char   __pad3[10];
-
-        long long       st_size;
-        unsigned long   st_blksize;
-
-        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
-        unsigned long   __pad4;         /* future possible st_blocks high bits */
-
-        unsigned long   st_atime;
-        unsigned long   st_atime_nsec;
-
-        unsigned long   st_mtime;
-        unsigned long   st_mtime_nsec;
-
-        unsigned long   st_ctime;
-        unsigned long   st_ctime_nsec;
-
-        unsigned long   __unused1;
-        unsigned long   __unused2;
+	unsigned long long	st_dev;
+	unsigned long long	st_ino;
+	unsigned int		st_mode;
+	unsigned int		st_nlink;
+	unsigned int		st_uid;
+	unsigned int		st_gid;
+	long long		st_size;
+	unsigned long long	st_rdev;
+	long long		st_blocks;
+	long			st_blksize;
+	long			st_atime;
+	long			st_atime_nsec;
+	long			st_mtime;
+	long			st_mtime_nsec;
+	long			st_ctime;
+	long			st_ctime_nsec;
 };
 
 #endif /* _VAX_STAT_H */
_______________________________________________
Linux-Vax mailing list
Linux-Vax at mail.pergamentum.com
http://mail.pergamentum.com/mailman/listinfo/linux-vax




More information about the Vax-linux mailing list