Hi,

Okie, here is the second batch of changes for GNU Fileutils.  This time it
consists of three patches. Comments from the maintainers of FETISH (FIleutils,
TExtutils, SH-utils) are especially welcome..

This patch fill make `cp' preserve the st_author field.

2002-04-03  Alfred M. Szmidt  <[EMAIL PROTECTED]>
        * configure.ac: Check for hurd.h
        * src/cp.c [HAVE_HURD_H] <hurd.h>: New include.
        Preserve the stat.st_author field.

diff -urp fileutils-4.1.7.orig/configure.ac fileutils-4.1.7-cp/configure.ac
--- fileutils-4.1.7.orig/configure.ac   Sun Mar 31 08:10:32 2002
+++ fileutils-4.1.7-cp/configure.ac     Tue Apr  2 16:10:57 2002
@@ -45,6 +45,8 @@ if test $fu_cv_sys_truncating_statfs = y
 fi
 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
 
+AC_CHECK_HEADERS(hurd.h)
+
 jm_LIB_CHECK
 
 AM_GNU_GETTEXT
Only in fileutils-4.1.7-cp: obj
diff -urp fileutils-4.1.7.orig/src/copy.c fileutils-4.1.7-cp/src/copy.c
--- fileutils-4.1.7.orig/src/copy.c     Sun Mar 10 03:27:11 2002
+++ fileutils-4.1.7-cp/src/copy.c       Tue Apr  2 16:13:42 2002
@@ -26,6 +26,10 @@
 #include <assert.h>
 #include <sys/types.h>
 
+#if HAVE_HURD_H
+# include <hurd.h>
+#endif
+
 #include "system.h"
 #include "error.h"
 #include "backupfile.h"
@@ -1504,6 +1508,16 @@ copy_internal (const char *src_path, con
        }
     }
 
+#if HAVE_HURD_H
+  /* Preserve the st_author field.  */
+  {
+    file_t file = getdport (dst_path);
+    if (file_chauthor (file, src_sb.st_author))
+      error (0, errno, _("preserving authorship for %s"), quote (dst_path));
+    mach_port_deallocate (mach_task_self (), file);
+  }
+#endif
+  
   /* Permissions of newly-created regular files were set upon `open' in
      copy_reg.  But don't return early if there were any special bits and
      we had to run chown, because the chown must have reset those bits.  */


And this patch will add a new option to `ls' called --author that will
show you the st_author field.

2002-04-03  Alfred M. Szmidt  <[EMAIL PROTECTED]>
        * configure.ac: Check for stat.st_author.
        * src/ls.c [HAVE_STRUCT_STAT_ST_AUTHOR] (print_author): New variable.
        (enum, long_options, decode_switches, usage): New option --author.
        (print_long_format): Print the st_author field.

diff -urp fileutils-4.1.7.orig/configure.ac fileutils-4.1.7-ls-author/configure.ac
--- fileutils-4.1.7.orig/configure.ac   Sun Mar 31 08:10:32 2002
+++ fileutils-4.1.7-ls-author/configure.ac      Sun Mar 31 08:11:04 2002
@@ -45,6 +45,8 @@ if test $fu_cv_sys_truncating_statfs = y
 fi
 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
 
+AC_CHECK_MEMBERS([struct stat.st_author])
+
 jm_LIB_CHECK
 
 AM_GNU_GETTEXT
diff -urp fileutils-4.1.7.orig/src/ls.c fileutils-4.1.7-ls-author/src/ls.c
--- fileutils-4.1.7.orig/src/ls.c       Sun Mar 31 08:10:32 2002
+++ fileutils-4.1.7-ls-author/src/ls.c  Tue Apr  2 19:07:30 2002
@@ -461,6 +461,11 @@ static int sort_reverse;
 
 static int print_owner = 1;
 
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+/* Nonzero means to display author information.*/
+static int print_author = 0;
+#endif
+
 /* Nonzero means to display group information.  -G and -o turn this off.  */
 
 static int print_group = 1;
@@ -707,6 +712,9 @@ enum
   SI_OPTION,
   SORT_OPTION,
   TIME_OPTION,
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+  AUTHOR_OPTION,
+#endif
   TIME_STYLE_OPTION
 };
 
@@ -747,6 +755,9 @@ static struct option const long_options[
   {"time-style", required_argument, 0, TIME_STYLE_OPTION},
   {"color", optional_argument, 0, COLOR_OPTION},
   {"block-size", required_argument, 0, BLOCK_SIZE_OPTION},
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+  {"author", no_argument, 0, AUTHOR_OPTION},
+#endif
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
   {NULL, 0, NULL, 0}
@@ -1494,6 +1505,13 @@ decode_switches (int argc, char **argv)
            format = one_per_line;
          break;
 
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+       case AUTHOR_OPTION:
+         format = long_format;
+         print_author = 1;
+         break;
+#endif
+
        case SORT_OPTION:
          sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types);
          sort_type_specified = 1;
@@ -2834,6 +2852,19 @@ print_long_format (const struct fileinfo
       p += strlen (p);
     }
 
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+  if (print_author)
+    {
+      char const *author_name = 
+       (numeric_ids ? NULL : getuser (f->stat.st_author));
+      if (author_name)
+       sprintf (p, "%-8s ", author_name);
+      else
+       sprintf (p, "%-8lu ", (unsigned long) f->stat.st_author);
+      p += strlen (p);
+    }
+#endif
+
   if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
     sprintf (p, "%3lu, %3lu ",
             (unsigned long) major (f->stat.st_rdev),
@@ -3586,6 +3617,11 @@ Mandatory arguments to long options are 
   -A, --almost-all           do not list implied . and ..\n\
   -b, --escape               print octal escapes for nongraphic characters\n\
 "), stdout);
+#if HAVE_STRUCT_STAT_ST_AUTHOR
+      fputs(_("\
+      --author               print the author of each file\n\
+"), stdout);
+#endif
       fputs (_("\
       --block-size=SIZE      use SIZE-byte blocks\n\
   -B, --ignore-backups       do not list implied entries ending with ~\n\


Finally the last patch, this will add two new options to ls
--translators and --unknown-users. The first option will print some useful
information about active/passive translators, and the second one will
print the unknown user bits (this should probably be split up into
two separate patches).

2002-04-03  Alfred M. Szmidt  <[EMAIL PROTECTED]>
        * configure.ac: Check for hurd.h.
        * src/ls.c [HAVE_HURD_H] <hurd.h>: Include.
        (struct fileinfo): New member `trans_name', 'trans_fsid', 'trans_mode'.
        (print_translators, print_unknown_users): New variable.
        (enum, long_options, decode_switches, usage): New options --translators
        and --unknown-users.
        (gobble_file): Implement new behaviour for --translators.
        (print_long_format): Implement new behaviour for --unknown-users.
        
diff -urp fileutils-4.1.7.orig/configure.ac fileutils-4.1.7-ls-ext/configure.ac
--- fileutils-4.1.7.orig/configure.ac   Sun Mar 31 08:10:32 2002
+++ fileutils-4.1.7-ls-ext/configure.ac Tue Apr  2 19:44:17 2002
@@ -45,6 +45,8 @@ if test $fu_cv_sys_truncating_statfs = y
 fi
 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
 
+AC_CHECK_HEADERS(hurd.h)
+
 jm_LIB_CHECK
 
 AM_GNU_GETTEXT
diff -urp fileutils-4.1.7.orig/src/ls.c fileutils-4.1.7-ls-ext/src/ls.c
--- fileutils-4.1.7.orig/src/ls.c       Sun Mar 31 08:10:32 2002
+++ fileutils-4.1.7-ls-ext/src/ls.c     Wed Apr  3 15:15:25 2002
@@ -60,6 +60,10 @@
 # include <sys/ptem.h>
 #endif
 
+#if HAVE_HURD_H
+# include <hurd.h>
+#endif
+
 #include <stdio.h>
 #include <assert.h>
 #include <setjmp.h>
@@ -219,6 +223,18 @@ struct fileinfo
 
     struct stat stat;
 
+#if HAVE_HURD_H    
+    /* The translator that is attached to the node.  */
+    char *trans_name;
+    
+    /* The fsid for the active translator.  */
+    int trans_fsid;
+    
+    /* If 1 then we have a translator attached and/or running on the node,
+       otherwise 0.  */
+    int trans_mode;
+#endif
+    
     /* For symbolic link, name of the file linked to, otherwise zero. */
     char *linkname;
 
@@ -465,6 +481,14 @@ static int print_owner = 1;
 
 static int print_group = 1;
 
+#if HAVE_HURD_H
+/* Nonzero means to display translator information.  */
+static int print_translators = 0;
+
+/* Nonzero means to display unknown user permission bits.  */
+static int print_unknown_users = 0;
+#endif
+
 /* Nonzero means print the user and group id's as numbers rather
    than as names.  -n  */
 
@@ -707,6 +731,10 @@ enum
   SI_OPTION,
   SORT_OPTION,
   TIME_OPTION,
+#if HAVE_HURD_H
+  UNKNOWN_USERS_OPTION,
+  TRANSLATORS_OPTION,
+#endif
   TIME_STYLE_OPTION
 };
 
@@ -747,6 +775,10 @@ static struct option const long_options[
   {"time-style", required_argument, 0, TIME_STYLE_OPTION},
   {"color", optional_argument, 0, COLOR_OPTION},
   {"block-size", required_argument, 0, BLOCK_SIZE_OPTION},
+#if HAVE_HURD_H
+  {"unknown-users", no_argument, 0, UNKNOWN_USERS_OPTION},
+  {"translators", no_argument, 0, TRANSLATORS_OPTION},
+#endif
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
   {NULL, 0, NULL, 0}
@@ -1494,6 +1526,18 @@ decode_switches (int argc, char **argv)
            format = one_per_line;
          break;
 
+#if HAVE_HURD_H
+       case TRANSLATORS_OPTION:
+         format = long_format;
+         print_translators = 1;
+         break;
+
+       case UNKNOWN_USERS_OPTION:
+         format = long_format;
+         print_unknown_users = 1;
+         break;
+#endif
+
        case SORT_OPTION:
          sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types);
          sort_type_specified = 1;
@@ -2287,6 +2331,51 @@ gobble_file (const char *name, enum file
            free (linkpath);
        }
 
+#if HAVE_HURD_H
+      if ((files[files_index].stat.st_mode & S_IROOT) && print_translators)
+       {
+          int trans_fd;
+         file_t trans_port;
+          struct stat trans_stat;
+         
+          files[files_index].trans_fsid = files[files_index].stat.st_fsid;
+         
+          /* Get the underlying node */
+         trans_fd = open (path, O_NOTRANS);
+         if ((trans_fd && fstat (trans_fd, &trans_stat)) < 0)
+           {
+             error (0, errno, "%s", quotearg_colon (path));
+             close (trans_fd);
+             exit_status = 1;
+             return 0;
+           }
+         
+         trans_port = getdport (trans_fd);
+         close (trans_fd);
+         
+          if (trans_stat.st_mode & S_IPTRANS)
+            {
+              char buf[1024], *trans = buf;
+              int trans_len = sizeof (buf);
+             
+             if (file_get_translator (trans_port, &trans, &trans_len))
+                {
+                 mach_port_deallocate (mach_task_self(), trans_port);
+                  error (0, errno, "%s", quotearg_colon (path));
+                  exit_status = 1;
+                  return 0;
+                }
+              
+              argz_stringify (trans, trans_len, ' ');
+              
+              files[files_index].trans_name = strdup(trans);
+              files[files_index].trans_mode = 1;
+             
+             mach_port_deallocate (mach_task_self(), trans_port);
+           }
+       }
+#endif
+      
       if (S_ISLNK (files[files_index].stat.st_mode))
        files[files_index].filetype = symbolic_link;
       else if (S_ISDIR (files[files_index].stat.st_mode))
