Hi Yong,

On Sat, May 17, 2025 at 05:05:43PM +0800, Sheng Yong wrote:
> From: Sheng Yong <shengyo...@xiaomi.com>
> 
> When attempting to use an archive file, such as APEX on android,
> as a file-backed mount source, it fails because EROFS image within
> the archive file does not start at offset 0. As a result, a loop
> or a dm device is still needed to attach the image file at an
> appropriate offset first. Similarly, if an EROFS image within a
> block device does not start at offset 0, it cannot be mounted
> directly either.
> 
> To address this issue, this patch adds a new mount option `fsoffset=x'
> to accept a start offset for the primary device. The offset should be
> aligned to the block size. EROFS will add this offset before performing
> read requests.
> 
> Signed-off-by: Sheng Yong <shengyo...@xiaomi.com>
> Signed-off-by: Wang Shuai <wangshua...@xiaomi.com>

I applied the following diff to fulfill the Hongbo's previous suggestion
and refine an error message:

diff --git a/Documentation/filesystems/erofs.rst 
b/Documentation/filesystems/erofs.rst
index 11b0f8635f04..d93b30287110 100644
--- a/Documentation/filesystems/erofs.rst
+++ b/Documentation/filesystems/erofs.rst
@@ -128,7 +128,7 @@ device=%s              Specify a path to an extra device to 
be used together.
 fsid=%s                Specify a filesystem image ID for Fscache back-end.
 domain_id=%s           Specify a domain ID in fscache mode so that different 
images
                        with the same blobs under a given domain ID can share 
storage.
-fsoffset=%lu           Specify image offset for the primary device.
+fsoffset=%lu           Specify block-aligned filesystem offset for the primary 
device.
 ===================    
=========================================================
 
 Sysfs Entries
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 3185bb90f549..e1e9f06e8342 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -654,9 +654,9 @@ static int erofs_fc_fill_super(struct super_block *sb, 
struct fs_context *fc)
        }
 
        if (sbi->dif0.fsoff) {
-               if (sbi->dif0.fsoff & ((1 << sbi->blkszbits) - 1))
-                       return invalfc(fc, "fsoffset %llu not aligned to block 
size",
-                                      sbi->dif0.fsoff);
+               if (sbi->dif0.fsoff & (sb->s_blocksize - 1))
+                       return invalfc(fc, "fsoffset %llu is not aligned to 
block size %lu",
+                                      sbi->dif0.fsoff, sb->s_blocksize);
                if (erofs_is_fscache_mode(sb))
                        return invalfc(fc, "cannot use fsoffset in fscache 
mode");
        }

Reply via email to