sshfs: add -r and -M options

This commit is contained in:
aiju 2017-04-29 18:44:01 +00:00
parent b4b2cd72b0
commit ca2fa9596b
2 changed files with 22 additions and 4 deletions

View file

@ -4,7 +4,7 @@ sshfs - secure file transfer protocol client
.SH SYNOPSIS .SH SYNOPSIS
.B sshfs .B sshfs
[ [
.B -abdRUG .B -abdRUGM
] ]
[ [
.B -s .B -s
@ -15,6 +15,10 @@ sshfs - secure file transfer protocol client
.I mtpt .I mtpt
] ]
[ [
.B -r
.I root
]
[
.B -u .B -u
.I uidfile .I uidfile
] ]
@ -56,7 +60,10 @@ is specified,
.I sshfs .I sshfs
communicates with an SFTP server via stdin and stdout. communicates with an SFTP server via stdin and stdout.
.PP .PP
.I Sshfs Unless
.B -M
is specified,
.I sshfs
will mount itself under the mountpoint specified by will mount itself under the mountpoint specified by
.IR mtpt , .IR mtpt ,
or under or under
@ -73,6 +80,8 @@ and
.B -b .B -b
have the same function as they do with have the same function as they do with
.IR mount (1). .IR mount (1).
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
@ -108,7 +117,7 @@ If these files cannot be accessed for any reason, numeric IDs simply remain untr
Further options: Further options:
.TP .TP
-R -R
Read-only access only. Read access only.
.TP .TP
-d -d
Enable debugging output. Enable debugging output.
@ -125,6 +134,11 @@ In particular there is no guarantee that a failed
did not change some of the fields. did not change some of the fields.
.PP .PP
The code is naive about links and assumes files with distinct names to be distinct, assigning them different QIDs. The code is naive about links and assumes files with distinct names to be distinct, assigning them different QIDs.
.PP
File names with null bytes in them will confuse
.I sshfs.
.I Sshfs
should probably escape them, as well as control characters that might confuse other software.
.SH HISTORY .SH HISTORY
.I .I
Sshfs Sshfs

View file

@ -7,6 +7,7 @@
int readonly; int readonly;
int debug; int debug;
char *root = ".";
#define dprint(...) if(debug) fprint(2, __VA_ARGS__) #define dprint(...) if(debug) fprint(2, __VA_ARGS__)
#pragma varargck type "Σ" int #pragma varargck type "Σ" int
@ -732,7 +733,8 @@ sshfsattach(Req *r)
if(r->ifcall.aname != nil && *r->ifcall.aname != 0) if(r->ifcall.aname != nil && *r->ifcall.aname != 0)
sf->fn = strdup(r->ifcall.aname); sf->fn = strdup(r->ifcall.aname);
else else
sf->fn = strdup("."); sf->fn = strdup(root);
root = ".";
sf->qid = (Qid){qidcalc(sf->fn), 0, QTDIR}; sf->qid = (Qid){qidcalc(sf->fn), 0, QTDIR};
r->ofcall.qid = sf->qid; r->ofcall.qid = sf->qid;
r->fid->qid = sf->qid; r->fid->qid = sf->qid;
@ -1332,10 +1334,12 @@ threadmain(int argc, char **argv)
case 'a': mflag |= MAFTER; break; case 'a': mflag |= MAFTER; break;
case 'b': mflag |= MBEFORE; break; case 'b': mflag |= MBEFORE; break;
case 'm': mtpt = EARGF(usage()); break; case 'm': mtpt = EARGF(usage()); break;
case 'M': mtpt = nil; break;
case 'u': uidfile = EARGF(usage()); break; case 'u': uidfile = EARGF(usage()); break;
case 'U': uidfile = nil; break; case 'U': uidfile = nil; break;
case 'g': gidfile = EARGF(usage()); break; case 'g': gidfile = EARGF(usage()); break;
case 'G': gidfile = nil; break; case 'G': gidfile = nil; break;
case 'r': root = EARGF(usage()); break;
default: usage(); default: usage();
}ARGEND; }ARGEND;