vftp: walk fixes (Fazlul Shahriar)
This commit is contained in:
parent
d29f5ece8b
commit
ff086a8232
1 changed files with 14 additions and 1 deletions
|
|
@ -54,6 +54,16 @@ ebuf(void)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
estrdup(char *s)
|
||||||
|
{
|
||||||
|
char *t;
|
||||||
|
|
||||||
|
t = emalloc(strlen(s)+1);
|
||||||
|
strcpy(t, s);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
walk(char *path, Nfs3Handle *ph)
|
walk(char *path, Nfs3Handle *ph)
|
||||||
{
|
{
|
||||||
|
|
@ -61,6 +71,7 @@ walk(char *path, Nfs3Handle *ph)
|
||||||
Nfs3Handle h;
|
Nfs3Handle h;
|
||||||
Nfs3Status ok;
|
Nfs3Status ok;
|
||||||
|
|
||||||
|
path = estrdup(path); /* writable */
|
||||||
if(path[0] == '/')
|
if(path[0] == '/')
|
||||||
h = root;
|
h = root;
|
||||||
else
|
else
|
||||||
|
|
@ -75,10 +86,12 @@ walk(char *path, Nfs3Handle *ph)
|
||||||
continue;
|
continue;
|
||||||
if((ok = fsyslookup(fsys, auth, &h, p, &h)) != Nfs3Ok){
|
if((ok = fsyslookup(fsys, auth, &h, p, &h)) != Nfs3Ok){
|
||||||
nfs3errstr(ok);
|
nfs3errstr(ok);
|
||||||
|
free(path);
|
||||||
return ebuf();
|
return ebuf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ph = h;
|
*ph = h;
|
||||||
|
free(path);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,7 +120,7 @@ cmdcd(int argc, char **argv)
|
||||||
return err;
|
return err;
|
||||||
if((ok = fsysgetattr(fsys, auth, &h, &attr)) != Nfs3Ok){
|
if((ok = fsysgetattr(fsys, auth, &h, &attr)) != Nfs3Ok){
|
||||||
nfs3errstr(ok);
|
nfs3errstr(ok);
|
||||||
fprint(2, "%s: %r\n");
|
fprint(2, "%s: %r\n", argv[1]);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if(attr.type != Nfs3FileDir)
|
if(attr.type != Nfs3FileDir)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue