This is similar to mycroftiv's import-z, but uses the -m option (already in use for the same function at another site), which gives the mnemonic "mount-only", instead of -z. More important, it doesn't require an argument that's then ignored, which avoids having to document an ignored argument (which would be unique, I think). Instead, if -m is given, you must not provide the tree (ie, if you do, it's diagnosed). I'd mentioned all this on 9fans, but perhaps the suggestions were missed in the long conversations. There are no patents on this option. Reference: /n/sources/patch/applied/import-m Date: Tue May 7 12:58:51 CES 2013 Signed-off-by: charles.forsyth@gmail.com --- /sys/man/4/import Tue May 7 12:53:02 2013 +++ /sys/man/4/import Tue May 7 12:53:00 2013 @@ -13,6 +13,14 @@ ] .PP .B import +.B -m +[ +.I options +] +.I system +.I mountpoint +.PP +.B import .B -B [ .I options @@ -114,6 +122,27 @@ Post the connection's mountable file descriptor as .BI /srv/ name\fR. .PD +.PP +The +.B -m +option mounts a file exported by +.IR exportfs (4) +with its +.B -r +or +.B -S +options, which skip the part of its protocol that allows the importer to specify +the +.I file +to export. +Instead, the file or name space is selected by +.IR exportfs , +and +.I import +mounts it on +.I mountpoint +as guided by the other +.IR options . .PP The .B -B --- /sys/man/4/exportfs Tue May 7 12:53:06 2013 +++ /sys/man/4/exportfs Tue May 7 12:53:04 2013 @@ -139,17 +139,27 @@ .B -r \fIroot Bypass the initial protocol, serving the name space rooted at .IR root . +A corresponding +.IR import (4) +must use the +.B -m +option. .TP .B -S \fIservice -bypass the initial protocol, serving the result of mounting +Bypass the initial protocol, serving the result of mounting .IR service . A separate mount is used for each .IR attach (5) message, to correctly handle servers in which each mount corresponds to a different client -.IR e.g. , ( +(e.g., .IR rio (4)). +A corresponding +.IR import (4) +must use the +.B -m +option. .TP .B -s equivalent to --- /sys/src/cmd/import.c Tue May 7 12:53:10 2013 +++ /sys/src/cmd/import.c Tue May 7 12:53:07 2013 @@ -92,11 +92,12 @@ main(int argc, char **argv) { char *mntpt, *srvpost, srvfile[64]; - int backwards = 0, fd, mntflags, oldserver; + int backwards = 0, fd, mntflags, oldserver, notree; quotefmtinstall(); srvpost = nil; oldserver = 0; + notree = 0; mntflags = MREPL; ARGBEGIN{ case 'A': @@ -145,6 +146,9 @@ case 'B': backwards = 1; break; + case 'm': + notree = 1; + break; default: usage(); }ARGEND; @@ -164,6 +168,8 @@ mntpt = argv[1]; break; case 3: + if(notree) + usage(); mntpt = argv[2]; break; default: @@ -179,6 +185,8 @@ if(backwards) fd = passive(); + else if(notree) + fd = connect(argv[0], nil, oldserver); else fd = connect(argv[0], argv[1], oldserver); @@ -312,20 +320,22 @@ sysfatal("%r: %s", system); } - procsetname("writing tree name %s", tree); - n = write(fd, tree, strlen(tree)); - if(n < 0) - sysfatal("can't write tree: %r"); - - strcpy(buf, "can't read tree"); - - procsetname("awaiting OK for %s", tree); - n = read(fd, buf, sizeof buf - 1); - if(n!=2 || buf[0]!='O' || buf[1]!='K'){ - if (timedout) - sysfatal("timed out connecting to %s", na); - buf[sizeof buf - 1] = '\0'; - sysfatal("bad remote tree: %s", buf); + if(tree != nil){ + procsetname("writing tree name %s", tree); + n = write(fd, tree, strlen(tree)); + if(n < 0) + sysfatal("can't write tree: %r"); + + strcpy(buf, "can't read tree"); + + procsetname("awaiting OK for %s", tree); + n = read(fd, buf, sizeof buf - 1); + if(n!=2 || buf[0]!='O' || buf[1]!='K'){ + if (timedout) + sysfatal("timed out connecting to %s", na); + buf[sizeof buf - 1] = '\0'; + sysfatal("bad remote tree: %s", buf); + } } if(oldserver) @@ -362,7 +372,7 @@ void usage(void) { - fprint(2, "usage: import [-abcC] [-A] [-E clear|ssl|tls] " + fprint(2, "usage: import [-abcCm] [-A] [-E clear|ssl|tls] " "[-e 'crypt auth'|clear] [-k keypattern] [-p] host remotefs [mountpoint]\n"); exits("usage"); }