for(p = s_to_c(stfmt); *p != '\0'; p++){
switch(*p){
case 'U': Bwrite(bout, f->uid, strlen(f->uid)); break;
case 'G': Bwrite(bout, f->gid, strlen(f->gid)); break;
case 'M': Bwrite(bout, f->muid, strlen(f->muid)); break;
case 'a': Bprint(bout, "%uld", f->atime); break;
case 'm': Bprint(bout, "%uld", f->mtime); break;
case 'n': Bwrite(bout, f->name, strlen(f->name)); break;
case 'p':
if(path != dotpath)
Bwrite(bout, path, strlen(path));
if(! (f->qid.type & QTDIR) && !pathonly){
if(path != dotpath)
Bputc(bout, '/');
Bwrite(bout, f->name, strlen(f->name));
}
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;
/* These two are slightly different, as they tell us about the fileserver instead of the file */
case 'D': Bprint(bout, "%ud", f->dev); break;
case 'T': Bprint(bout, "%C", f->type); break;
default:
abort();
}
if(*(p+1) != '\0')
Bputc(bout, ' ');
}
Bputc(bout, '\n');
if(uflag)
Bflush(bout);
}
void
walk(char *path, Dir *cf, long depth)
{
String *file;
Dir *dirs, *f, *fe;
int fd;
long n;
/*
Last I checked (commit 3dd6a31881535615389c24ab9a139af2798c462c),
libString calls sysfatal when things go wrong; in my local
copy of libString, failed calls return nil and errstr is set.
There are various nil checks in this code when calling libString
functions, but since they are a no-op and libString needs
a rework, I left them in - BurnZeZ
*/
void
main(int argc, char **argv)
{
long i;
Dir *d;
stfmt = nil;
ARGBEGIN{
case 'C': Cflag++; break; /* undocumented; do not cleanname() the args */
case 'u': uflag++; break; /* unbuffered output */
case 'd': dflag++; fflag = 0; break; /* only dirs */
case 'f': fflag++; dflag = 0; break; /* only non-dirs */
case 't': tflag++; break; /* only tmp files */
case 'x': xflag++; break; /* only executable permission */
case 'n': elimdepth(EARGF(usage())); break;
case 'e':
if((stfmt = s_reset(stfmt)) == nil)
sysfatal("s_reset: %r");
s_append(stfmt, EARGF(usage()));
i = strspn(s_to_c(stfmt), "UGMamnpqsxDT");
if(i != s_len(stfmt))
sysfatal("bad stfmt: %s", s_to_c(stfmt));
break;
default:
usage();
}ARGEND;