]> git.lizzy.rs Git - plan9front.git/commitdiff
exportfs: revert e524e8d65a7573c46d7beb49e77bfc2d55a5563d
authorOri Bernstein <ori@eigenstate.org>
Wed, 18 Aug 2021 14:44:29 +0000 (14:44 +0000)
committerOri Bernstein <ori@eigenstate.org>
Wed, 18 Aug 2021 14:44:29 +0000 (14:44 +0000)
It turns out that the '-f' flag was being used, and removing
it broke things.

sys/man/4/exportfs
sys/src/cmd/exportfs/exportfs.c
sys/src/cmd/exportfs/exportfs.h
sys/src/cmd/exportfs/exportsrv.c
sys/src/cmd/exportfs/io.c
sys/src/cmd/exportfs/oexportfs.c
sys/src/cmd/exportfs/pattern.c

index bf26b641bd0fdd43310ee9d404f9e6cbc2cf25cd..b6108c1ab0ab8a2d3818e6b072ef3c144ce051a0 100644 (file)
@@ -4,23 +4,7 @@ exportfs, srvfs \- file server plumbing
 .SH SYNOPSIS
 .B exportfs
 [
-.B -dsR
-]
-[
-.B -m
-.I msize
-]
-[
-.B -r
-.I root
-]
-[
-.B -P
-.I patternfile
-]
-[
-.B -S
-.I srvfile
+.I options
 ]
 .PP
 .B srvfs
@@ -55,8 +39,11 @@ into a local file tree.
 .PP
 The options are:
 .TP
-.B -d
-Log all 9P traffic to stderr.
+.B -d -f \fIdbgfile
+Log all 9P traffic to
+.I dbgfile
+(default
+.BR /tmp/exportdb ).
 .TP
 .B -P \fIpatternfile
 Restrict the set of exported files.
index 86680e1f602016dc7d049a76cc283573b4359816..b17cec499a83136420d1bd9426331db6253bdc90 100644 (file)
@@ -10,16 +10,18 @@ int readonly;
 void
 usage(void)
 {
-       fprint(2, "usage: %s [-dsR] [-m msize] [-r root] "
-               "[-P patternfile] [-S srvfile]\n", argv0);
+       fprint(2, "usage: %s [-dsR] [-f dbgfile] [-m msize] [-r root] "
+               "[-S srvfile] [-P exclusion-file]\n", argv0);
        fatal("usage");
 }
 
 void
 main(int argc, char **argv)
 {
-       char *srv, *srvfdfile;
+       char *dbfile, *srv, *srvfdfile;
+       int n;
 
+       dbfile = "/tmp/exportdb";
        srv = nil;
        srvfd = -1;
        srvfdfile = nil;
@@ -29,6 +31,10 @@ main(int argc, char **argv)
                dbg++;
                break;
 
+       case 'f':
+               dbfile = EARGF(usage());
+               break;
+
        case 'm':
                messagesize = strtoul(EARGF(usage()), nil, 0);
                break;
@@ -76,7 +82,13 @@ main(int argc, char **argv)
 
        exclusions();
 
-       DEBUG(2, "exportfs: started\n");
+       if(dbg) {
+               n = create(dbfile, OWRITE|OTRUNC, 0666);
+               dup(n, DFD);
+               close(n);
+       }
+
+       DEBUG(DFD, "exportfs: started\n");
 
        rfork(RFNOTEG|RFREND);
 
@@ -94,13 +106,13 @@ main(int argc, char **argv)
                        char ebuf[ERRMAX];
                        ebuf[0] = '\0';
                        errstr(ebuf, sizeof ebuf);
-                       DEBUG(2, "chdir(\"%s\"): %s\n", srv, ebuf);
+                       DEBUG(DFD, "chdir(\"%s\"): %s\n", srv, ebuf);
                        mounterror(ebuf);
                }
-               DEBUG(2, "invoked as server for %s", srv);
+               DEBUG(DFD, "invoked as server for %s", srv);
        }
 
-       DEBUG(2, "\niniting root\n");
+       DEBUG(DFD, "\niniting root\n");
        initroot();
        io();
 }
