diff options
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/ubd_kern.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index b3c854523e6c..944453a3ec99 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
@@ -511,8 +511,37 @@ __uml_exitcall(kill_io_thread); | |||
511 | static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out) | 511 | static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out) |
512 | { | 512 | { |
513 | char *file; | 513 | char *file; |
514 | int fd; | ||
515 | int err; | ||
516 | |||
517 | __u32 version; | ||
518 | __u32 align; | ||
519 | char *backing_file; | ||
520 | time_t mtime; | ||
521 | unsigned long long size; | ||
522 | int sector_size; | ||
523 | int bitmap_offset; | ||
524 | |||
525 | if (ubd_dev->file && ubd_dev->cow.file) { | ||
526 | file = ubd_dev->cow.file; | ||
527 | |||
528 | goto out; | ||
529 | } | ||
514 | 530 | ||
515 | file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file; | 531 | fd = os_open_file(ubd_dev->file, global_openflags, 0); |
532 | if (fd < 0) | ||
533 | return fd; | ||
534 | |||
535 | err = read_cow_header(file_reader, &fd, &version, &backing_file, \ | ||
536 | &mtime, &size, §or_size, &align, &bitmap_offset); | ||
537 | os_close_file(fd); | ||
538 | |||
539 | if(err == -EINVAL) | ||
540 | file = ubd_dev->file; | ||
541 | else | ||
542 | file = backing_file; | ||
543 | |||
544 | out: | ||
516 | return os_file_size(file, size_out); | 545 | return os_file_size(file, size_out); |
517 | } | 546 | } |
518 | 547 | ||