From 87aa4832f7f3587a65ee92ffa24f528652684c1b Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Thu, 1 Feb 2018 11:37:17 +0100
Subject: fs: add support loop mount offset
When loop mounting, allow to specify an offset into the file, similarly
to the losetup offset option. Multiplicative suffixes are supported.
Signed-off-by: Philipp Zabel
Signed-off-by: Sascha Hauer
---
fs/fs.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'fs/fs.c')
diff --git a/fs/fs.c b/fs/fs.c
index 7d0d97906d..d188fa995f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1279,11 +1279,13 @@ static const char *detect_fs(const char *filename, const char *fsoptions)
enum filetype type;
struct driver_d *drv;
struct fs_driver_d *fdrv;
- bool loop;
+ bool loop = false;
+ unsigned long long offset = 0;
parseopt_b(fsoptions, "loop", &loop);
+ parseopt_llu_suffix(fsoptions, "offset", &offset);
if (loop)
- type = file_name_detect_type(filename);
+ type = file_name_detect_type_offset(filename, offset);
else
type = cdev_detect_type(filename);
@@ -1302,9 +1304,13 @@ static const char *detect_fs(const char *filename, const char *fsoptions)
int fsdev_open_cdev(struct fs_device_d *fsdev)
{
+ unsigned long long offset = 0;
+
parseopt_b(fsdev->options, "loop", &fsdev->loop);
+ parseopt_llu_suffix(fsdev->options, "offset", &offset);
if (fsdev->loop)
- fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR);
+ fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR,
+ offset);
else
fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR);
if (!fsdev->cdev)
--
cgit v1.2.3