index 6723620cde91994bb4f9aeb1bdb5af2e4cec99e6..344304b7cf82d3e6ede8235f438f1f920f41a12a 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #define DEBUG          if(!dbg){}else fprint
+#define DFD            9
 #define fidhash(s)     fhash[s%FHASHSIZE]
 
 typedef struct Fsrpc Fsrpc;
index 3bd9e3aeb3c679359e28fc03628324b81374ee4d..b7ddd64b575139cb6c6e20ac9e3ed204d7efc155 100644 (file)
@@ -65,7 +65,7 @@ Xflush(Fsrpc *t)
                w = m->busy;
                if(w != nil && w->work.tag == t->work.oldtag) {
                        w->flushtag = t->work.tag;
-                       DEBUG(2, "\tset flushtag %d\n", t->work.tag);
+                       DEBUG(DFD, "\tset flushtag %d\n", t->work.tag);
                        postnote(PNPROC, m->pid, "flush");
                        unlock(m);
                        putsbuf(t);
@@ -75,7 +75,7 @@ Xflush(Fsrpc *t)
        }
 
        reply(&t->work, &rhdr, 0);
-       DEBUG(2, "\tflush reply\n");
+       DEBUG(DFD, "\tflush reply\n");
        putsbuf(t);
 }
 
@@ -359,7 +359,7 @@ Xremove(Fsrpc *t)
        }
 
        path = makepath(f->f, "");
-       DEBUG(2, "\tremove: %s\n", path);
+       DEBUG(DFD, "\tremove: %s\n", path);
        if(remove(path) < 0) {
                free(path);
                errstr(err, sizeof err);
@@ -518,7 +518,7 @@ blockingslave(Proc *m)
                if(p == nil)            /* Swept */
                        break;
 
-               DEBUG(2, "\tslave: %d %F\n", m->pid, &p->work);
+               DEBUG(DFD, "\tslave: %d %F\n", m->pid, &p->work);
                if(p->flushtag != NOTAG)
                        goto flushme;
 
@@ -629,7 +629,7 @@ slaveopen(Fsrpc *p)
        }
        
        path = makepath(f->f, "");
-       DEBUG(2, "\topen: %s %d\n", path, work->mode);
+       DEBUG(DFD, "\topen: %s %d\n", path, work->mode);
        f->fid = open(path, work->mode);
        free(path);
        if(f->fid < 0 || (d = dirfstat(f->fid)) == nil) {
@@ -646,7 +646,7 @@ slaveopen(Fsrpc *p)
                        goto Error;
        }
 
-       DEBUG(2, "\topen: fd %d\n", f->fid);
+       DEBUG(DFD, "\topen: fd %d\n", f->fid);
        f->mode = work->mode;
        f->offset = 0;
        rhdr.iounit = getiounit(f->fid);
@@ -688,7 +688,7 @@ slaveread(Fsrpc *p)
                reply(work, &rhdr, err);
                return;
        }
-       DEBUG(2, "\tread: fd=%d %d bytes\n", f->fid, r);
+       DEBUG(DFD, "\tread: fd=%d %d bytes\n", f->fid, r);
 
        rhdr.data = data;
        rhdr.count = r;
@@ -720,7 +720,7 @@ slavewrite(Fsrpc *p)
                return;
        }
 
-       DEBUG(2, "\twrite: %d bytes fd=%d\n", n, f->fid);
+       DEBUG(DFD, "\twrite: %d bytes fd=%d\n", n, f->fid);
 
        rhdr.count = n;
        reply(work, &rhdr, 0);
index 2309168a84f5575b8ae8efc51e44a8064e2c623c..ad1d7154b782d596510db15e4e79db1e76b3cbdd 100644 (file)
@@ -49,7 +49,7 @@ io(void)
                if(convM2S(r->buf, n, &r->work) != n)
                        fatal("convM2S format error");
 
-               DEBUG(2, "%F\n", &r->work);
+               DEBUG(DFD, "%F\n", &r->work);
                (fcalls[r->work.type])(r);
        }
 }
@@ -69,7 +69,7 @@ reply(Fcall *r, Fcall *t, char *err)
        else 
                t->type = r->type + 1;
 
