aboutsummaryrefslogtreecommitdiff
path: root/bin/netfilestat
diff options
context:
space:
mode:
Diffstat (limited to 'bin/netfilestat')
-rwxr-xr-xbin/netfilestat52
1 files changed, 37 insertions, 15 deletions
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