Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146172101
D2854.id7120.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D2854.id7120.diff
View Options
Index: head/bin/ls/ls.h
===================================================================
--- head/bin/ls/ls.h
+++ head/bin/ls/ls.h
@@ -37,6 +37,8 @@
#define HUMANVALSTR_LEN 5
+#define LS_XO_VERSION "1"
+
extern long blocksize; /* block size units */
extern int f_accesstime; /* use time of last access */
@@ -58,6 +60,7 @@
extern int f_thousands; /* show file sizes with thousands separators */
extern char *f_timeformat; /* user-specified time format */
extern int f_notabs; /* don't use tab-separated multi-col output */
+extern int f_numericonly; /* don't convert uid/gid to name */
extern int f_type; /* add type character for non-regular files */
#ifdef COLORLS
extern int f_color; /* add type in color for non-regular files */
Index: head/bin/ls/ls.c
===================================================================
--- head/bin/ls/ls.c
+++ head/bin/ls/ls.c
@@ -119,7 +119,7 @@
int f_nonprint; /* show unprintables as ? */
static int f_nosort; /* don't sort output */
int f_notabs; /* don't use tab-separated multi-col output */
-static int f_numericonly; /* don't convert uid/gid to name */
+ int f_numericonly; /* don't convert uid/gid to name */
int f_octal; /* show unprintables as \xxx */
int f_octal_escape; /* like f_octal but use C escapes if possible */
static int f_recursive; /* ls subdirectories also */
@@ -195,6 +195,7 @@
if (argc < 0)
return (1);
xo_set_flags(NULL, XOF_COLUMNS);
+ xo_set_version(LS_XO_VERSION);
while ((ch = getopt(argc, argv,
"1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,")) != -1) {
Index: head/bin/ls/print.c
===================================================================
--- head/bin/ls/print.c
+++ head/bin/ls/print.c
@@ -171,7 +171,7 @@
xo_open_list("entry");
for (p = dp->list; p; p = p->fts_link) {
- char *name;
+ char *name, *type;
if (IS_NOPRINT(p))
continue;
xo_open_instance("entry");
@@ -180,22 +180,46 @@
if (name)
xo_emit("{ke:name/%hs}", name);
if (f_inode)
- xo_emit("{:inode/%*ju} ",
+ xo_emit("{t:inode/%*ju} ",
dp->s_inode, (uintmax_t)sp->st_ino);
if (f_size)
- xo_emit("{:blocks/%*jd} ",
+ xo_emit("{t:blocks/%*jd} ",
dp->s_block, howmany(sp->st_blocks, blocksize));
strmode(sp->st_mode, buf);
aclmode(buf, p);
np = p->fts_pointer;
xo_attr("value", "%03o", (int) sp->st_mode & ALLPERMS);
- xo_emit("{t:mode/%s} {:links/%*u} {:user/%-*s} {:group/%-*s} ",
- buf, dp->s_nlink, sp->st_nlink,
- dp->s_user, np->user, dp->s_group, np->group);
+ if (f_numericonly) {
+ xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} {td:user/%-*s}{e:user/%ju} {td:group/%-*s}{e:group/%ju} ",
+ buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, sp->st_nlink,
+ dp->s_user, np->user, sp->st_uid, dp->s_group, np->group, sp->st_gid);
+ } else {
+ xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} {t:user/%-*s} {t:group/%-*s} ",
+ buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, sp->st_nlink,
+ dp->s_user, np->user, dp->s_group, np->group);
+ }
+ if (S_ISBLK(sp->st_mode))
+ asprintf(&type, "block");
+ if (S_ISCHR(sp->st_mode))
+ asprintf(&type, "character");
+ if (S_ISDIR(sp->st_mode))
+ asprintf(&type, "directory");
+ if (S_ISFIFO(sp->st_mode))
+ asprintf(&type, "fifo");
+ if (S_ISLNK(sp->st_mode))
+ asprintf(&type, "symlink");
+ if (S_ISREG(sp->st_mode))
+ asprintf(&type, "regular");
+ if (S_ISSOCK(sp->st_mode))
+ asprintf(&type, "socket");
+ if (S_ISWHT(sp->st_mode))
+ asprintf(&type, "whiteout");
+ xo_emit("{e:type/%s}", type);
+ free(type);
if (f_flags)
xo_emit("{:flags/%-*s} ", dp->s_flags, np->flags);
if (f_label)
- xo_emit("{:label/%-*s} ", dp->s_label, np->label);
+ xo_emit("{t:label/%-*s} ", dp->s_label, np->label);
if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
printdev(dp->s_size, sp->st_rdev);
else
@@ -238,6 +262,7 @@
FTSENT *p;
int chcnt;
+ xo_open_list("entry");
for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
if (p->fts_number == NO_PRINT)
continue;
@@ -247,12 +272,15 @@
xo_emit("\n");
chcnt = 0;
}
+ xo_open_instance("file");
chcnt += printaname(p, dp->s_inode, dp->s_block);
+ xo_close_instance("file");
if (p->fts_link) {
xo_emit(", ");
chcnt += 2;
}
}
+ xo_close_list("entry");
if (chcnt)
xo_emit("\n");
}
@@ -369,10 +397,10 @@
sp = p->fts_statp;
chcnt = 0;
if (f_inode)
- chcnt += xo_emit("{:inode/%*ju} ",
+ chcnt += xo_emit("{t:inode/%*ju} ",
(int)inodefield, (uintmax_t)sp->st_ino);
if (f_size)
- chcnt += xo_emit("{:size/%*jd} ",
+ chcnt += xo_emit("{t:size/%*jd} ",
(int)sizefield, howmany(sp->st_blocks, blocksize));
#ifdef COLORLS
if (f_color)
@@ -425,9 +453,11 @@
format = d_first ? "%e %b %Y" : "%b %e %Y";
strftime(longstring, sizeof(longstring), format, localtime(&ftime));
- snprintf(fmt, sizeof(fmt), "{:%s/%%hs} ", field);
+ snprintf(fmt, sizeof(fmt), "{d:%s/%%hs} ", field);
xo_attr("value", "%ld", (long) ftime);
xo_emit(fmt, longstring);
+ snprintf(fmt, sizeof(fmt), "{en:%s/%%ld} ", field);
+ xo_emit(fmt, (long) ftime);
}
static int
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 10:51 AM (5 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29110380
Default Alt Text
D2854.id7120.diff (5 KB)
Attached To
Mode
D2854: Fix issues with the libxo'ing of /bin/ls
Attached
Detach File
Event Timeline
Log In to Comment