-       DEBUG(2, "\t%F\n", t);
+       DEBUG(DFD, "\t%F\n", t);
 
        data = malloc(messagesize);     /* not mallocz; no need to clear */
        if(data == nil)
@@ -224,7 +224,7 @@ freefile(File *f)
 
        while(--f->ref == 0){
                freecnt++;
-               DEBUG(2, "free %s\n", f->name);
+               DEBUG(DFD, "free %s\n", f->name);
                /* delete from parent */
                parent = f->parent;
                if(parent->child == f)
@@ -250,7 +250,7 @@ file(File *parent, char *name)
        char *path;
        File *f;
 
-       DEBUG(2, "\tfile: 0x%p %s name %s\n", parent, parent->name, name);
+       DEBUG(DFD, "\tfile: 0x%p %s name %s\n", parent, parent->name, name);
 
        path = makepath(parent, name);
        if(patternfile != nil && excludefile(path)){
@@ -429,17 +429,17 @@ uniqueqid(Dir *d)
        }
        path = d->qid.path;
        while(qidexists(path)){
-               DEBUG(2, "collision on %s\n", d->name);
+               DEBUG(DFD, "collision on %s\n", d->name);
                /* collision: find a new one */
                ncollision++;
                path &= QIDPATH;
                ++newqid;
                if(newqid >= (1<<16)){
-                       DEBUG(2, "collision wraparound\n");
+                       DEBUG(DFD, "collision wraparound\n");
                        newqid = 1;
                }
                path |= newqid<<48;
-               DEBUG(2, "assign qid %.16llux\n", path);
+               DEBUG(DFD, "assign qid %.16llux\n", path);
        }
        qidcnt++;
        q = emallocz(sizeof(Qidtab));
@@ -472,7 +472,7 @@ fatal(char *s, ...)
                postnote(PNPROC, m->pid, "kill");
 
        if(s != nil) {
-               DEBUG(2, "%s\n", buf);
+               DEBUG(DFD, "%s\n", buf);
                sysfatal("%s", buf);    /* caution: buf could contain '%' */
        } else
                exits(nil);
index e9fa819c7fa32c5e0acf389dccc842f933f3fd1b..c6683a1745170530bbb594473d92858282991d77 100644 (file)
@@ -59,7 +59,7 @@ filter(int fd, char *cmd, char *host)
                strecpy(strrchr(addr, '!'), addr+sizeof(addr), s);
        }
 
-       DEBUG(2, "filter: %s\n", addr);
+       DEBUG(DFD, "filter: %s\n", addr);
 
        snprint(buf, sizeof(buf), "%s", cmd);
        argc = tokenize(buf, argv, nelem(argv)-3);
@@ -256,7 +256,7 @@ main(int argc, char **argv)
 
        if(dbg) {
                n = create(dbfile, OWRITE|OTRUNC, 0666);
-               dup(n, 2);
+               dup(n, DFD);
                close(n);
        }
 
@@ -265,7 +265,7 @@ main(int argc, char **argv)
                usage();
        }
 
-       DEBUG(2, "%s: started\n", argv0);
+       DEBUG(DFD, "%s: started\n", argv0);
 
        rfork(RFNOTEG|RFREND);
 
@@ -289,10 +289,10 @@ main(int argc, char **argv)
                if(chdir(srv) < 0) {
                        ebuf[0] = '\0';
                        errstr(ebuf, sizeof ebuf);
-                       DEBUG(2, "chdir(\"%s\"): %s\n", srv, ebuf);
+                       DEBUG(DFD, "chdir(\"%s\"): %s\n", srv, ebuf);
                        mounterror(ebuf);
                }
-               DEBUG(2, "invoked as server for %s", srv);
+               DEBUG(DFD, "invoked as server for %s", srv);
                strncpy(buf, srv, sizeof buf);
        }
        else {
@@ -301,22 +301,22 @@ main(int argc, char **argv)
                if(n < 0) {
                        errstr(buf, sizeof buf);
                        fprint(0, "read(0): %s\n", buf);
-                       DEBUG(2, "read(0): %s\n", buf);
+                       DEBUG(DFD, "read(0): %s\n", buf);
                        exits(buf);
                }
                buf[n] = 0;
                if(chdir(buf) < 0) {
                        errstr(ebuf, sizeof ebuf);
                        fprint(0, "chdir(%d:\"%s\"): %s\n", n, buf, ebuf);
-                       DEBUG(2, "chdir(%d:\"%s\"): %s\n", n, buf, ebuf);
+                       DEBUG(DFD, "chdir(%d:\"%s\"): %s\n", n, buf, ebuf);
                        exits(ebuf);
                }
        }
 
