summaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/ubd_kern.c
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2006-10-30 22:07:11 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-31 08:07:00 -0800
commit0bf16bffeef65622603af22151156807323d7dc7 (patch)
treea6a97156aed12ddfa01049786b5a0d716564fc94 /arch/um/drivers/ubd_kern.c
parent84e945e399ce9710a34035ea81eaf5719aa709af (diff)
[PATCH] uml ubd driver: do not store error codes as ->fd
To simplify error handling, make sure fd is saved into ubd_dev->fd only when we are sure it is an fd and not an error code. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/drivers/ubd_kern.c')
-rw-r--r--arch/um/drivers/ubd_kern.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 3e3bb22c3ce..125a63fd3a4 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -578,33 +578,36 @@ static int ubd_open_dev(struct ubd *ubd_dev)
struct openflags flags;
char **back_ptr;
int err, create_cow, *create_ptr;
+ int fd;
ubd_dev->openflags = ubd_dev->boot_openflags;
create_cow = 0;
create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL;
back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file;
- ubd_dev->fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared,
+
+ fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared,
back_ptr, &ubd_dev->cow.bitmap_offset,
&ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset,
create_ptr);
- if((ubd_dev->fd == -ENOENT) && create_cow){
- ubd_dev->fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file,
+ if((fd == -ENOENT) && create_cow){
+ fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file,
ubd_dev->openflags, 1 << 9, PAGE_SIZE,
&ubd_dev->cow.bitmap_offset,
&ubd_dev->cow.bitmap_len,
&ubd_dev->cow.data_offset);
- if(ubd_dev->fd >= 0){
+ if(fd >= 0){
printk(KERN_INFO "Creating \"%s\" as COW file for "
"\"%s\"\n", ubd_dev->file, ubd_dev->cow.file);
}
}
- if(ubd_dev->fd < 0){
+ if(fd < 0){
printk("Failed to open '%s', errno = %d\n", ubd_dev->file,
- -ubd_dev->fd);
- return(ubd_dev->fd);
+ -fd);
+ return fd;
}
+ ubd_dev->fd = fd;
if(ubd_dev->cow.file != NULL){
err = -ENOMEM;