summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-12-15 00:52:22 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-12-15 00:52:22 +0100
commit5c1803e1adc869ef6781eb65d2ee08b30326aee1 (patch)
treea8e4dde9df820033b52329a8e9923d9bdde8784a
parent2e94406e7f66b0c5f4e2b1d5c2158a37e8677724 (diff)
disk/mkfs: add -o flag to list source files
-rw-r--r--sys/man/8/mkfs8
-rw-r--r--sys/src/cmd/disk/mkfs.c21
2 files changed, 25 insertions, 4 deletions
diff --git a/sys/man/8/mkfs b/sys/man/8/mkfs
index 6a37d61c7..99c37b6dd 100644
--- a/sys/man/8/mkfs
+++ b/sys/man/8/mkfs
@@ -3,7 +3,7 @@
mkfs, mkext \- archive or update a file system
.SH SYNOPSIS
.B disk/mkfs
-.RB [ -aprvxU ]
+.RB [ -aprvoxU ]
.RB [ -d
.IR root ]
.RB [ -n
@@ -84,6 +84,12 @@ For use with
this option writes a list of file names, dates, and sizes to standard output
rather than producing an archive file.
.TP
+.B o
+Similar to
+.BR -x
+above, but produces a list of source file names to standard output
+rather than producing an archive file.
+.TP
.BI "d " root
Copy files into the tree rooted at
.I root
diff --git a/sys/src/cmd/disk/mkfs.c b/sys/src/cmd/disk/mkfs.c
index 6a19a8e6b..d0c893aa7 100644
--- a/sys/src/cmd/disk/mkfs.c
+++ b/sys/src/cmd/disk/mkfs.c
@@ -46,6 +46,7 @@ int modes;
int ream;
int debug;
int xflag;
+int oflag;
int sfd;
int fskind; /* Kfs, Fs, Archive */
int setuid; /* on Fs: set uid and gid? */
@@ -106,6 +107,9 @@ main(int argc, char **argv)
case 'v':
verb = 1;
break;
+ case 'o':
+ oflag = 1;
+ break;
case 'x':
xflag = 1;
break;
@@ -116,8 +120,13 @@ main(int argc, char **argv)
usage();
}ARGEND
- if(!argc)
+ if(!argc)
+ usage();
+
+ if((xflag || oflag) && fskind != Archive){
+ fprint(2, "cannot use -x and -o without -a\n");
usage();
+ }
buf = malloc(buflen);
zbuf = malloc(buflen);
@@ -145,7 +154,8 @@ main(int argc, char **argv)
if(errs)
exits("skipped protos");
if(fskind == Archive){
- Bprint(&bout, "end of archive\n");
+ if(!xflag && !oflag)
+ Bprint(&bout, "end of archive\n");
Bterm(&bout);
}
exits(0);
@@ -319,6 +329,11 @@ protoenum(char *new, char *old, Dir *d, void *)
sprint(newfile, "%s%s", newroot, new);
sprint(oldfile, "%s", old);
+ if(oflag){
+ if(!(d->mode & DMDIR))
+ Bprint(&bout, "%q\n", cleanname(oldfile));
+ return;
+ }
if(xflag){
Bprint(&bout, "%q\t%ld\t%lld\n", new, d->mtime, d->length);
return;
@@ -438,6 +453,6 @@ warn(char *fmt, ...)
void
usage(void)
{
- fprint(2, "usage: %q [-adprvxUD] [-d root] [-n name] [-s source] [-u users] [-z n] proto ...\n", prog);
+ fprint(2, "usage: %q [-adprvoxUD] [-d root] [-n name] [-s source] [-u users] [-z n] proto ...\n", prog);
exits("usage");
}