@@ -2744,15 +2833,18 @@ get_current_time (void)
 static void
 print_long_format (const struct fileinfo *f)
 {
-  char modebuf[12];
+  char modebuf[15];
 
   /* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
-     1 10-byte mode string,
+     1 10-byte mode string (13-bytes on GNU/Hurd),
      1 35-byte time string (may be longer in some locales -- see below)
        or LONGEST_HUMAN_READABLE integer,
      9 spaces, one following each of these fields, and
      1 trailing NUL byte.  */
   char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10
+#if HAVE_HURD_H
+                  + 3
+#endif
                   + MAX (35, LONGEST_HUMAN_READABLE)
                   + 9 + 1];
   char *buf = init_bigbuf;
@@ -2770,9 +2862,34 @@ print_long_format (const struct fileinfo
   mode_string (f->stat.st_mode, modebuf);
 #endif
 
-  modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
-  modebuf[11] = '\0';
-
+#if HAVE_HURD_H
+  if (print_unknown_users)
+    {
+      if (f->stat.st_mode & S_IUSEUNK)
+       {
+         modebuf[10] = f->stat.st_mode & (S_IRUSR << S_IUNKSHIFT) ? 'r' : '-';
+         modebuf[11] = f->stat.st_mode & (S_IWUSR << S_IUNKSHIFT) ? 'w' : '-';
+         modebuf[12] = f->stat.st_mode & (S_IXUSR << S_IUNKSHIFT) ? 'x' : '-';
+       }
+      else
+       /* If S_IUSEUNK is not set then default to showing group member
+          permission bits. */
+       {
+         modebuf[10] = f->stat.st_mode & S_IROTH ? 'r' : '-';
+         modebuf[11] = f->stat.st_mode & S_IWOTH ? 'w' : '-';
+         modebuf[12] = f->stat.st_mode & S_IXOTH ? 'x' : '-';
+       }
+      
+      modebuf[13] = (FILE_HAS_ACL (f) ? '+' : ' ');
+      modebuf[14] = '\0';
+    }
+  else
+#endif
+    {
+      modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
+      modebuf[11] = '\0';
+    }
+  
   switch (time_type)
     {
     case time_ctime:
@@ -2940,6 +3057,19 @@ print_long_format (const struct fileinfo
            print_type_indicator (f->linkmode);
        }
     }
+#if HAVE_HURD_H
+  else if ((f->stat.st_mode & S_IROOT)
+          && print_translators)
+    {
+      DIRED_FPUTS_LITERAL (" => ", stdout);
+      if (f->trans_name)
+       printf ("%s", f->trans_name);
+      else
+       printf ("unknown");
+      
+      printf (" (%d)", f->trans_fsid);
+    }
+#endif
   else if (indicator_style != none)
     print_type_indicator (f->stat.st_mode);
 }
@@ -3658,6 +3788,12 @@ Mandatory arguments to long options are 
                                atime, access, use, ctime or status; use\n\
                                specified time as sort key if --sort=time\n\
 "), stdout);
+#if HAVE_HURD_H
+      fputs (_("\
+      --translators          show active/passive translator information\n\
+      --unknown-users        show unknown-user permission bits\n\
+"), stdout);
+#endif
       fputs (_("\
       --time-style=WORD      show times using style WORD:\n\
                                full-iso, iso, locale, posix-iso, +FORMAT\n\

Have fun,
-- 
Alfred M. Szmidt

Reply via email to