sshfs(4): replace the much maligned -r option
This commit is contained in:
parent
2b5dfee06c
commit
41013392a1
2 changed files with 48 additions and 23 deletions
|
@ -82,8 +82,6 @@ and
|
||||||
.B -b
|
.B -b
|
||||||
have the same function as they do with
|
have the same function as they do with
|
||||||
.IR mount .
|
.IR mount .
|
||||||
The default remote root is the user's home directory but can be changed with
|
|
||||||
.BR -r .
|
|
||||||
.PP
|
.PP
|
||||||
If
|
If
|
||||||
.B -s
|
.B -s
|
||||||
|
@ -92,11 +90,20 @@ it will post itself in
|
||||||
.IR srv (3)
|
.IR srv (3)
|
||||||
with service name
|
with service name
|
||||||
.IR service .
|
.IR service .
|
||||||
If the service file is mounted, the
|
If the service file is mounted, the attach name (the third argument to
|
||||||
.IR attach (5)
|
.IR mount (1)) can be used to specify which directory on the remote host will be mounted.
|
||||||
name can be used to specify which directory on the remote host will be mounted.
|
.PP
|
||||||
If it is omitted or empty, the user's home directory is used.
|
By default, relative paths are assumed relative to the user's home directory.
|
||||||
Relative paths are also relative to this directory.
|
The
|
||||||
|
.B -r
|
||||||
|
option can be used to specify an alternative base for relative paths.
|
||||||
|
The initial mount at
|
||||||
|
.B -m
|
||||||
|
also uses this directory.
|
||||||
|
If an attach name starts with
|
||||||
|
.BR ~ ,
|
||||||
|
the user's home directory is substituted for
|
||||||
|
.BR ~ .
|
||||||
.PP
|
.PP
|
||||||
Since the only supported version 3 of the SFTP protocol has no way to look up numeric user and group IDs,
|
Since the only supported version 3 of the SFTP protocol has no way to look up numeric user and group IDs,
|
||||||
.I sshfs
|
.I sshfs
|
||||||
|
|
|
@ -600,6 +600,7 @@ attrfixupqid(Qid *qid)
|
||||||
if(flags & SSH_FILEXFER_ATTR_PERMISSIONS){
|
if(flags & SSH_FILEXFER_ATTR_PERMISSIONS){
|
||||||
if(p + 4 > rxpkt + rxlen) return -1;
|
if(p + 4 > rxpkt + rxlen) return -1;
|
||||||
if((GET4(p) & 0170000) != 0040000) qid->type = 0;
|
if((GET4(p) & 0170000) != 0040000) qid->type = 0;
|
||||||
|
else qid->type = QTDIR;
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
if(flags & SSH_FILEXFER_ATTR_ACMODTIME){
|
if(flags & SSH_FILEXFER_ATTR_ACMODTIME){
|
||||||
|
@ -722,21 +723,40 @@ sshfsattach(Req *r)
|
||||||
{
|
{
|
||||||
SFid *sf;
|
SFid *sf;
|
||||||
|
|
||||||
if(r->ifcall.aname != nil && *r->ifcall.aname != 0 && r->aux == nil){
|
if(r->aux == nil){
|
||||||
|
sf = emalloc9p(sizeof(SFid));
|
||||||
|
if(r->ifcall.aname != nil)
|
||||||
|
switch(*r->ifcall.aname){
|
||||||
|
case '~':
|
||||||
|
switch(r->ifcall.aname[1]){
|
||||||
|
case 0: sf->fn = estrdup9p("."); break;
|
||||||
|
case '/': sf->fn = estrdup9p(r->ifcall.aname + 2); break;
|
||||||
|
default:
|
||||||
|
free(sf);
|
||||||
|
respond(r, "invalid attach name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
sf->fn = estrdup9p(r->ifcall.aname);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
sf->fn = estrdup9p(root);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sf->fn = pathcat(root, r->ifcall.aname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sf->fn = estrdup9p(root);
|
||||||
|
r->fid->aux = sf;
|
||||||
submitreq(r);
|
submitreq(r);
|
||||||
return;
|
}else{
|
||||||
|
sf = r->fid->aux;
|
||||||
|
sf->qid = (Qid){qidcalc(sf->fn), 0, QTDIR};
|
||||||
|
r->ofcall.qid = sf->qid;
|
||||||
|
r->fid->qid = sf->qid;
|
||||||
|
respond(r, nil);
|
||||||
}
|
}
|
||||||
sf = emalloc9p(sizeof(SFid));
|
|
||||||
if(r->ifcall.aname != nil && *r->ifcall.aname != 0)
|
|
||||||
sf->fn = estrdup9p(r->ifcall.aname);
|
|
||||||
else
|
|
||||||
sf->fn = estrdup9p(root);
|
|
||||||
root = ".";
|
|
||||||
sf->qid = (Qid){qidcalc(sf->fn), 0, QTDIR};
|
|
||||||
r->ofcall.qid = sf->qid;
|
|
||||||
r->fid->qid = sf->qid;
|
|
||||||
r->fid->aux = sf;
|
|
||||||
respond(r, nil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -783,7 +803,7 @@ sendproc(void *)
|
||||||
sf = r->req->fid != nil ? r->req->fid->aux : nil;
|
sf = r->req->fid != nil ? r->req->fid->aux : nil;
|
||||||
switch(r->req->ifcall.type){
|
switch(r->req->ifcall.type){
|
||||||
case Tattach:
|
case Tattach:
|
||||||
sendpkt("bus", SSH_FXP_STAT, r->reqid, r->req->ifcall.aname, strlen(r->req->ifcall.aname));
|
sendpkt("bus", SSH_FXP_STAT, r->reqid, sf->fn, strlen(sf->fn));
|
||||||
break;
|
break;
|
||||||
case Twalk:
|
case Twalk:
|
||||||
sendpkt("bus", SSH_FXP_STAT, r->reqid, r->req->aux, strlen(r->req->aux));
|
sendpkt("bus", SSH_FXP_STAT, r->reqid, r->req->aux, strlen(r->req->aux));
|
||||||
|
@ -1364,8 +1384,6 @@ threadmain(int argc, char **argv)
|
||||||
sshfssrv.wstat = nil;
|
sshfssrv.wstat = nil;
|
||||||
sshfssrv.remove = nil;
|
sshfssrv.remove = nil;
|
||||||
}
|
}
|
||||||
if(mtpt == nil)
|
|
||||||
root = ".";
|
|
||||||
|
|
||||||
if(pflag){
|
if(pflag){
|
||||||
rdfd = 0;
|
rdfd = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue