On Fri, Aug 10, 2001 at 03:28:59PM +0530, Nikunj A. Dadhania wrote:
> here is the patch

Thanks. A correction:
 
> 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",

You need a change here, too ^^^^^.

>  #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",

No need to print the thing twice, once is enough.

fsid does not change with USE_FILE_OFFSET64 (it's not related to files at
all).

>  #endif
>                       filename,
> -                     statfsbuf.f_fsid.__val[0],
> -                     statfsbuf.f_fsid.__val[1],
> +                     statfsbuf.f_fsid,
> +                     statfsbuf.f_fsid,

And only one of these two.

>                       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

Same here, only one time each.  The 16 was only a guess, it is needed to make 
the
column align.  I suggest a test run to find the real value (17 = 8 + 1 + 8?)

> -        switch (statfsbuf.f_type) {
> -             case AFFS_SUPER_MAGIC:

Why did you reindent the whole thing?

> +     case MINIX_SUPER_MAGIC:
> +             printf("MINIX\n");
> +     case MINIX_SUPER_MAGIC2:


Here is a bug in the upstream code? The entry misses a break;

>  #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.

> @@ -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,


> -    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);

Ayupp, we have a problem here. st_dev is dev_t which is int on Linux, but
on the Hurd, it is the same as fsid (long).  But why did you remove the cast
to int of statbuf.st_ino?

It is possible to determine the size of the field in C.  When you do that
and set a variable st_dev_len to 4/8 and then switch on that, do you think
this would be a good solution? Otherwise, you can also just do

#ifndef (__GNU__)
Original code
#else
Your version
#endif

Which is far simpler ;)

Thanks,
Marcus



-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org [EMAIL PROTECTED]
Marcus Brinkmann              GNU    http://www.gnu.org    [EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.marcus-brinkmann.de


Reply via email to