This commit is contained in:
rsc 2005-03-21 17:27:25 +00:00
parent 5c84c448b8
commit 011090f03b
2 changed files with 46 additions and 14 deletions

View file

@ -4,24 +4,21 @@
.SH SYNOPSIS .SH SYNOPSIS
.B 9p .B 9p
[ [
.B -a .I options
.I addr
] ]
.B read .B read
.I path .I path
.br .br
.B 9p .B 9p
[ [
.B -a .I options
.I addr
] ]
.B readfd .B readfd
.I path .I path
.PP .PP
.B 9p .B 9p
[ [
.B -a .I options
.I addr
] ]
.B write .B write
[ [
@ -31,28 +28,49 @@
.br .br
.B 9p .B 9p
[ [
.B -a .I options
.I addr
] ]
.B writefd .B writefd
.I path .I path
.PP .PP
.B 9p .B 9p
[ [
.B -a .I options
.I addr
] ]
.B stat .B stat
.I path .I path
.PP .PP
.B 9p .B 9p
[
.I options
]
.B rdwr .B rdwr
.I path .I path
.PP
.B 9p
[
.I options
]
.B ls
[
.B -dl
]
.I path...
.SH DESCRIPTION .SH DESCRIPTION
.I 9p .I 9p
is a trivial 9P client that can access a single file on a 9P server. is a trivial 9P client that can access a single file on a 9P server.
It can be useful for manual interaction with a 9P server or for It can be useful for manual interaction with a 9P server or for
accessing simple 9P services from within shell scripts. accessing simple 9P services from within shell scripts.
The common options are:
.TP
.B -a\fI addr
dial
the server at
.I addr
.TP
.B -A\fI aname
attach to the file system named
.I aname
.PP .PP
The first argument is a command, one of: The first argument is a command, one of:
.TP .TP
@ -101,6 +119,16 @@ Print errors, but don't give up.
.B Rdwr .B Rdwr
is useful for interacting with servers like is useful for interacting with servers like
.IR factotum (4). .IR factotum (4).
.TP
.B ls
Print a directory listing in the format of
.IR ls (1).
The
.B -d
and
.B -l
flags have the same meaning as in
.IR ls .
.PD .PD
.PP .PP
.I 9p .I 9p

View file

@ -12,7 +12,7 @@ char *addr;
void void
usage(void) usage(void)
{ {
fprint(2, "usage: 9p [-a address] cmd args...\n"); fprint(2, "usage: 9p [-a address] [-A aname] cmd args...\n");
fprint(2, "possible cmds:\n"); fprint(2, "possible cmds:\n");
fprint(2, " read name\n"); fprint(2, " read name\n");
fprint(2, " readfd name\n"); fprint(2, " readfd name\n");
@ -25,6 +25,7 @@ usage(void)
threadexitsall("usage"); threadexitsall("usage");
} }
char *aname;
void xread(int, char**); void xread(int, char**);
void xwrite(int, char**); void xwrite(int, char**);
void xreadfd(int, char**); void xreadfd(int, char**);
@ -53,6 +54,9 @@ threadmain(int argc, char **argv)
int i; int i;
ARGBEGIN{ ARGBEGIN{
case 'A':
aname = EARGF(usage());
break;
case 'a': case 'a':
addr = EARGF(usage()); addr = EARGF(usage());
if(strchr(addr, '!') == nil) if(strchr(addr, '!') == nil)
@ -94,15 +98,15 @@ xparse(char *name, char **path)
else else
*p++ = 0; *p++ = 0;
*path = p; *path = p;
fs = nsamount(name, ""); fs = nsamount(name, aname);
if(fs == nil) if(fs == nil)
sysfatal("mount: %r"); sysfatal("mount: %r");
}else{ }else{
*path = name; *path = name;
if((fd = dial(addr, nil, nil, nil)) < 0) if((fd = dial(addr, nil, nil, nil)) < 0)
sysfatal("dial: %r"); sysfatal("dial: %r");
if((fs = fsamount(fd, "")) == nil) if((fs = fsamount(fd, aname)) == nil)
sysfatal("fsmount: %r"); sysfatal("fsamount: %r");
} }
return fs; return fs;
} }