diff options
author | jdike <jdike> | 2003-09-18 14:13:09 +0000 |
---|---|---|
committer | jdike <jdike> | 2003-09-18 14:13:09 +0000 |
commit | 4b1f82dc701c8c3ae0a58a2c446d3d7b71cf5bfb (patch) | |
tree | f808207efb1d7822e42ab7b5d1655b207fca66c3 | |
parent | f4684731388a6e042268a23e9e0bbc818a9493e7 (diff) | |
download | uml-history-4b1f82dc701c8c3ae0a58a2c446d3d7b71cf5bfb.tar.gz |
Cleaned up the error handling and reporting.
Fixed a race.
-rw-r--r-- | arch/um/drivers/ubd_user.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c index 166ad6f..f745d2c 100644 --- a/arch/um/drivers/ubd_user.c +++ b/arch/um/drivers/ubd_user.c @@ -45,7 +45,7 @@ static int same_backing_files(char *from_cmdline, char *from_cow, char *cow) printk("Couldn't stat '%s', err = %d\n", from_cow, -err); return(1); } - if((buf1.st_dev == buf2.st_dev) && (buf1.st_ino == buf2.st_ino)) + if((buf1.ust_dev == buf2.ust_dev) && (buf1.ust_ino == buf2.ust_ino)) return(1); printk("Backing file mismatch - \"%s\" requested,\n" @@ -79,9 +79,9 @@ static int backing_file_mismatch(char *file, __u64 size, time_t mtime) "file\n", size, actual); return(-EINVAL); } - if(buf.st_mtime != mtime){ + if(buf.ust_mtime != mtime){ printk("mtime mismatch (%ld vs %ld) of COW header vs backing " - "file\n", mtime, buf.st_mtime); + "file\n", mtime, buf.ust_mtime); return(-EINVAL); } return(0); @@ -317,21 +317,21 @@ int io_thread(void *arg) while(1){ n = os_read_file(kernel_fd, &req, sizeof(req)); if(n != sizeof(req)){ - if(n < 0) { - printk("io_thread - read failed, err = %d\n", - -n); - } + if(n < 0) + printk("io_thread - read failed, fd = %d, " + "err = %d\n", kernel_fd, -n); else { - printk("io_thread - short read : length = %d\n", - n); - continue; + printk("io_thread - short read, fd = %d, " + "length = %d\n", kernel_fd, n); } + continue; } io_count++; do_io(&req); n = os_write_file(kernel_fd, &req, sizeof(req)); if(n != sizeof(req)) - printk("io_thread - write failed, err = %d\n", -n); + printk("io_thread - write failed, fd = %d, err = %d\n", + kernel_fd, -n); } } @@ -342,24 +342,28 @@ int start_io_thread(unsigned long sp, int *fd_out) err = os_pipe(fds, 1, 1); if(err < 0){ printk("start_io_thread - os_pipe failed, err = %d\n", -err); - return(err); + goto out; } + kernel_fd = fds[0]; + *fd_out = fds[1]; + pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD, NULL); if(pid < 0){ printk("start_io_thread - clone failed : errno = %d\n", errno); - goto err; + goto out_close; } - kernel_fd = fds[0]; - *fd_out = fds[1]; - return(pid); - err: + + out_close: os_close_file(fds[0]); os_close_file(fds[1]); - return(-errno); + kernel_fd = -1; + *fd_out = -1; + out: + return(err); } /* |