diff -ur fileutils-4.1/doc/fileutils.texi fileutils-octal-mode/doc/fileutils.texi --- fileutils-4.1/doc/fileutils.texi Mon Apr 23 03:36:22 2001 +++ fileutils-octal-mode/doc/fileutils.texi Fri Jun 8 20:45:01 2001 @@ -690,7 +690,8 @@ @cindex permissions, output by @code{ls} The permissions listed are similar to symbolic mode specifications -(@pxref{Symbolic Modes}). But @code{ls} combines multiple bits into the +(@pxref{Symbolic Modes}) (unless @option{-M} is used). +But @code{ls} combines multiple bits into the third character of each set of permissions as follows: @table @samp @item s @@ -988,6 +989,13 @@ @opindex address@hidden, outputting between files} List files horizontally, with as many as will fit on each line, separated by @samp{, } (a comma and a space). + address@hidden -M address@hidden --numeric-mode address@hidden -M address@hidden --numeric-mode address@hidden numeric mode +List the octal file mode instead of the symbolic mode. @item -n @itemx --numeric-uid-gid diff -ur fileutils-4.1/lib/filemode.c fileutils-octal-mode/lib/filemode.c --- fileutils-4.1/lib/filemode.c Sat Apr 15 17:47:31 2000 +++ fileutils-octal-mode/lib/filemode.c Fri Jun 8 20:22:27 2001 @@ -171,7 +171,7 @@ '-' for regular files '?' for any other file type. */ -static char +char ftypelet (mode_t bits) { #ifdef S_ISBLK diff -ur fileutils-4.1/lib/filemode.h fileutils-octal-mode/lib/filemode.h --- fileutils-4.1/lib/filemode.h Mon Apr 26 08:16:14 1999 +++ fileutils-octal-mode/lib/filemode.h Fri Jun 8 20:21:51 2001 @@ -15,5 +15,6 @@ # endif void mode_string PARAMS ((mode_t mode, char *str)); +char ftypelet PARAMS ((mode_t bits)); #endif diff -ur fileutils-4.1/src/ls.c fileutils-octal-mode/src/ls.c --- fileutils-4.1/src/ls.c Sun Apr 29 05:42:47 2001 +++ fileutils-octal-mode/src/ls.c Sun Jun 10 20:46:36 2001 @@ -241,12 +241,6 @@ #endif }; -#if USE_ACL -# define FILE_HAS_ACL(F) ((F)->have_acl) -#else -# define FILE_HAS_ACL(F) 0 -#endif - #define LEN_STR_PAIR(s) sizeof (s) - 1, s /* Null is a valid character in a color indicator (think about Epson @@ -453,6 +447,11 @@ static int numeric_ids; +/* Nonzero means print the file modes as octal numbers rather + than as symbolic-mode strings. -M */ + +static int numeric_mode; + /* Nonzero means mention the size in blocks of each file. -s */ static int print_block_size; @@ -690,6 +689,7 @@ {"ignore", required_argument, 0, 'I'}, {"indicator-style", required_argument, 0, INDICATOR_STYLE_OPTION}, {"dereference", no_argument, 0, 'L'}, + {"numeric-mode", no_argument, 0, 'M'}, {"literal", no_argument, 0, 'N'}, {"quote-name", no_argument, 0, 'Q'}, {"quoting-style", required_argument, 0, QUOTING_STYLE_OPTION}, @@ -1076,7 +1076,7 @@ } while ((c = getopt_long (argc, argv, - "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1", + "abcdfghiklmnopqrstuvw:xABCDFGHI:LMNQRST:UX1", long_options, NULL)) != -1) { switch (c) @@ -1233,6 +1233,10 @@ trace_links = 1; break; + case 'M': + numeric_mode = 1; + break; + case 'N': set_quoting_style (NULL, literal_quoting_style); break; @@ -2456,14 +2460,30 @@ char *user_name; #if HAVE_ST_DM_MODE - /* Cray DMF: look at the file's migrated, not real, status */ - mode_string (f->stat.st_dm_mode, modebuf); +/* Cray DMF: look at the file's migrated, not real, status */ +#define ST_MODE st_dm_mode #else - mode_string (f->stat.st_mode, modebuf); +#define ST_MODE st_mode #endif - - modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' '); - modebuf[11] = '\0'; + if (numeric_mode) + { + char ftype = ftypelet (f->stat.ST_MODE); + sprintf (modebuf, "%c %4o", (ftype == '-' ? ' ' : ftype), f->stat.ST_MODE & 07777); +#if USE_ACL + modebuf[6] = (f->have_acl ? '+' : ' '); + modebuf[7] = '\0'; +#endif + } + else + { + mode_string (f->stat.ST_MODE, modebuf); +#if USE_ACL + modebuf[10] = (f->have_acl ? '+' : ' '); + modebuf[11] = '\0'; +#else + modebuf[10] = '\0'; +#endif + } switch (time_type) { @@ -3289,6 +3309,7 @@ -l use a long listing format\n\ -L, --dereference list entries pointed to by symbolic links\n\ -m fill width with a comma separated list of entries\n\ + -M, --numeric-mode list octal file mode instead of symbolic mode\n\ -n, --numeric-uid-gid list numeric UIDs and GIDs instead of names\n\ -N, --literal print raw entry names (don't treat e.g. control\n\ characters specially)\n\