[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: some more JOBS



Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de> writes:

> On Fri, Aug 10, 2001 at 10:29:15AM +0530, Nikunj A. Dadhania wrote:
> > Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de> writes:
> > There is a member of stat structure fsid. its declared as
> >    typedef __u_quad_t __fsid_t;	/* Type of file system IDs.  */
> 
> The program stat has two issues:
> 
> 1. It accesses internal symbols of glibc (__var).  Everything beginning with
> two underscores is "strictly forbidden" if you want to follow the book.
> More so, there is absolutely no need to access those symbols.  As the GNU
> version of st_fsid shows, the special definition of the fsid type is
> purely a technical implementation issue to make the variable occupy a
> certain number of bytes in some special way.  Applications should be
> completely unaware of this.
> 
> stat should be changed to simply access st_fsid (not __val at all), and
> print it out as a long long.  For this you need to reformat the format
> specifiers a bit (%-16Lx for example, etc)

> 
> You should list all filesystem types in hurd/hurd_types.h.  In fact, this
> could easily be scripted and the code automatically generated, but cut&paste
> is also ok.  I suggest to simply use the XXX in FSTYPE_XXX for the string to
> print.

done

here is the patch

thanks,
nikunj

patch
========================================================================

diff -ruN stat-2.5.orig/fs.h hurd/stat/stat-2.5.orig/fs.h
--- stat-2.5.orig/fs.h	Mon Oct 11 17:53:17 1999
+++ hurd/stat/stat-2.5.orig/fs.h	Fri Aug 10 14:06:45 2001
@@ -1,6 +1,6 @@
 /* define the magic numbers as given by statfs(2) */
 /* please send additions to meskes@debian.org     */
-
+#if defined(__linux__)
 #define	AFFS_SUPER_MAGIC      0xADFF
 #define EXT_SUPER_MAGIC       0x137D
 #define EXT2_OLD_SUPER_MAGIC  0xEF51
@@ -23,3 +23,7 @@
 #define UFS_MAGIC             0x00011954
 #define _XIAFS_SUPER_MAGIC    0x012FD16D
 #define	NTFS_SUPER_MAGIC      0x5346544e
+#elif defined(__GNU__)
+#include <hurd/hurd_types.h>
+#endif
+
diff -ruN stat-2.5.orig/stat.c hurd/stat/stat-2.5.orig/stat.c
--- stat-2.5.orig/stat.c	Thu May 10 13:25:29 2001
+++ hurd/stat/stat-2.5.orig/stat.c	Fri Aug 10 14:48:27 2001
@@ -23,11 +23,11 @@
 #ifdef __USE_FILE_OFFSET64
 		printf("%s %x %x %lu %lx %lld %lld %lld %ld %lld %lld\n",
 #else
-		printf("%s %x %x %d %x %ld %ld %ld %d %ld %ld\n",
+		printf("%s %Lx %Lx %d %x %d %d %d %d %d %d\n",
 #endif
 			filename,
-			statfsbuf.f_fsid.__val[0],
-			statfsbuf.f_fsid.__val[1],
+			statfsbuf.f_fsid,
+			statfsbuf.f_fsid,
 			statfsbuf.f_namelen,
 			statfsbuf.f_type,
 			statfsbuf.f_blocks,
@@ -42,78 +42,162 @@
 	
 	printf("  File: \"%s\"\n", filename);
 #ifdef __USE_FILE_OFFSET64 
-	printf("    ID: %-8x %-8x Namelen: %-7ld Type: ", statfsbuf.f_fsid.__val[0], statfsbuf.f_fsid.__val[1], statfsbuf.f_namelen);
+	printf("    ID: %-16Lx %-16Lx Namelen: %-7ld Type: ", statfsbuf.f_fsid, statfsbuf.f_fsid, statfsbuf.f_namelen);
 #else
-	printf("    ID: %-8x %-8x Namelen: %-7d Type: ", statfsbuf.f_fsid.__val[0], statfsbuf.f_fsid.__val[1], statfsbuf.f_namelen);
+	printf("    ID: %-16Lx %-16Lx Namelen: %-7d Type: ", statfsbuf.f_fsid, statfsbuf.f_fsid, statfsbuf.f_namelen);
 #endif
 
-        switch (statfsbuf.f_type) {
-        	case AFFS_SUPER_MAGIC:
-        		printf("AFFS\n");
-        		break;
-        	case EXT_SUPER_MAGIC:
-        		printf("EXT\n");
-        		break;
-        	case EXT2_OLD_SUPER_MAGIC:
-        		printf("EXT2\n");
-        		break;
-        	case EXT2_SUPER_MAGIC:
-        		printf("EXT2\n");
-        		break;
-		case HPFS_SUPER_MAGIC:
-			printf("HPFS\n");
-			break;
-		case ISOFS_SUPER_MAGIC:
-			printf("ISOFS\n");
-			break;
-		case MINIX_SUPER_MAGIC:
-			printf("MINIX\n");
-		case MINIX_SUPER_MAGIC2:
-			printf("MINIX (30 char.)\n");
-			break;
-		case MINIX2_SUPER_MAGIC:
-			printf("MINIX V2\n");
-			break;
-		case MINIX2_SUPER_MAGIC2:
-			printf("MINIX V2 (30 char.)\n");
-			break;
-		case MSDOS_SUPER_MAGIC:
-			printf("MSDOS\n");
-			break;
-		case NCP_SUPER_MAGIC:
-			printf("NOVELL\n");
-			break;
-		case NFS_SUPER_MAGIC:
-			printf("NFS\n");
-			break;
-		case PROC_SUPER_MAGIC:
-			printf("PROC\n");
-			break;
-		case SMB_SUPER_MAGIC:
-			printf("SMB\n");
-			break;
-		case XENIX_SUPER_MAGIC:
-			printf("XENIX\n");
-			break;
-		case SYSV4_SUPER_MAGIC:
-			printf("SYSV4\n");
-			break;
-		case SYSV2_SUPER_MAGIC:
-			printf("SYSV2\n");
-			break;
-		case COH_SUPER_MAGIC:
-			printf("COH\n");
-			break;
-		case UFS_MAGIC:
-			printf("UFS\n");
-			break;
-		case _XIAFS_SUPER_MAGIC:
-			printf("XIA\n");
-			break;
-		case NTFS_SUPER_MAGIC:
-			printf("NTFS\n");
-			break;
-        	default:
+	switch (statfsbuf.f_type) {
+#if defined(__linux__)
+	case AFFS_SUPER_MAGIC:
+		printf("AFFS\n");
+		break;
+	case EXT_SUPER_MAGIC:
+		printf("EXT\n");
+		break;
+	case EXT2_OLD_SUPER_MAGIC:
+		printf("EXT2\n");
+		break;
+	case EXT2_SUPER_MAGIC:
+		printf("EXT2\n");
+		break;
+	case HPFS_SUPER_MAGIC:
+		printf("HPFS\n");
+		break;
+	case ISOFS_SUPER_MAGIC:
+		printf("ISOFS\n");
+		break;
+	case MINIX_SUPER_MAGIC:
+		printf("MINIX\n");
+	case MINIX_SUPER_MAGIC2:
+		printf("MINIX (30 char.)\n");
+		break;
+	case MINIX2_SUPER_MAGIC:
+		printf("MINIX V2\n");
+		break;
+	case MINIX2_SUPER_MAGIC2:
+		printf("MINIX V2 (30 char.)\n");
+		break;
+	case MSDOS_SUPER_MAGIC:
+		printf("MSDOS\n");
+		break;
+	case NCP_SUPER_MAGIC:
+		printf("NOVELL\n");
+		break;
+	case NFS_SUPER_MAGIC:
+		printf("NFS\n");
+		break;
+	case PROC_SUPER_MAGIC:
+		printf("PROC\n");
+		break;
+	case SMB_SUPER_MAGIC:
+		printf("SMB\n");
+		break;
+	case XENIX_SUPER_MAGIC:
+		printf("XENIX\n");
+		break;
+	case SYSV4_SUPER_MAGIC:
+		printf("SYSV4\n");
+		break;
+	case SYSV2_SUPER_MAGIC:
+		printf("SYSV2\n");
+		break;
+	case COH_SUPER_MAGIC:
+		printf("COH\n");
+		break;
+	case UFS_MAGIC:
+		printf("UFS\n");
+		break;
+	case _XIAFS_SUPER_MAGIC:
+		printf("XIA\n");
+		break;
+	case NTFS_SUPER_MAGIC:
+		printf("NTFS\n");
+		break;
+#elif defined(__GNU__)		
+	case FSTYPE_UFS:
+		printf("UFS\n");
+		break;
+	case FSTYPE_NFS:
+		printf("NFS\n");
+		break;
+	case FSTYPE_GFS:
+		printf("GFS\n");
+		break;
+	case FSTYPE_LFS:
+		printf("LFS\n");
+		break;
+	case FSTYPE_SYSV:
+		printf("SYSV\n");
+		break;
+	case FSTYPE_FTP:
+		printf("FTP\n");
+		break;
+	case FSTYPE_TAR:
+		printf("TAR\n");
+		break;
+	case FSTYPE_AR:
+		printf("AR\n");
+		break;
+	case FSTYPE_CPIO:
+		printf("CPIO\n");
+		break;
+	case FSTYPE_MSLOSS:
+		printf("MSLOSS\n");
+		break;
+	case FSTYPE_CPM:
+		printf("CPM\n");
+		break;
+	case FSTYPE_HFS:
+		printf("HFS\n");
+		break;
+	case FSTYPE_DTFS:
+		printf("DTFS\n");
+		break;
+	case FSTYPE_GRFS:
+		printf("GRFS\n");
+		break;
+	case FSTYPE_TERM:
+		printf("TERM\n");
+		break;
+	case FSTYPE_DEV:
+		printf("DEV\n");
+		break;
+	case FSTYPE_PROC:
+		printf("PROC\n");
+		break;
+	case FSTYPE_IFSOCK:
+		printf("IFSOCK\n");
+		break;
+	case FSTYPE_AFS:
+		printf("AFS\n");
+		break;
+	case FSTYPE_DFS:
+		printf("DFS\n");
+		break;
+	case FSTYPE_PROC9:
+		printf("PROC9\n");
+		break;
+	case FSTYPE_SOCKET:
+		printf("SOCKET\n");
+		break;
+	case FSTYPE_MISC:
+		printf("MISC\n");
+		break;
+	case FSTYPE_EXT2FS:
+		printf("EXT2FS\n");
+		break;
+	case FSTYPE_HTTP:
+		printf("HTTP\n");
+		break;
+	case FSTYPE_MEMFS:
+		printf("MEMFS\n");
+		break;
+	case FSTYPE_ISO9660:
+		printf("ISO9660\n");
+		break;
+#endif
+	default:
 #ifdef __USE_FILE_OFFSET64 
         		printf("UNKNOWN (0x%lx)\n", statfsbuf.f_type);
 #else
@@ -124,8 +208,8 @@
 	printf("Blocks: Total: %-10lld Free: %-10lld Available: %-10lld Size: %ld\n",  statfsbuf.f_blocks, statfsbuf.f_bfree, statfsbuf.f_bavail, statfsbuf.f_bsize);
 	printf("Inodes: Total: %-10lld Free: %-10lld\n", statfsbuf.f_files, statfsbuf.f_ffree);
 #else
-	printf("Blocks: Total: %-10ld Free: %-10ld Available: %-10ld Size: %d\n", statfsbuf.f_blocks, statfsbuf.f_bfree, statfsbuf.f_bavail, statfsbuf.f_bsize);
-	printf("Inodes: Total: %-10ld Free: %-10ld\n", statfsbuf.f_files, statfsbuf.f_ffree);
+	printf("Blocks: Total: %-10d Free: %-10d Available: %-10d Size: %d\n", statfsbuf.f_blocks, statfsbuf.f_bfree, statfsbuf.f_bavail, statfsbuf.f_bsize);
+	printf("Inodes: Total: %-10d Free: %-10d\n", statfsbuf.f_files, statfsbuf.f_ffree);
 #endif
 }
                                                                                                                                                          
@@ -145,14 +229,14 @@
     }
     
     if (terse != 0) {
-		printf("%s %u %u %x %d %d %x %d %d %x %x %d %d %d %d\n",
+		printf("%s %u %u %x %d %d %Lx %d %d %x %x %d %d %d %d\n",
 			filename,
 			(unsigned int)statbuf.st_size,
 			(unsigned int)statbuf.st_blocks,
 			statbuf.st_mode,
 			statbuf.st_uid,
 			statbuf.st_gid,
-			(int)statbuf.st_dev,
+			statbuf.st_dev,
 			(int)statbuf.st_ino,
 			(int)statbuf.st_nlink,
 			major(statbuf.st_rdev),
@@ -203,8 +287,8 @@
 	(void) printf("Unknown\n");
     }
 
-    printf("Device: %xh/%dd\tInode: %-10d  Links: %-5d", (int)statbuf.st_dev, (int)statbuf.st_dev,
-    	 (int)statbuf.st_ino, (int)statbuf.st_nlink);
+    printf("Device: %Lxh/%dd\tInode: %-10d  Links: %-5d", statbuf.st_dev,(int)statbuf.st_dev,
+    	 statbuf.st_ino, (int)statbuf.st_nlink);
 
     i = statbuf.st_mode & S_IFMT;
     if (i == S_IFCHR || i == S_IFBLK)




Reply to: