From: Stephen Gregoratto <dev@sgregoratto.me>
To: 9front@9front.org
Subject: [9front] walk: properly format permissions
Date: Sun, 4 Apr 2021 10:34:41 +1000 [thread overview]
Message-ID: <20210404003441.lutl2xy7avmlduga@BlackBox> (raw)
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.
diff -r 4dfbef4fa4ac sys/man/1/walk
--- a/sys/man/1/walk Sat Apr 03 19:32:47 2021 +0200
+++ b/sys/man/1/walk Sun Apr 04 10:25:44 2021 +1000
@@ -123,8 +123,6 @@
.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 -r 4dfbef4fa4ac sys/src/cmd/walk.c
--- a/sys/src/cmd/walk.c Sat Apr 03 19:32:47 2021 +0200
+++ b/sys/src/cmd/walk.c Sun Apr 04 10:25:44 2021 +1000
@@ -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 @@
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 @@
usage();
}ARGEND;
+ fmtinstall('M', dirmodefmt);
+
if((bout = Bfdopen(1, OWRITE)) == nil)
sysfatal("Bfdopen: %r");
Blethal(bout, nil);
--
Stephen Gregoratto
next reply other threads:[~2021-04-04 19:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-04 0:34 Stephen Gregoratto [this message]
2021-04-06 16:00 ` Sigrid Solveig Haflínudóttir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210404003441.lutl2xy7avmlduga@BlackBox \
--to=dev@sgregoratto.me \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).