Initialize ocicfg only when nbdsrc.type changes to EROFSNBD_SOURCE_OCI. Fixes: 6a7cfdb9cd66 ("erofs-utils: oci: add support for indexing by layer digest") Cc: Chengyu Zhu <hudson...@tencent.com> Signed-off-by: Gao Xiang <hsiang...@linux.alibaba.com> --- mount/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/mount/main.c b/mount/main.c index eb0dd01..e2443f8 100644 --- a/mount/main.c +++ b/mount/main.c @@ -83,10 +83,6 @@ static int erofsmount_parse_oci_option(const char *option) char *p; long idx; - if (oci_cfg->layer_index == 0 && !oci_cfg->blob_digest && - !oci_cfg->platform && !oci_cfg->username && !oci_cfg->password) - oci_cfg->layer_index = -1; - p = strstr(option, "oci.blob="); if (p != NULL) { p += strlen("oci.blob="); @@ -147,10 +143,6 @@ static int erofsmount_parse_oci_option(const char *option) } } } - - if (oci_cfg->platform || oci_cfg->username || oci_cfg->password || - oci_cfg->blob_digest || oci_cfg->layer_index >= 0) - nbdsrc.type = EROFSNBD_SOURCE_OCI; return 0; } #else @@ -191,6 +183,11 @@ static long erofsmount_parse_flagopts(char *s, long flags, char **more) *comma = '\0'; if (strncmp(s, "oci", 3) == 0) { + /* Initialize ocicfg here iff != EROFSNBD_SOURCE_OCI */ + if (nbdsrc.type != EROFSNBD_SOURCE_OCI) { + nbdsrc.type = EROFSNBD_SOURCE_OCI; + nbdsrc.ocicfg.layer_index = -1; + } err = erofsmount_parse_oci_option(s); if (err < 0) return err; -- 2.43.5