erofs-utils: fix `--blobdev=X`
PATCH 1/1 erofs-utils: fix `--blobdev=X`
Create one if the file doesn't exist.
--- lib/blobchunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/blobchunk.c +2 -1
@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile =erofs_tmpfile (); multidev = false; }else { - blobfile =open (blobfile_path,O_WRONLY |O_BINARY ); + blobfile =open (blobfile_path,O_WRONLY |O_CREAT | +O_TRUNC |O_BINARY ,0666 ); multidev = true; }if (blobfile <0 )
Signature · 1 line
2.43.5
Quoted 3 lines · Gao Xiang
Create one if the file doesn't exist.
Fixes b6b741d8daaf ("erofs-utils: lib: get rid of tmpfile()")
I think the real fixes should be Fixes: bbeec3c93076 ("erofs-utils: mkfs: add extra blob device support").
Quoted 10 lines
Signed-off-by Gao Xiang <[email protected]>--- lib/blobchunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/blobchunk.c +0
-0
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) · line 631
Quoted 6 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile =erofs_tmpfile (); multidev = false; }else { - blobfile =open (blobfile_path,O_WRONLY |O_BINARY ); + blobfile =open (blobfile_path,O_WRONLY |O_CREAT | +O_TRUNC |O_BINARY ,0666 );
To maintain consistency, is it better to set the default permission to 0644?
Thanks,
Hongbo
Quoted 3 lines
lib/blobchunk.c +0
-0multidev = true; }if (blobfile <0 )
Hi Hongbo,
Quoted 8 lines · Hongbo Li
Quoted 3 lines · Gao Xiang
Create one if the file doesn't exist.
Fixes b6b741d8daaf ("erofs-utils: lib: get rid of tmpfile()")I think the real fixes should be Fixes:
bbeec3c93076("erofs-utils: mkfs: add extra blob device support").
Prior to b6b741d8daaf, the functionality is ok since fopen(..,"wb") will create the file too.
Quoted 5 lines
Quoted 5 lines
Signed-off-by Gao Xiang <[email protected]>---
lib/blobchunk.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) · line 631
Quoted 11 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
Thanks,
Gao Xiang
Quoted 6 lines · Gao Xiang
Hi Hongbo,
Quoted 3 lines · Hongbo Li
On 2025/4/27 10:15, Gao Xiang wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Create one if the file doesn't exist.
Fixes b6b741d8daaf ("erofs-utils: lib: get rid of tmpfile()")I think the real fixes should be Fixes:
bbeec3c93076("erofs-utils: mkfs: add extra blob device support").Prior to
b6b741d8daaf, the functionality is ok sincefopen(..,"wb")will create the file too.
Sorry, you're right, I misread that.
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Gao Xiang <[email protected]>---
lib/blobchunk.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)Quoted 13 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, · line 632
Quoted 12 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
Quoted 3 lines
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
but 0644 can clearly show which permissions are set (the default umask 022 won't change anything). Or if we need to enforce a specific mode, can we umask to 0 at the beginning instead of relying on the default umask?
By the way, I have another doubt (just occurred to me when seeing O_TRUNC, though it might be unrelated to this change): the chunk-based format can't be used together with the "--increase" option. Should we add a warning for that?
Thanks,
Hongbo
Quoted 2 lines
Thanks,
Gao Xiang
Quoted 3 lines · Hongbo Li
On 2025/4/27 10:56, Gao Xiang wrote:
...
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) · line 631
Quoted 11 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
Quoted 4 lines
Quoted 3 lines
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
but 0644 can clearly show which permissions are set (the default umask 022 won't change anything). Or if we need to enforce a specific mode, can we umask to 0 at the beginning instead of relying on the default umask?
see fopen(3): https://man7.org/linux/man-pages/man3/fopen.3.html
In short, I'd like to change all 0644 to 0666 since there is no reason to mask off other permissions unless umask is also effective.
Or do you have other concerns?
Quoted 2 lines
By the way, I have another doubt (just occurred to me when seeing
O_TRUNC, though it might be unrelated to this change): the chunk-based format can't be used together with the "--increase" option. Should we add a warning for that?
Why?
Thanks,
Gao Xiang
Quoted 6 lines
Thanks,
HongboQuoted 2 lines
Thanks,
Gao Xiang
Hongbo Li
Reviewed-byQuoted 28 lines · Gao Xiang
Quoted 3 lines · Hongbo Li
On 2025/4/27 10:56, Gao Xiang wrote:
...
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, · line 632
Quoted 12 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
Quoted 4 lines
Quoted 3 lines
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
but 0644 can clearly show which permissions are set (the default umask 022 won't change anything). Or if we need to enforce a specific mode, can we umask to 0 at the beginning instead of relying on the default umask?
Quoted 7 lines
see fopen(3): https://man7.org/linux/man-pages/man3/fopen.3.html
In short, I'd like to change all 0644 to 0666 since there is no reason to mask off other permissions unless umask is also effective.
Or do you have other concerns?
ok, I have not other concerns.
Quoted 16 lines
Quoted 3 lines
By the way, I have another doubt (just occurred to me when seeing
O_TRUNC, though it might be unrelated to this change): the chunk-based format can't be used together with the "--increase" option. Should we add a warning for that?Why?
Thanks,
Gao XiangQuoted 6 lines
Thanks,
HongboQuoted 2 lines
Thanks,
Gao Xiang
Quoted 36 lines · Hongbo Li
Quoted 33 lines · Gao Xiang
Quoted 3 lines · Hongbo Li
On 2025/4/27 10:56, Gao Xiang wrote:
...
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) · line 631
Quoted 11 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
Quoted 4 lines
Quoted 3 lines
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
but 0644 can clearly show which permissions are set (the default umask 022 won't change anything). Or if we need to enforce a specific mode, can we umask to 0 at the beginning instead of relying on the default umask?
see fopen(3): https://man7.org/linux/man-pages/man3/fopen.3.html
In short, I'd like to change all 0644 to 0666 since there is no reason to mask off other permissions unless umask is also effective.
Quoted 5 lines
Quoted 1 line
Or do you have other concerns?
ok, I have not other concerns.
Reviewed-by Hongbo Li <[email protected]>
Thanks for the review!
Thanks,
Gao Xiang
Quoted 34 lines · Gao Xiang
Quoted 3 lines · Hongbo Li
On 2025/4/27 10:56, Gao Xiang wrote:
...
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
lib/blobchunk.c int erofs_blob_init(const char *blobfile_path, · line 632
Quoted 12 lines
lib/blobchunk.c +2
-1@@ -627,7 +627,8 @@ int erofs_blob_init(const char *blobfile_path, erofs_off_t chunksize) blobfile = erofs_tmpfile(); multidev = false; } else { - blobfile = open(blobfile_path, O_WRONLY | O_BINARY); + blobfile = open(blobfile_path, O_WRONLY | O_CREAT | + O_TRUNC | O_BINARY, 0666);To maintain consistency, is it better to set the default permission to 0644?
Quoted 4 lines
Quoted 3 lines
I tend to switch all modes to 0666 around the codebase in the future, since umask(022) will mask them into 0644.
but 0644 can clearly show which permissions are set (the default umask 022 won't change anything). Or if we need to enforce a specific mode, can we umask to 0 at the beginning instead of relying on the default umask?
see fopen(3): https://man7.org/linux/man-pages/man3/fopen.3.html
In short, I'd like to change all 0644 to 0666 since there is no reason to mask off other permissions unless umask is also effective.
Quoted 7 lines
Or do you have other concerns?
Quoted 2 lines
By the way, I have another doubt (just occurred to me when seeing
O_TRUNC, though it might be unrelated to this change): the chunk-based format can't be used together with the "--increase" option. Should we add a warning for that?Why?
Because some formatting options cannot be used in combination (such as --blobdev --chunksize --incremental=xxx in non-tar mode). But this might be outside the scope of this patch.
Perhaps we can add the constraints or some explanation to avoid any misunderstanding later. What's about your opinion?
Thanks,
Hongbo
Quoted 10 lines
Thanks,
Gao XiangQuoted 6 lines
Thanks,
HongboQuoted 2 lines
Thanks,
Gao Xiang
Quoted 2 lines · Hongbo Li
...
Quoted 4 lines
Quoted 1 line
Because some formatting options cannot be used in combination (such as --blobdev --chunksize --incremental=xxx in non-tar mode). But this might be outside the scope of this patch.
Perhaps we can add the constraints or some explanation to avoid any misunderstanding later. What's about your opinion?
Okay, I understand.
Yeah, I think they should be explicitly warned out, but they're just unimplemented due to lack of development resource...
Thanks,
Gao Xiang
Quoted 3 lines
Thanks,
Hongbo