tftpfs: add manpage, add -x option
This commit is contained in:
parent
5baafe7307
commit
61d1967e74
2 changed files with 87 additions and 11 deletions
73
sys/man/4/tftpfs
Normal file
73
sys/man/4/tftpfs
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
.TH TFTPFS 4
|
||||||
|
.SH NAME
|
||||||
|
tftpfs \- trivial file transfer protocol (TFTP) file system
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B ip/tftpfs
|
||||||
|
[
|
||||||
|
.B -D
|
||||||
|
] [
|
||||||
|
.B -s
|
||||||
|
.I srvname
|
||||||
|
] [
|
||||||
|
.B -m
|
||||||
|
.I mtpt
|
||||||
|
] [
|
||||||
|
.B -x
|
||||||
|
.I net
|
||||||
|
] [
|
||||||
|
.I ipaddr
|
||||||
|
]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.I Tftpfs
|
||||||
|
serves files from a TFTP server as a filesystem. TFTP
|
||||||
|
is mostly used by bootloaders to download kernel images for
|
||||||
|
network bootstrap (see
|
||||||
|
.IR dhcp (8)).
|
||||||
|
As the protocol has no way of distinguishing files from
|
||||||
|
directories the final path segment needs to conain a dot
|
||||||
|
(.) character to be recognized as a file. To access files that
|
||||||
|
have no dot in the filename, a trailing dot has to be added
|
||||||
|
and will be striped before it is passed to the server.
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.B -D
|
||||||
|
option enables 9P debugging messages.
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.B -s
|
||||||
|
option causes
|
||||||
|
.I tftpfs
|
||||||
|
to post the 9P service as
|
||||||
|
.BI /srv/ srvname
|
||||||
|
and disables the default mount.
|
||||||
|
.PP
|
||||||
|
The default mountpoint
|
||||||
|
.BR /n/tftp
|
||||||
|
can be changed with the
|
||||||
|
.B -B
|
||||||
|
.I mtpt
|
||||||
|
option.
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.B -x
|
||||||
|
option specifies an alternate network directory
|
||||||
|
.RI ( e.g.,
|
||||||
|
.BR /net.alt ).
|
||||||
|
.PP
|
||||||
|
The ip address of the server can be passed in
|
||||||
|
.I ipaddr
|
||||||
|
as the last program argument or in the mount spec (see
|
||||||
|
.IR bind (1))
|
||||||
|
on a per mount basis.
|
||||||
|
.SH EXAMPLE
|
||||||
|
Boot a kernel from a tftp server. (note the final
|
||||||
|
dot in the kernel path).
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
ip/tftpd 10.192.254.53
|
||||||
|
echo reboot /n/tftp/386/9pcf. >/dev/reboot
|
||||||
|
.EE
|
||||||
|
.SH SOURCE
|
||||||
|
.B /sys/src/cmd/ip/tftpfs.c
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.IR dhcpd (8).
|
|
@ -16,7 +16,7 @@ enum {
|
||||||
Tftp_ERROR = 5,
|
Tftp_ERROR = 5,
|
||||||
Tftp_OACK = 6,
|
Tftp_OACK = 6,
|
||||||
|
|
||||||
TftpPort = 69,
|
TftpPort = 69,
|
||||||
|
|
||||||
Segsize = 512,
|
Segsize = 512,
|
||||||
Maxpath = 2+2+Segsize-8,
|
Maxpath = 2+2+Segsize-8,
|
||||||
|
@ -25,19 +25,19 @@ enum {
|
||||||
typedef struct Tfile Tfile;
|
typedef struct Tfile Tfile;
|
||||||
struct Tfile
|
struct Tfile
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
uchar addr[IPaddrlen];
|
uchar addr[IPaddrlen];
|
||||||
char path[Maxpath];
|
char path[Maxpath];
|
||||||
Channel *c;
|
Channel *c;
|
||||||
Tfile *next;
|
Tfile *next;
|
||||||
Ref;
|
Ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char net[Maxpath];
|
||||||
uchar ipaddr[IPaddrlen];
|
uchar ipaddr[IPaddrlen];
|
||||||
static ulong time0;
|
static ulong time0;
|
||||||
Tfile *files;
|
Tfile *files;
|
||||||
|
|
||||||
|
|
||||||
static Tfile*
|
static Tfile*
|
||||||
tfileget(uchar *addr, char *path)
|
tfileget(uchar *addr, char *path)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ static void
|
||||||
download(void *aux)
|
download(void *aux)
|
||||||
{
|
{
|
||||||
int fd, cfd, last, block, seq, n, ndata;
|
int fd, cfd, last, block, seq, n, ndata;
|
||||||
char *err, adir[40];
|
char *err, adir[40], buf[256];
|
||||||
uchar *data;
|
uchar *data;
|
||||||
Channel *c;
|
Channel *c;
|
||||||
Tfile *f;
|
Tfile *f;
|
||||||
|
@ -173,7 +173,8 @@ download(void *aux)
|
||||||
|
|
||||||
threadsetname(f->path);
|
threadsetname(f->path);
|
||||||
|
|
||||||
if((cfd = announce("udp!*!0", adir)) < 0){
|
snprint(buf, sizeof(buf), "%s/udp!*!0", net);
|
||||||
|
if((cfd = announce(buf, adir)) < 0){
|
||||||
err = "announce: %r";
|
err = "announce: %r";
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -264,8 +265,6 @@ out:
|
||||||
if(c){
|
if(c){
|
||||||
while((r != nil) || (r = recvp(c))){
|
while((r != nil) || (r = recvp(c))){
|
||||||
if(err){
|
if(err){
|
||||||
char buf[ERRMAX];
|
|
||||||
|
|
||||||
snprint(buf, sizeof(buf), err);
|
snprint(buf, sizeof(buf), err);
|
||||||
respond(r, buf);
|
respond(r, buf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -412,7 +411,7 @@ fsstat(Req *r)
|
||||||
|
|
||||||
Srv fs =
|
Srv fs =
|
||||||
{
|
{
|
||||||
.attach= fsattach,
|
.attach= fsattach,
|
||||||
.destroyfid= fsdestroyfid,
|
.destroyfid= fsdestroyfid,
|
||||||
.walk1= fswalk1,
|
.walk1= fswalk1,
|
||||||
.clone= fsclone,
|
.clone= fsclone,
|
||||||
|
@ -424,7 +423,7 @@ Srv fs =
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: tftpfs [-D] [-s srvname] [-m mtpt] [ipaddr]\n");
|
fprint(2, "usage: tftpfs [-D] [-s srvname] [-m mtpt] [-x net] [ipaddr]\n");
|
||||||
threadexitsall("usage");
|
threadexitsall("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,6 +434,7 @@ threadmain(int argc, char **argv)
|
||||||
char *mtpt = "/n/tftp";
|
char *mtpt = "/n/tftp";
|
||||||
|
|
||||||
time0 = time(0);
|
time0 = time(0);
|
||||||
|
strcpy(net, "/net");
|
||||||
ipmove(ipaddr, IPnoaddr);
|
ipmove(ipaddr, IPnoaddr);
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
@ -448,6 +448,9 @@ threadmain(int argc, char **argv)
|
||||||
case 'm':
|
case 'm':
|
||||||
mtpt = EARGF(usage());
|
mtpt = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
setnetmtpt(net, sizeof net, EARGF(usage()));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue