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 #endif +#if HAVE_HURD_H +# include +#endif + #include #include #include @@ -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\