diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2006-10-31 01:07:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-31 11:07:00 -0500 |
commit | 0bf16bffeef65622603af22151156807323d7dc7 (patch) | |
tree | a6a97156aed12ddfa01049786b5a0d716564fc94 /arch/um | |
parent | 84e945e399ce9710a34035ea81eaf5719aa709af (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')
-rw-r--r-- | arch/um/drivers/ubd_kern.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 3e3bb22c3ce8..125a63fd3a45 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) | |||
578 | struct openflags flags; | 578 | struct openflags flags; |
579 | char **back_ptr; | 579 | char **back_ptr; |
580 | int err, create_cow, *create_ptr; | 580 | int err, create_cow, *create_ptr; |
581 | int fd; | ||
581 | 582 | ||
582 | ubd_dev->openflags = ubd_dev->boot_openflags; | 583 | ubd_dev->openflags = ubd_dev->boot_openflags; |
583 | create_cow = 0; | 584 | create_cow = 0; |
584 | create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL; | 585 | create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL; |
585 | back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file; | 586 | back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file; |
586 | ubd_dev->fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared, | 587 | |
588 | fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared, | ||
587 | back_ptr, &ubd_dev->cow.bitmap_offset, | 589 | back_ptr, &ubd_dev->cow.bitmap_offset, |
588 | &ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset, | 590 | &ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset, |
589 | create_ptr); | 591 | create_ptr); |
590 | 592 | ||
591 | if((ubd_dev->fd == -ENOENT) && create_cow){ | 593 | if((fd == -ENOENT) && create_cow){ |
592 | ubd_dev->fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file, | 594 | fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file, |
593 | ubd_dev->openflags, 1 << 9, PAGE_SIZE, | 595 | ubd_dev->openflags, 1 << 9, PAGE_SIZE, |
594 | &ubd_dev->cow.bitmap_offset, | 596 | &ubd_dev->cow.bitmap_offset, |
595 | &ubd_dev->cow.bitmap_len, | 597 | &ubd_dev->cow.bitmap_len, |
596 | &ubd_dev->cow.data_offset); | 598 | &ubd_dev->cow.data_offset); |
597 | if(ubd_dev->fd >= 0){ | 599 | if(fd >= 0){ |
598 | printk(KERN_INFO "Creating \"%s\" as COW file for " | 600 | printk(KERN_INFO "Creating \"%s\" as COW file for " |
599 | "\"%s\"\n", ubd_dev->file, ubd_dev->cow.file); | 601 | "\"%s\"\n", ubd_dev->file, ubd_dev->cow.file); |
600 | } | 602 | } |
601 | } | 603 | } |
602 | 604 | ||
603 | if(ubd_dev->fd < 0){ | 605 | if(fd < 0){ |
604 | printk("Failed to open '%s', errno = %d\n", ubd_dev->file, | 606 | printk("Failed to open '%s', errno = %d\n", ubd_dev->file, |
605 | -ubd_dev->fd); | 607 | -fd); |
606 | return(ubd_dev->fd); | 608 | return fd; |
607 | } | 609 | } |
610 | ubd_dev->fd = fd; | ||
608 | 611 | ||
609 | if(ubd_dev->cow.file != NULL){ | 612 | if(ubd_dev->cow.file != NULL){ |
610 | err = -ENOMEM; | 613 | err = -ENOMEM; |