Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143752381
D2854.id7118.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D2854.id7118.diff
View Options
Index: bin/ls/ls.h
===================================================================
--- bin/ls/ls.h
+++ 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 */
Index: bin/ls/ls.c
===================================================================
--- bin/ls/ls.c
+++ bin/ls/ls.c
@@ -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: bin/ls/print.c
===================================================================
--- bin/ls/print.c
+++ 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, Feb 1, 11:05 AM (2 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28349500
Default Alt Text
D2854.id7118.diff (4 KB)
Attached To
Mode
D2854: Fix issues with the libxo'ing of /bin/ls
Attached
Detach File
Event Timeline
Log In to Comment