From 4c981d440d6740e553c90afbe8f682502615b7cb Mon Sep 17 00:00:00 2001 From: Stephen Gregoratto Date: Tue, 6 Apr 2021 14:43:38 +0200 Subject: [9front] walk: properly format permissions This patch adds dirmodefmt from fcall.h to pretty-print file permissions, similarly to ls -l. I didn't notice any performance degradation. I hope no-one relied on the old behaviour. --- sys/man/1/walk | 2 -- sys/src/cmd/walk.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/man/1/walk b/sys/man/1/walk index 7263d32e4..92699e2eb 100644 --- a/sys/man/1/walk +++ b/sys/man/1/walk @@ -123,8 +123,6 @@ walk -fn1 -esp .IR ls (1), .IR du (1) .SH BUGS -Statfmt character `x' displays permissions as an integer. -.PP Manipulating ifs is a nuisance. .PP File names are assumed to not contain newlines. diff --git a/sys/src/cmd/walk.c b/sys/src/cmd/walk.c index cd83acca7..ec7636983 100644 --- a/sys/src/cmd/walk.c +++ b/sys/src/cmd/walk.c @@ -2,6 +2,7 @@ #include #include #include +#include int Cflag = 0; int uflag = 0; @@ -70,7 +71,7 @@ dofile(char *path, Dir *f, int pathonly) break; case 'q': Bprint(bout, "%ullx.%uld.%.2uhhx", f->qid.path, f->qid.vers, f->qid.type); break; case 's': Bprint(bout, "%lld", f->length); break; - case 'x': Bprint(bout, "%ulo", f->mode); break; + case 'x': Bprint(bout, "%M", f->mode); break; /* These two are slightly different, as they tell us about the fileserver instead of the file */ case 'D': Bprint(bout, "%ud", f->dev); break; @@ -250,6 +251,8 @@ main(int argc, char **argv) usage(); }ARGEND; + fmtinstall('M', dirmodefmt); + if((bout = Bfdopen(1, OWRITE)) == nil) sysfatal("Bfdopen: %r"); Blethal(bout, nil); -- cgit v1.2.3