ref: ca2fa9596b5d0d893be28c6e8fd8a52a89a0c3c6
parent: b4b2cd72b0e674300e5ec0030967621a05049c35
author: aiju <devnull@localhost>
date: Sat Apr 29 14:44:01 EDT 2017
sshfs: add -r and -M options
--- a/sys/man/4/sshfs
+++ b/sys/man/4/sshfs
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B sshfs
[
-.B -abdRUG
+.B -abdRUGM
]
[
.B -s
@@ -15,6 +15,10 @@
.I mtpt
]
[
+.B -r
+.I root
+]
+[
.B -u
.I uidfile
]
@@ -56,7 +60,10 @@
.I sshfs
communicates with an SFTP server via stdin and stdout.
.PP
-.I Sshfs
+Unless
+.B -M
+is specified,
+.I sshfs
will mount itself under the mountpoint specified by
.IR mtpt ,
or under
@@ -73,6 +80,8 @@
.B -b
have the same function as they do with
.IR mount (1).
+The default remote root is the user's home directory but can be changed with
+.BR -r .
.PP
If
.B -s
@@ -108,7 +117,7 @@
Further options:
.TP
-R
-Read-only access only.
+Read access only.
.TP
-d
Enable debugging output.
@@ -125,6 +134,11 @@
did not change some of the fields.
.PP
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
.I
Sshfs
--- a/sys/src/cmd/sshfs.c
+++ b/sys/src/cmd/sshfs.c
@@ -7,6 +7,7 @@
int readonly;
int debug;
+char *root = ".";
#define dprint(...) if(debug) fprint(2, __VA_ARGS__)
#pragma varargck type "Σ" int
@@ -732,7 +733,8 @@
if(r->ifcall.aname != nil && *r->ifcall.aname != 0)
sf->fn = strdup(r->ifcall.aname);
else
- sf->fn = strdup(".");
+ sf->fn = strdup(root);
+ root = ".";
sf->qid = (Qid){qidcalc(sf->fn), 0, QTDIR};
r->ofcall.qid = sf->qid;
r->fid->qid = sf->qid;
@@ -1332,10 +1334,12 @@
case 'a': mflag |= MAFTER; break;
case 'b': mflag |= MBEFORE; break;
case 'm': mtpt = EARGF(usage()); break;
+ case 'M': mtpt = nil; break;
case 'u': uidfile = EARGF(usage()); break;
case 'U': uidfile = nil; break;
case 'g': gidfile = EARGF(usage()); break;
case 'G': gidfile = nil; break;
+ case 'r': root = EARGF(usage()); break;
default: usage();
}ARGEND;