FreeBSD Bugzilla – Attachment 5354 Details for
Bug 12866
[PATCH] RFE for /bin/ls to add a -n option for showing uid/gid numerically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.61 KB, created by
pckizer
on 1999-07-29 07:20:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
pckizer
Created:
1999-07-29 07:20:00 UTC
Size:
1.61 KB
patch
obsolete
>--- ls.c-old Wed Jul 28 15:16:56 1999 >+++ ls.c Wed Jul 28 16:11:55 1999 >@@ -100,6 +100,7 @@ > int f_timesort; /* sort by time vice name */ > int f_type; /* add type character for non-regular files */ > int f_whiteout; /* show whiteout entries */ >+int f_numbers; /* show uid/gid numbers rather than names */ > > int rval; > >@@ -137,7 +138,7 @@ > f_listdot = 1; > > fts_options = FTS_PHYSICAL; >- while ((ch = getopt(argc, argv, "1ABCFHLPRTWabcdfgikloqrstu")) != -1) { >+ while ((ch = getopt(argc, argv, "1ABCFHLPRTWabcdfgiklnoqrstu")) != -1) { > switch (ch) { > /* > * The -1, -C and -l options all override each other so shell >@@ -209,6 +210,9 @@ > case 'k': > f_kblocks = 1; > break; >+ case 'n': >+ f_numbers = 1; >+ break; > case 'o': > f_flags = 1; > break; >@@ -401,6 +405,7 @@ > char *initmax; > int entries, needstats; > char *user, *group, *flags, buf[20]; /* 32 bits == 10 digits */ >+ char user_num[8], group_num[8]; > > /* > * If list is NULL there are two possibilities: that the parent >@@ -512,10 +517,19 @@ > > btotal += sp->st_blocks; > if (f_longform) { >- user = user_from_uid(sp->st_uid, 0); >+ if (f_numbers) { >+ snprintf(user_num, sizeof(user_num), >+ "%d", sp->st_uid); >+ user = user_num; >+ snprintf(group_num, sizeof(group_num), >+ "%d", sp->st_gid); >+ group = user_num; >+ } else { >+ user = user_from_uid(sp->st_uid, 0); >+ group = group_from_gid(sp->st_gid, 0); >+ } > if ((ulen = strlen(user)) > maxuser) > maxuser = ulen; >- group = group_from_gid(sp->st_gid, 0); > if ((glen = strlen(group)) > maxgroup) > maxgroup = glen; > if (f_flags) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 12866
: 5354