diff options
| author | forsyth <forsyth@vitanuova.com> | 2009-08-25 20:05:21 +0100 |
|---|---|---|
| committer | forsyth <forsyth@vitanuova.com> | 2009-08-25 20:05:21 +0100 |
| commit | 9cc6081ecb7a8f3f2cd63eaa9f6cd3df4f9fb801 (patch) | |
| tree | 6aeaf8f468e036eac546e850c0c974484db2c4b3 /appl/cmd/ftpfs.b | |
| parent | 74173b64021e5a33c09562a07fa63011a7369f0b (diff) | |
20090825-2005
Diffstat (limited to 'appl/cmd/ftpfs.b')
| -rw-r--r-- | appl/cmd/ftpfs.b | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/appl/cmd/ftpfs.b b/appl/cmd/ftpfs.b index afb152c1..ee5a44d4 100644 --- a/appl/cmd/ftpfs.b +++ b/appl/cmd/ftpfs.b @@ -202,10 +202,11 @@ connect(): string return nil; } -#shut(s: string) -#{ -# sys->print("ftpfs: %s shutdown\n", s); -#} +error(s: string) +{ + sys->fprint(sys->fildes(2), "ftpfs: %s\n", s); + raise "fail:"+s; +} # # Mount server. Must be spawned because it does @@ -214,8 +215,8 @@ connect(): string mount(mountpoint: string) { - if (sys->mount(mountfd, nil, mountpoint, sys->MREPL | sys->MCREATE, nil) < 0) { - sys->print("mount %s failed: %r\n", mountpoint); + if (sys->mount(mountfd, nil, mountpoint, Sys->MREPL | Sys->MCREATE, nil) < 0) { + sys->fprint(sys->fildes(2), "ftpfs: mount %s failed: %r\n", mountpoint); shutdown(); } mountfd = nil; @@ -1596,12 +1597,10 @@ init(nil: ref Draw->Context, args: list of string) if (debug) sys->print("proxyhost %s\n", proxyhost); } else { - d := "tcp!" + hostname + "!ftp"; + d := dial->netmkaddr(hostname, "tcp", "ftp"); ftp = dial->dial(d, nil); - if(ftp == nil) { - sys->print("dial %s failed: %r\n", d); - exit; - } + if(ftp == nil) + error(sys->sprint("dial %s failed: %r", d)); if(debug) sys->print("localdir %s\n", ftp.dir); dfid = ftp.dfd; @@ -1685,20 +1684,13 @@ init(nil: ref Draw->Context, args: list of string) spawn server(); # dies when receive on chan fails } -kill(pid: int): int +kill(pid: int) { if (debug) sys->print("killing %d\n", pid); - fd := sys->open("/prog/"+string pid+"/ctl", Sys->OWRITE); - if (fd == nil) { - sys->print("kill: open failed\n"); - return -1; - } - if (sys->write(fd, array of byte "kill", 4) != 4) { - sys->print("kill: write failed\n"); - return -1; - } - return 0; + fd := sys->open("#p/"+string pid+"/ctl", Sys->OWRITE); + if(fd != nil) + sys->fprint(fd, "kill"); } shutdown() @@ -1911,7 +1903,7 @@ clunkT(t: ref Tmsg.Clunk) f := getfid(t.fid); if (f.node.fileisdirty()) { if (f.node.createfile() < 0) - sys->print("ftpfs: could not create %s\n", f.node.pathname()); + sys->print("ftpfs: could not create %s: %r\n", f.node.pathname()); f.node.fileclean(); f.node.uncache(); } |
