[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.
front
Stephen Gregoratto 2021-04-06 14:43:38 +02:00
parent d41c867696
commit 4c981d440d
2 changed files with 4 additions and 3 deletions

View File

@ -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.

View File

@ -2,6 +2,7 @@
#include <libc.h>
#include <bio.h>
#include <String.h>
#include <fcall.h>
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);