aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/ubd_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/ubd_kern.c')
-rw-r--r--arch/um/drivers/ubd_kern.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 620f5b70957d..944453a3ec99 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -46,7 +46,6 @@
46#include "asm/tlbflush.h" 46#include "asm/tlbflush.h"
47#include "mem_user.h" 47#include "mem_user.h"
48#include "kern_util.h" 48#include "kern_util.h"
49#include "kern.h"
50#include "mconsole_kern.h" 49#include "mconsole_kern.h"
51#include "init.h" 50#include "init.h"
52#include "irq_user.h" 51#include "irq_user.h"
@@ -54,7 +53,6 @@
54#include "ubd_user.h" 53#include "ubd_user.h"
55#include "os.h" 54#include "os.h"
56#include "mem.h" 55#include "mem.h"
57#include "mem_kern.h"
58#include "cow.h" 56#include "cow.h"
59 57
60enum ubd_req { UBD_READ, UBD_WRITE }; 58enum ubd_req { UBD_READ, UBD_WRITE };
@@ -513,8 +511,37 @@ __uml_exitcall(kill_io_thread);
513static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out) 511static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
514{ 512{
515 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 }
516 530
517 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, &sector_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
544out:
518 return os_file_size(file, size_out); 545 return os_file_size(file, size_out);
519} 546}
520 547