diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-10-06 04:14:48 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-10-06 04:14:48 +0200 |
commit | 61d1967e74a3796af55bc14ee81599696b86f3bb (patch) | |
tree | 6d28f65b9ea02d4682204b1cd2d149d1f1b68a37 /sys | |
parent | 5baafe7307f1c8a0a9026f2091312b9100708c59 (diff) |
tftpfs: add manpage, add -x option
Diffstat (limited to 'sys')
-rw-r--r-- | sys/man/4/tftpfs | 73 | ||||
-rw-r--r-- | sys/src/cmd/ip/tftpfs.c | 25 |
2 files changed, 87 insertions, 11 deletions
diff --git a/sys/man/4/tftpfs b/sys/man/4/tftpfs new file mode 100644 index 000000000..9aa9822b1 --- /dev/null +++ b/sys/man/4/tftpfs @@ -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). diff --git a/sys/src/cmd/ip/tftpfs.c b/sys/src/cmd/ip/tftpfs.c index 55d8f496d..2b5aac59e 100644 --- a/sys/src/cmd/ip/tftpfs.c +++ b/sys/src/cmd/ip/tftpfs.c @@ -16,7 +16,7 @@ enum { Tftp_ERROR = 5, Tftp_OACK = 6, - TftpPort = 69, + TftpPort = 69, Segsize = 512, Maxpath = 2+2+Segsize-8, @@ -25,19 +25,19 @@ enum { typedef struct Tfile Tfile; struct Tfile { - int id; + int id; uchar addr[IPaddrlen]; - char path[Maxpath]; + char path[Maxpath]; Channel *c; - Tfile *next; + Tfile *next; Ref; }; +char net[Maxpath]; uchar ipaddr[IPaddrlen]; static ulong time0; Tfile *files; - static Tfile* tfileget(uchar *addr, char *path) { @@ -148,7 +148,7 @@ static void download(void *aux) { int fd, cfd, last, block, seq, n, ndata; - char *err, adir[40]; + char *err, adir[40], buf[256]; uchar *data; Channel *c; Tfile *f; @@ -173,7 +173,8 @@ download(void *aux) 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"; goto out; } @@ -264,8 +265,6 @@ out: if(c){ while((r != nil) || (r = recvp(c))){ if(err){ - char buf[ERRMAX]; - snprint(buf, sizeof(buf), err); respond(r, buf); } else { @@ -412,7 +411,7 @@ fsstat(Req *r) Srv fs = { -.attach= fsattach, +.attach= fsattach, .destroyfid= fsdestroyfid, .walk1= fswalk1, .clone= fsclone, @@ -424,7 +423,7 @@ Srv fs = 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"); } @@ -435,6 +434,7 @@ threadmain(int argc, char **argv) char *mtpt = "/n/tftp"; time0 = time(0); + strcpy(net, "/net"); ipmove(ipaddr, IPnoaddr); ARGBEGIN{ @@ -448,6 +448,9 @@ threadmain(int argc, char **argv) case 'm': mtpt = EARGF(usage()); break; + case 'x': + setnetmtpt(net, sizeof net, EARGF(usage())); + break; default: usage(); }ARGEND; |