summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ratfs
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-05-02 17:32:01 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-05-02 17:32:01 +0200
commitac88ce4f7f19be1aae1fdf390fa870b4be8dc3f5 (patch)
tree47df6acf41dd8d2dc607b89af9d4667935d0c952 /sys/src/cmd/ratfs
parent7ff6ea0f70307d4b82e6df69eb1310a6e27aa4ad (diff)
make bind(2) error handling consistent
The mount() and bind() syscalls return -1 on error, and the mountid sequence number on success. The manpage states that the mountid sequence number is a positive integer, but the kernels implementation currently uses a unsigned 32-bit integer and does not guarantee that the mountid will not become negative. Most code just cares about the error, so test for the -1 error value only.
Diffstat (limited to 'sys/src/cmd/ratfs')
-rw-r--r--sys/src/cmd/ratfs/main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/src/cmd/ratfs/main.c b/sys/src/cmd/ratfs/main.c
index c0add934f..38e46362e 100644
--- a/sys/src/cmd/ratfs/main.c
+++ b/sys/src/cmd/ratfs/main.c
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
break;
default:
close(p[0]);
- if(mount(p[1], -1, mountpoint, MREPL|MCREATE, "") < 0)
+ if(mount(p[1], -1, mountpoint, MREPL|MCREATE, "") == -1)
fatal("mount failed: %r");
}
exits(0);
@@ -155,10 +155,9 @@ post(int fd, char *mountpoint)
* another server is already running, so just exit.
*/
f = open(SRVFILE, ORDWR);
- if(f >= 0 && mount(f, -1, mountpoint, MREPL|MCREATE, "") >= 0){
- unmount(0, mountpoint);
- close(f);
- exits(0);
+ if(f >= 0 && mount(f, -1, mountpoint, MREPL|MCREATE, "") != -1){
+ unmount(0, mountpoint);
+ exits(0);
}
remove(SRVFILE);
}