Tftp_ERROR = 5,
Tftp_OACK = 6,
- TftpPort = 69,
+ TftpPort = 69,
Segsize = 512,
Maxpath = 2+2+Segsize-8,
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)
{
f = emalloc9p(sizeof *f);
memset(f, 0, sizeof(*f));
ipmove(f->addr, addr);
- strncpy(f->path, path, sizeof(f->path));
+ strncpy(f->path, path, Maxpath-1);
f->ref = 1;
f->id = id++;
f->next = files;
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;
if((c = f->c) == nil)
goto out;
- threadsetname(f->path);
+ threadsetname("%s", 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;
}
msg.buf[n] = 0;
switch(nhgets(msg.buf)){
case Tftp_ERROR:
- werrstr((char*)msg.buf+4);
+ werrstr("%s", (char*)msg.buf+4);
err = "%r";
goto out;
if(c){
while((r != nil) || (r = recvp(c))){
if(err){
- char buf[ERRMAX];
-
snprint(buf, sizeof(buf), err);
respond(r, buf);
} else {
Srv fs =
{
-.attach= fsattach,
+.attach= fsattach,
.destroyfid= fsdestroyfid,
.walk1= fswalk1,
.clone= fsclone,
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");
}
char *mtpt = "/n/tftp";
time0 = time(0);
+ strcpy(net, "/net");
ipmove(ipaddr, IPnoaddr);
ARGBEGIN{
case 'm':
mtpt = EARGF(usage());
break;
+ case 'x':
+ setnetmtpt(net, sizeof net, EARGF(usage()));
+ break;
default:
usage();
}ARGEND;