aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-03-18 19:27:03 +0000
committerrsc <devnull@localhost>2005-03-18 19:27:03 +0000
commit80f72cbedc7c0b60d2172ed83279585ad6079247 (patch)
tree0a9f067b08c93d74c90b8fbbca8e218ae5b40fab /bin
parent3a6f92eed18aa29c7f5f2e150c0fb81adaa3a6bf (diff)
downloadplan9port-80f72cbedc7c0b60d2172ed83279585ad6079247.tar.gz
plan9port-80f72cbedc7c0b60d2172ed83279585ad6079247.tar.bz2
plan9port-80f72cbedc7c0b60d2172ed83279585ad6079247.zip
handle 9p servers
Diffstat (limited to 'bin')
-rwxr-xr-xbin/netfileget13
-rwxr-xr-xbin/netfileput20
-rwxr-xr-xbin/netfilestat52
3 files changed, 66 insertions, 19 deletions
diff --git a/bin/netfileget b/bin/netfileget
index 1b39f0f3..c621482d 100755
--- a/bin/netfileget
+++ b/bin/netfileget
@@ -11,6 +11,10 @@ if(! ~ $#* 2){
exit usage
}
+ns=`{namespace}
+if(u test -S $ns/$1)
+ f=$f^9p
+
t=/tmp/netget.$pid.$USER
fn sigexit { rm -f $t }
@@ -21,12 +25,21 @@ fn getfile {
cat $t
}
+fn getfile9p {
+ if(! 9p read $1/$2)
+ exit 1
+}
+
fn getdir {
if(! {echo cd $2; echo ls -l} | sftp -b - $1 | sed '1,2d; s/sftp> //g; /^$/d' >$t)
exit 1
cat $t | awk '$NF == "." || $NF == ".." { next } {s = $NF; if($0 ~ /^d/) s = s "/"; print s}'
}
+fn getdir9p {
+ 9p ls -l $1/$2 | awk '{s=$NF; if($0 ~ /^d/) s=s"/"; print s}'
+}
+
$f $1 $2
exit 0
diff --git a/bin/netfileput b/bin/netfileput
index 9a5a396d..baa3eb12 100755
--- a/bin/netfileput
+++ b/bin/netfileput
@@ -1,15 +1,27 @@
#!/usr/local/plan9/bin/rc
-whatis '*'
if(! ~ $#* 2){
echo 'usage: netput system path' >[1=2]
exit usage
}
+f=putfile
+ns=`{namespace}
+if(u test -S $ns/$1)
+ f=$f^9p
+
t=/tmp/netget.$pid.$USER
fn sigexit { rm -f $t }
-cat >$t
-if(! echo put $t $2 | sftp -b - $1 >/dev/null)
- exit 1
+fn putfile{
+ cat >$t
+ if(! echo put $t $2 | sftp -b - $1 >/dev/null)
+ exit 1
+}
+fn putfile9p{
+ if(! 9p write $1/$2)
+ exit 1
+}
+
+$f $1 $2
exit 0
diff --git a/bin/netfilestat b/bin/netfilestat
index 8e81cf69..1d687e51 100755
--- a/bin/netfilestat
+++ b/bin/netfilestat
@@ -5,26 +5,48 @@ if(! ~ $#* 2){
exit usage
}
+f=dostat
+ns=`{namespace}
+if(u test -S $ns/$1)
+ f=$f^9p
+
t=/tmp/netisdir.$pid.$USER
fn sigexit { rm -f $t }
-{
- echo !echo XXX connected
- echo cd $2
- echo !echo XXX directory exists
-} | sftp -b - $1 >$t >[2=1]
-if(9 grep -s XXX.directory.exists $t){
- echo directory
+fn dostat {
+ {
+ echo !echo XXX connected
+ echo cd $2
+ echo !echo XXX directory exists
+ } | sftp -b - $1 >$t >[2=1]
+ if(9 grep -s XXX.directory.exists $t){
+ echo directory
+ exit 0
+ }
+ if(9 grep -s 'is not a directory' $t){
+ echo file
+ exit 0
+ }
+ cat $t | sed 's/sftp> //g; /^$/d; /XXX/d; /^cd /d' >[1=2]
+ if(! 9 grep -s XXX.connected $t){
+ echo connect failed
+ exit 0
+ }
+ echo nonexistent
exit 0
}
-if(9 grep -s 'is not a directory' $t){
+
+fn dostat9p {
+ if(! 9p ls -ld $1/$2 >$t >[2]/dev/null){
+ echo nonexistent
+ exit 0
+ }
+ if(9 grep -s '^d' $t){
+ echo directory
+ exit 0
+ }
echo file
exit 0
}
-cat $t | sed 's/sftp> //g; /^$/d; /XXX/d; /^cd /d' >[1=2]
-if(! 9 grep -s XXX.connected $t){
- echo connect failed
- exit 0
-}
-echo nonexistent
-exit 0
+
+$f $1 $2