Skip to contentSkip to conversation

erofs-utils: mount: don't overwrite layer_index with -1 again

PATCH In review Gao Xiang 2 participants 2 messages Oct 7, 2025 – Oct 9, 2025

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: mount: don't overwrite layer_index with -1 again

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 <[email protected]>
---
 mount/main.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
mount/main.c +5 -8
index eb0dd01..e2443f8 100644
@@ -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;
Signature · 1 line
2.43.5
Reviewed-by Chengyu Zhu on v1 1/1
#1 lore raw

Thanks,
Chengyu

Quoted 53 lines

2025年10月7日 11:22,Gao Xiang <[email protected]> 写道:

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 <[email protected]>

---
mount/main.c | 13 +++++--------

1 file changed, 5 insertions(+), 8 deletions(-)
mount/main.c +5 -8
index eb0dd01..e2443f8 100644
@@ -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;
Signature · 1 line
2.43.5