Hi, I wrote a patch for ls, which allowls to display long username and group name. The patch is for fileutils-4.0.36, and I added a new switch to ls, "-e" or "--longname".
It is very simple, I hope it is useful to you. Regards. Xiang Xuesong
ls2
Description: Binary data
--- ls.c Tue May 14 09:56:27 2002
+++ ls.c.orign Tue May 14 10:04:48 2002
@@ -689,5 +689,4 @@
{"inode", no_argument, 0, 'i'},
{"kilobytes", no_argument, 0, 'k'},
- {"longname", no_argument, 0, 'e'},
{"numeric-uid-gid", no_argument, 0, 'n'},
{"no-group", no_argument, 0, 'G'},
@@ -833,8 +832,4 @@
-static int max_username_len = 8;
-static int max_groupname_len = 8;
-static int display_longname = 0;
-
/* Write to standard output PREFIX, followed by the quoting style and
a space-separated list of the integers stored in OS all on one line. */
@@ -917,5 +912,5 @@
gobble_file (argv[i], unknown, 1, "");
}
-
+
if (dir_defaulted)
{
@@ -928,5 +923,4 @@
if (files_index)
{
-
sort_files ();
if (!immediate_dirs)
@@ -947,5 +941,4 @@
thispend = pending_dirs;
pending_dirs = pending_dirs->next;
-
print_dir (thispend->name, thispend->realname);
free (thispend->name);
@@ -1093,5 +1086,5 @@
while ((c = getopt_long (argc, argv,
- "abcdefghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
+ "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1",
long_options, NULL)) != -1)
{
@@ -1117,7 +1110,5 @@
immediate_dirs = 1;
break;
- case 'e':
- display_longname = 1;
- break;
+
case 'f':
/* Same as enabling -a -U and disabling -l -s. */
@@ -1894,6 +1885,5 @@
register uintmax_t blocks;
register char *path;
- int uid, gid;
-
+
if (files_index == nfiles)
{
@@ -1982,7 +1972,5 @@
files[files_index].linkok = 1;
}
- }
-
-
+ }
if (linkpath)
free (linkpath);
@@ -2000,5 +1988,4 @@
else
files[files_index].filetype = normal;
-
blocks = ST_NBLOCKS (files[files_index].stat);
@@ -2021,20 +2008,5 @@
}
- uid = files[files_index].stat.st_uid;
- gid = files[files_index].stat.st_gid;
-
files[files_index].name = xstrdup (name);
-
- if(getgroup(gid) && display_longname){
- if(strlen(getgroup(gid)) > max_groupname_len){
- max_groupname_len = strlen(getgroup(gid));
- }
- }
- if(getuser(uid) && display_longname){
- if(strlen(getuser(uid)) > max_username_len){
- max_username_len = strlen(getuser(uid));
- }
- }
-
files_index++;
@@ -2529,7 +2501,7 @@
user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));
if (user_name)
- sprintf (p, "%-*.*s ", max_username_len, max_username_len, user_name);
+ sprintf (p, "%-8.8s ", user_name);
else
- sprintf (p, "%-*u ", max_username_len, (unsigned int) f->stat.st_uid);
+ sprintf (p, "%-8u ", (unsigned int) f->stat.st_uid);
p += strlen (p);
@@ -2538,7 +2510,7 @@
char *group_name = (numeric_ids ? NULL : getgroup (f->stat.st_gid));
if (group_name)
- sprintf (p, "%-*.*s ", max_groupname_len, max_groupname_len, group_name);
+ sprintf (p, "%-8.8s ", group_name);
else
- sprintf (p, "%-*u ", max_groupname_len, (unsigned int) f->stat.st_gid);
+ sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid);
p += strlen (p);
}
@@ -3289,5 +3261,4 @@
-d, --directory list directory entries instead of contents\n\
-D, --dired generate output designed for Emacs' dired mode\n\
- -e, --longname display full username and group name\n\
-f do not sort, enable -aU, disable -lst\n\
-F, --classify append indicator (one of */=@|) to entries\n\
