[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 03:28:59PM +0530, Nikunj A. Dadhania wrote:
> > here is the patch
> 
> Thanks. A correction:
>  
Thanks for the correctionS :)

> >  #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
> 
> Why did you touch this code? long is correct for these.
No its not long, it is declared as unsigned int 
in structure statfs(/include/bits/statfs.h) it is declared as

#ifndef __USE_FILE_OFFSET64
    __fsblkcnt_t f_blocks;
    __fsblkcnt_t f_bfree;
    __fsblkcnt_t f_bavail;
....

and __fsblkcnt_t in /include/bits/types.h is declared as

/* Type to count file system blocks.  */
typedef unsigned int __fsblkcnt_t;
typedef __u_quad_t __fsblkcnt64_t;



> > -    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);
> 
 
> #ifndef (__GNU__)
> Original code
> #else
> Your version
> #endif
> 
> Which is far simpler ;)
yes

thanks
nikunj

new patch with corrections

diff -ruN stat-2.5.orig/fs.h stat/stat-2.5.orig/fs.h
--- stat-2.5.orig/fs.h	Mon Oct 11 17:53:17 1999
+++ stat/stat-2.5.orig/fs.h	Fri Aug 10 18:09:14 2001
@@ -1,6 +1,7 @@
 /* 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 +24,6 @@
 #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 stat/stat-2.5.orig/stat.c
--- stat-2.5.orig/stat.c	Thu May 10 13:25:29 2001
+++ stat/stat-2.5.orig/stat.c	Fri Aug 10 19:11:26 2001
@@ -21,14 +21,13 @@
 
 	if (terse != 0) {
 #ifdef __USE_FILE_OFFSET64
-		printf("%s %x %x %lu %lx %lld %lld %lld %ld %lld %lld\n",
+		printf("%s %Lx %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 %d %x %d %d %d %d %d %d\n",
 #endif
 			filename,
-			statfsbuf.f_fsid.__val[0],
-			statfsbuf.f_fsid.__val[1],
-			statfsbuf.f_namelen,
+			statfsbuf.f_fsid,
+		        statfsbuf.f_namelen,
 			statfsbuf.f_type,
 			statfsbuf.f_blocks,
 			statfsbuf.f_bfree,
@@ -42,12 +41,13 @@
 	
 	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: %-14x Namelen: %-15ld Type: ", (int)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: %-14x Namelen: %-15d Type: ", (int)statfsbuf.f_fsid, statfsbuf.f_namelen);
 #endif
 
         switch (statfsbuf.f_type) {
+#if defined(__linux__)
         	case AFFS_SUPER_MAGIC:
         		printf("AFFS\n");
         		break;
@@ -68,7 +68,7 @@
 			break;
 		case MINIX_SUPER_MAGIC:
 			printf("MINIX\n");
-		case MINIX_SUPER_MAGIC2:
+	        case MINIX_SUPER_MAGIC2:
 			printf("MINIX (30 char.)\n");
 			break;
 		case MINIX2_SUPER_MAGIC:
@@ -113,6 +113,89 @@
 		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);
@@ -123,6 +206,9 @@
 #ifdef __USE_FILE_OFFSET64
 	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);
+#elif __GNU__
+	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);
 #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);
@@ -202,10 +288,13 @@
     default:
 	(void) printf("Unknown\n");
     }
-
+#ifndef __GNU__
+    printf("Device: %xh/%dd\tInode: %-10d  Links: %-5d", (int)statbuf.st_dev, (int)statbuf.st_dev,
+    	 statbuf.st_ino, (int)statbuf.st_nlink);
+#else
     printf("Device: %xh/%dd\tInode: %-10d  Links: %-5d", (int)statbuf.st_dev, (int)statbuf.st_dev,
     	 (int)statbuf.st_ino, (int)statbuf.st_nlink);
-
+#endif
     i = statbuf.st_mode & S_IFMT;
     if (i == S_IFCHR || i == S_IFBLK)
 	printf(" Device type: %x,%x\n", major(statbuf.st_rdev), minor(statbuf.st_rdev));
 



Reply to: