mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
handle 9p servers
This commit is contained in:
parent
3a6f92eed1
commit
80f72cbedc
3 changed files with 66 additions and 19 deletions
|
@ -11,6 +11,10 @@ if(! ~ $#* 2){
|
||||||
exit usage
|
exit usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ns=`{namespace}
|
||||||
|
if(u test -S $ns/$1)
|
||||||
|
f=$f^9p
|
||||||
|
|
||||||
t=/tmp/netget.$pid.$USER
|
t=/tmp/netget.$pid.$USER
|
||||||
fn sigexit { rm -f $t }
|
fn sigexit { rm -f $t }
|
||||||
|
|
||||||
|
@ -21,12 +25,21 @@ fn getfile {
|
||||||
cat $t
|
cat $t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn getfile9p {
|
||||||
|
if(! 9p read $1/$2)
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
fn getdir {
|
fn getdir {
|
||||||
if(! {echo cd $2; echo ls -l} | sftp -b - $1 | sed '1,2d; s/sftp> //g; /^$/d' >$t)
|
if(! {echo cd $2; echo ls -l} | sftp -b - $1 | sed '1,2d; s/sftp> //g; /^$/d' >$t)
|
||||||
exit 1
|
exit 1
|
||||||
cat $t | awk '$NF == "." || $NF == ".." { next } {s = $NF; if($0 ~ /^d/) s = s "/"; print s}'
|
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
|
$f $1 $2
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
#!/usr/local/plan9/bin/rc
|
#!/usr/local/plan9/bin/rc
|
||||||
|
|
||||||
whatis '*'
|
|
||||||
if(! ~ $#* 2){
|
if(! ~ $#* 2){
|
||||||
echo 'usage: netput system path' >[1=2]
|
echo 'usage: netput system path' >[1=2]
|
||||||
exit usage
|
exit usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f=putfile
|
||||||
|
ns=`{namespace}
|
||||||
|
if(u test -S $ns/$1)
|
||||||
|
f=$f^9p
|
||||||
|
|
||||||
t=/tmp/netget.$pid.$USER
|
t=/tmp/netget.$pid.$USER
|
||||||
fn sigexit { rm -f $t }
|
fn sigexit { rm -f $t }
|
||||||
|
|
||||||
|
fn putfile{
|
||||||
cat >$t
|
cat >$t
|
||||||
if(! echo put $t $2 | sftp -b - $1 >/dev/null)
|
if(! echo put $t $2 | sftp -b - $1 >/dev/null)
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
fn putfile9p{
|
||||||
|
if(! 9p write $1/$2)
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$f $1 $2
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -5,9 +5,15 @@ if(! ~ $#* 2){
|
||||||
exit usage
|
exit usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f=dostat
|
||||||
|
ns=`{namespace}
|
||||||
|
if(u test -S $ns/$1)
|
||||||
|
f=$f^9p
|
||||||
|
|
||||||
t=/tmp/netisdir.$pid.$USER
|
t=/tmp/netisdir.$pid.$USER
|
||||||
fn sigexit { rm -f $t }
|
fn sigexit { rm -f $t }
|
||||||
|
|
||||||
|
fn dostat {
|
||||||
{
|
{
|
||||||
echo !echo XXX connected
|
echo !echo XXX connected
|
||||||
echo cd $2
|
echo cd $2
|
||||||
|
@ -28,3 +34,19 @@ if(! 9 grep -s XXX.connected $t){
|
||||||
}
|
}
|
||||||
echo nonexistent
|
echo nonexistent
|
||||||
exit 0
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
$f $1 $2
|
||||||
|
|
Loading…
Reference in a new issue