bug-coreutils
[Top][All Lists]
Advanced

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

coreutils patch for dev_t/ino_t wider than long


From: Paul Eggert
Subject: coreutils patch for dev_t/ino_t wider than long
Date: Wed, 04 Aug 2004 15:06:17 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I installed this patch needed for hosts like Solaris 9, where ino_t is
long long.  Might as well treat dev_t similarly while we're at it.

2004-08-04  Paul Eggert  <address@hidden>

        * lib/fts.c (LONGEST_MODIFIER): New macro.
        (PRIuMAX) [!PRI_MACROS_BROKEN && !defined PRIuMAX]: New macro.
        (find_matching_ancestor): Use it for dev_t and ino_t.
        * src/stat.c (print_stat): Don't assume st_ino / st_dev fits in
        unsigned long; this isn't true for st_ino on Solaris 9.

Index: lib/fts.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/fts.c,v
retrieving revision 1.16
diff -p -u -r1.16 fts.c
--- lib/fts.c   2 Aug 2004 19:42:01 -0000       1.16
+++ lib/fts.c   4 Aug 2004 21:07:44 -0000
@@ -76,6 +76,17 @@ static char sccsid[] = "@(#)fts.c    8.6 (B
 #if HAVE_STDINT_H
 # include <stdint.h>
 #endif
+#if ULONG_MAX < ULLONG_MAX
+# define LONGEST_MODIFIER "ll"
+#else
+# define LONGEST_MODIFIER "l"
+#endif
+#if PRI_MACROS_BROKEN
+# undef PRIuMAX
+#endif
+#ifndef PRIuMAX
+# define PRIuMAX LONGEST_MODIFIER "u"
+#endif
 
 #if defined _LIBC
 # include <dirent.h>
@@ -1103,13 +1114,13 @@ find_matching_ancestor (FTSENT const *e_
   printf ("active dirs:\n");
   for (ent = e_curr;
        ent->fts_level >= FTS_ROOTLEVEL; ent = ent->fts_parent)
-    printf ("  %s(%lu/%lu) to %s(%lu/%lu)...\n",
+    printf ("  %s(%"PRIuMAX"/%"PRIuMAX") to %s(%"PRIuMAX"/%"PRIuMAX")...\n",
            ad->fts_ent->fts_accpath,
-           (unsigned long int) ad->dev,
-           (unsigned long int) ad->ino,
+           (uintmax_t) ad->dev,
+           (uintmax_t) ad->ino,
            ent->fts_accpath,
-           (unsigned long int) ent->fts_statp->st_dev,
-           (unsigned long int) ent->fts_statp->st_ino);
+           (uintmax_t) ent->fts_statp->st_dev,
+           (uintmax_t) ent->fts_statp->st_ino);
 }
 
 void
Index: src/stat.c
===================================================================
RCS file: /home/eggert/coreutils/cu/src/stat.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -p -u -r1.73 -r1.74
--- src/stat.c  3 Aug 2004 19:08:31 -0000       1.73
+++ src/stat.c  4 Aug 2004 22:04:26 -0000       1.74
@@ -450,16 +450,16 @@ print_stat (char *pformat, char m, char 
        }
       break;
     case 'd':
-      strcat (pformat, "lu");
-      printf (pformat, (unsigned long int) statbuf->st_dev);
+      strcat (pformat, PRIuMAX);
+      printf (pformat, (uintmax_t) statbuf->st_dev);
       break;
     case 'D':
-      strcat (pformat, "lx");
-      printf (pformat, (unsigned long int) statbuf->st_dev);
+      strcat (pformat, PRIxMAX);
+      printf (pformat, (uintmax_t) statbuf->st_dev);
       break;
     case 'i':
-      strcat (pformat, "lu");
-      printf (pformat, (unsigned long int) statbuf->st_ino);
+      strcat (pformat, PRIuMAX);
+      printf (pformat, (uintmax_t) statbuf->st_ino);
       break;
     case 'a':
       strcat (pformat, "lo");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]