-       DEBUG(2, "\niniting root\n");
+       DEBUG(DFD, "\niniting root\n");
        initroot();
 
-       DEBUG(2, "%s: %s\n", argv0, buf);
+       DEBUG(DFD, "%s: %s\n", argv0, buf);
 
        if(srv == nil && srvfd == -1 && write(0, "OK", 2) != 2)
                fatal("open ack write");
@@ -436,7 +436,7 @@ main(int argc, char **argv)
 
                if(convM2S(r->buf, n, &r->work) != n)
                        fatal("convM2S format error");
-               DEBUG(2, "%F\n", &r->work);
+               DEBUG(DFD, "%F\n", &r->work);
                (fcalls[r->work.type])(r);
        }
        io();
index f014a981243fbf724bb44c2e8a8f35b3d3162d9c..4dfed5bca67855914709f67cef963c9cc3ea8a0d 100644 (file)
@@ -42,7 +42,7 @@ exclusions(void)
                                if(include == nil)
                                        fatal("out of memory");
                        }
-                       DEBUG(2, "\tinclude %s\n", line+2);
+                       DEBUG(DFD, "\tinclude %s\n", line+2);
                        include[ni] = regcomp(line+2);
                        include[++ni] = nil;
                        break;
@@ -53,12 +53,12 @@ exclusions(void)
                                if(exclude == nil)
                                        fatal("out of memory");
                        }
-                       DEBUG(2, "\texclude %s\n", line+2);
+                       DEBUG(DFD, "\texclude %s\n", line+2);
                        exclude[ne] = regcomp(line+2);
                        exclude[++ne] = nil;
                        break;
                default:
-                       DEBUG(2, "ignoring pattern %s\n", line);
+                       DEBUG(DFD, "ignoring pattern %s\n", line);
                        break;
                }
        }
@@ -76,16 +76,16 @@ excludefile(char *path)
        else
                p = path+1;
 
-       DEBUG(2, "checking %s\n", p);
+       DEBUG(DFD, "checking %s\n", p);
        for(re = include; *re != nil; re++){
                if(regexec(*re, p, nil, 0) != 1){
-                       DEBUG(2, "excluded+ %s\n", p);
+                       DEBUG(DFD, "excluded+ %s\n", p);
                        return -1;
                }
        }
        for(re = exclude; *re != nil; re++){
                if(regexec(*re, p, nil, 0) == 1){
-                       DEBUG(2, "excluded- %s\n", p);
+                       DEBUG(DFD, "excluded- %s\n", p);
                        return -1;
                }
        }
@@ -98,7 +98,7 @@ preaddir(Fid *f, uchar *data, int n, vlong offset)
        int r = 0, m;
        Dir *d;
 
-       DEBUG(2, "\tpreaddir n=%d wo=%lld fo=%lld\n", n, offset, f->offset);
+       DEBUG(DFD, "\tpreaddir n=%d wo=%lld fo=%lld\n", n, offset, f->offset);
        if(offset == 0 && f->offset != 0){
                if(seek(f->fid, 0, 0) != 0)
                        return -1;
@@ -128,9 +128,9 @@ preaddir(Fid *f, uchar *data, int n, vlong offset)
                        free(p);
                }
                m = convD2M(d, data, n);
-               DEBUG(2, "\t\tconvD2M %d\n", m);
+               DEBUG(DFD, "\t\tconvD2M %d\n", m);
                if(m <= BIT16SZ){
-                       DEBUG(2, "\t\t\tneeded %d\n", GBIT16(data));
+                       DEBUG(DFD, "\t\t\tneeded %d\n", GBIT16(data));
                        /* not enough room for full entry; leave for next time */
                        f->cdir--;
                        return r;