disk/mkfs: add -o flag to list source files

This commit is contained in:
cinap_lenrek 2014-12-15 00:52:22 +01:00
parent 2e94406e7f
commit 5c1803e1ad
2 changed files with 25 additions and 4 deletions

View file

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

View file

@ -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,9 +120,14 @@ 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);
memset(zbuf, 0, 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");
}