linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: mkfs: Add volume-name setting support
@ 2022-10-04 16:02 Naoto Yamaguchi
  2022-10-04 16:15 ` Gao Xiang
  0 siblings, 1 reply; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 16:02 UTC (permalink / raw)
  To: linux-erofs; +Cc: Naoto Yamaguchi

The erofs_super_block has volume_name field.  On the other hand,
mkfs.erofs is not supporting to set volume name.
This patch add volume-name setting support to mkfs.erofs.
Option keyword is similar to mkfs.vfat.

usage:
  mkfs.erofs -n volume-name image-fn dir

Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
---
 include/erofs/internal.h |  1 +
 man/mkfs.erofs.1         |  4 ++++
 mkfs/main.c              | 13 ++++++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 2e0aae8..7dc42eb 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -92,6 +92,7 @@ struct erofs_sb_info {
 	u64 inos;
 
 	u8 uuid[16];
+	char volume_name[16];
 
 	u16 available_compr_algs;
 	u16 lz4_max_distance;
diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
index 11e8323..fb98505 100644
--- a/man/mkfs.erofs.1
+++ b/man/mkfs.erofs.1
@@ -32,6 +32,10 @@ big pcluster feature if needed (Linux v5.13+).
 Specify the level of debugging messages. The default is 2, which shows basic
 warning messages.
 .TP
+.BI "\-n " volume-name
+Set the volume name for the filesystem to volume-name.  The maximum length of
+the volume name is 16 bytes.
+.TP
 .BI "\-x " #
 Specify the upper limit of an xattr which is still inlined. The default is 2.
 Disable storing xattrs if < 0.
diff --git a/mkfs/main.c b/mkfs/main.c
index 594ecf9..613ee46 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -80,6 +80,7 @@ static void usage(void)
 	fputs("usage: [options] FILE DIRECTORY\n\n"
 	      "Generate erofs image from DIRECTORY to FILE, and [options] are:\n"
 	      " -d#                   set output message level to # (maximum 9)\n"
+	      " -n volume-name        set the volume name (max 16 bytes).\n"
 	      " -x#                   set xattr tolerance to # (< 0, disable xattrs; default 2)\n"
 	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
 	      " -C#                   specify the size of compress physical cluster in bytes\n"
@@ -212,7 +213,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 	int opt, i;
 	bool quiet = false;
 
-	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
+	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:n:x:z:",
 				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
@@ -241,6 +242,14 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			cfg.c_dbg_lvl = i;
 			break;
 
+		case 'n':
+			if (optarg == NULL || strlen(optarg) > 16) {
+				erofs_err("invalid volume name");
+				return -EINVAL;
+			}
+			strncpy(sbi.volume_name, optarg, 16);
+			break;
+
 		case 'x':
 			i = strtol(optarg, &endptr, 0);
 			if (*endptr != '\0') {
@@ -255,6 +264,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt)
 				return opt;
 			break;
+
 		case 'T':
 			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
 			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
@@ -483,6 +493,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 	sb.blocks       = cpu_to_le32(*blocks);
 	sb.root_nid     = cpu_to_le16(root_nid);
 	memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
+	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
 
 	if (erofs_sb_has_compr_cfgs())
 		sb.u1.available_compr_algs = sbi.available_compr_algs;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:02 [PATCH] erofs-utils: mkfs: Add volume-name setting support Naoto Yamaguchi
@ 2022-10-04 16:15 ` Gao Xiang
  2022-10-04 16:25   ` Naoto Yamaguchi
  0 siblings, 1 reply; 10+ messages in thread
From: Gao Xiang @ 2022-10-04 16:15 UTC (permalink / raw)
  To: Naoto Yamaguchi; +Cc: Naoto Yamaguchi, linux-erofs

Hi Naoto,

On Wed, Oct 05, 2022 at 01:02:37AM +0900, Naoto Yamaguchi wrote:
> The erofs_super_block has volume_name field.  On the other hand,
> mkfs.erofs is not supporting to set volume name.
> This patch add volume-name setting support to mkfs.erofs.
> Option keyword is similar to mkfs.vfat.
> 
> usage:
>   mkfs.erofs -n volume-name image-fn dir

Thanks for your patch! The patch itself generally looks good to me.


Just two minor ideas:

1) How about following mke2fs by using "-L volume-label" ?
https://www.man7.org/linux/man-pages/man8/mke2fs.8.html

2) If possible, how about adding a kernel ioctl for this if you have
more interest?  I mean FS_IOC_GETFSLABEL.

> 
> Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> ---
>  include/erofs/internal.h |  1 +
>  man/mkfs.erofs.1         |  4 ++++
>  mkfs/main.c              | 13 ++++++++++++-
>  3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/include/erofs/internal.h b/include/erofs/internal.h
> index 2e0aae8..7dc42eb 100644
> --- a/include/erofs/internal.h
> +++ b/include/erofs/internal.h
> @@ -92,6 +92,7 @@ struct erofs_sb_info {
>  	u64 inos;
>  
>  	u8 uuid[16];
> +	char volume_name[16];
>  
>  	u16 available_compr_algs;
>  	u16 lz4_max_distance;
> diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
> index 11e8323..fb98505 100644
> --- a/man/mkfs.erofs.1
> +++ b/man/mkfs.erofs.1
> @@ -32,6 +32,10 @@ big pcluster feature if needed (Linux v5.13+).
>  Specify the level of debugging messages. The default is 2, which shows basic
>  warning messages.
>  .TP
> +.BI "\-n " volume-name
> +Set the volume name for the filesystem to volume-name.  The maximum length of
> +the volume name is 16 bytes.
> +.TP
>  .BI "\-x " #
>  Specify the upper limit of an xattr which is still inlined. The default is 2.
>  Disable storing xattrs if < 0.
> diff --git a/mkfs/main.c b/mkfs/main.c
> index 594ecf9..613ee46 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -80,6 +80,7 @@ static void usage(void)
>  	fputs("usage: [options] FILE DIRECTORY\n\n"
>  	      "Generate erofs image from DIRECTORY to FILE, and [options] are:\n"
>  	      " -d#                   set output message level to # (maximum 9)\n"
> +	      " -n volume-name        set the volume name (max 16 bytes).\n"

...

>  	      " -x#                   set xattr tolerance to # (< 0, disable xattrs; default 2)\n"
>  	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
>  	      " -C#                   specify the size of compress physical cluster in bytes\n"


	      " -L volume-label       set the volume label (maximum 12)\n"

Thanks,
Gao Xiang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:15 ` Gao Xiang
@ 2022-10-04 16:25   ` Naoto Yamaguchi
  2022-10-04 16:33     ` Gao Xiang
  0 siblings, 1 reply; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 16:25 UTC (permalink / raw)
  To: Naoto Yamaguchi, linux-erofs, Naoto Yamaguchi

Hi Gao

Thank you feedback!

>1) How about following mke2fs by using "-L volume-label" ?
>https://www.man7.org/linux/man-pages/man8/mke2fs.8.html

The mkfs.extX is using "-L volume-label".
The mkfs.vfat is using "-n volume-name".
I think both better.
You commented to "-L" is more better, I will change it.

>2) If possible, how about adding a kernel ioctl for this if you have more interest?
>I mean FS_IOC_GETFSLABEL.

It's interesting feature.  I will try to work it.

Thanks,
Naoto Yamaguchi.
a member of Automotive Grade Linux Instrument Cluster EG.

2022年10月5日(水) 1:15 Gao Xiang <xiang@kernel.org>:
>
> Hi Naoto,
>
> On Wed, Oct 05, 2022 at 01:02:37AM +0900, Naoto Yamaguchi wrote:
> > The erofs_super_block has volume_name field.  On the other hand,
> > mkfs.erofs is not supporting to set volume name.
> > This patch add volume-name setting support to mkfs.erofs.
> > Option keyword is similar to mkfs.vfat.
> >
> > usage:
> >   mkfs.erofs -n volume-name image-fn dir
>
> Thanks for your patch! The patch itself generally looks good to me.
>
>
> Just two minor ideas:
>
> 1) How about following mke2fs by using "-L volume-label" ?
> https://www.man7.org/linux/man-pages/man8/mke2fs.8.html
>
> 2) If possible, how about adding a kernel ioctl for this if you have
> more interest?  I mean FS_IOC_GETFSLABEL.
>
> >
> > Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> > ---
> >  include/erofs/internal.h |  1 +
> >  man/mkfs.erofs.1         |  4 ++++
> >  mkfs/main.c              | 13 ++++++++++++-
> >  3 files changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/erofs/internal.h b/include/erofs/internal.h
> > index 2e0aae8..7dc42eb 100644
> > --- a/include/erofs/internal.h
> > +++ b/include/erofs/internal.h
> > @@ -92,6 +92,7 @@ struct erofs_sb_info {
> >       u64 inos;
> >
> >       u8 uuid[16];
> > +     char volume_name[16];
> >
> >       u16 available_compr_algs;
> >       u16 lz4_max_distance;
> > diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
> > index 11e8323..fb98505 100644
> > --- a/man/mkfs.erofs.1
> > +++ b/man/mkfs.erofs.1
> > @@ -32,6 +32,10 @@ big pcluster feature if needed (Linux v5.13+).
> >  Specify the level of debugging messages. The default is 2, which shows basic
> >  warning messages.
> >  .TP
> > +.BI "\-n " volume-name
> > +Set the volume name for the filesystem to volume-name.  The maximum length of
> > +the volume name is 16 bytes.
> > +.TP
> >  .BI "\-x " #
> >  Specify the upper limit of an xattr which is still inlined. The default is 2.
> >  Disable storing xattrs if < 0.
> > diff --git a/mkfs/main.c b/mkfs/main.c
> > index 594ecf9..613ee46 100644
> > --- a/mkfs/main.c
> > +++ b/mkfs/main.c
> > @@ -80,6 +80,7 @@ static void usage(void)
> >       fputs("usage: [options] FILE DIRECTORY\n\n"
> >             "Generate erofs image from DIRECTORY to FILE, and [options] are:\n"
> >             " -d#                   set output message level to # (maximum 9)\n"
> > +           " -n volume-name        set the volume name (max 16 bytes).\n"
>
> ...
>
> >             " -x#                   set xattr tolerance to # (< 0, disable xattrs; default 2)\n"
> >             " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
> >             " -C#                   specify the size of compress physical cluster in bytes\n"
>
>
>               " -L volume-label       set the volume label (maximum 12)\n"
>
> Thanks,
> Gao Xiang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:25   ` Naoto Yamaguchi
@ 2022-10-04 16:33     ` Gao Xiang
  2022-10-04 16:43       ` Naoto Yamaguchi
  0 siblings, 1 reply; 10+ messages in thread
From: Gao Xiang @ 2022-10-04 16:33 UTC (permalink / raw)
  To: Naoto Yamaguchi; +Cc: Naoto Yamaguchi, linux-erofs

On Wed, Oct 05, 2022 at 01:25:48AM +0900, Naoto Yamaguchi wrote:
> Hi Gao
> 
> Thank you feedback!
> 
> >1) How about following mke2fs by using "-L volume-label" ?
> >https://www.man7.org/linux/man-pages/man8/mke2fs.8.html
> 
> The mkfs.extX is using "-L volume-label".
> The mkfs.vfat is using "-n volume-name".
> I think both better.
> You commented to "-L" is more better, I will change it.

Yeah, I tend to follow mke2fs if it has the similar
function if possible, since it's more widely used :)

> 
> >2) If possible, how about adding a kernel ioctl for this if you have more interest?
> >I mean FS_IOC_GETFSLABEL.
> 
> It's interesting feature.  I will try to work it.
> 

Thanks a lot! Yet that is not urgent since 6.1 features are
already fixed, it needs to be landed in 6.2...

Thanks,
Gao Xiang

> Thanks,
> Naoto Yamaguchi.
> a member of Automotive Grade Linux Instrument Cluster EG.
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:33     ` Gao Xiang
@ 2022-10-04 16:43       ` Naoto Yamaguchi
  2022-10-04 16:49         ` Gao Xiang
  0 siblings, 1 reply; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 16:43 UTC (permalink / raw)
  To: linux-erofs; +Cc: Naoto Yamaguchi

The erofs_super_block has volume_name field.  On the other hand,
mkfs.erofs is not supporting to set volume name.
This patch add volume-name setting support to mkfs.erofs.
Option keyword is similar to mkfs.vfat.

usage:
  mkfs.erofs -n volume-name image-fn dir

Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
---
 include/erofs/internal.h |  1 +
 man/mkfs.erofs.1         |  5 +++++
 mkfs/main.c              | 13 ++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 2e0aae8..7dc42eb 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -92,6 +92,7 @@ struct erofs_sb_info {
 	u64 inos;
 
 	u8 uuid[16];
+	char volume_name[16];
 
 	u16 available_compr_algs;
 	u16 lz4_max_distance;
diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
index 11e8323..b65d01b 100644
--- a/man/mkfs.erofs.1
+++ b/man/mkfs.erofs.1
@@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
 more space and the tail part I/O. (Linux v5.17+)
 .RE
 .TP
+.BI "\-L " volume-label
+Set the volume label for the filesystem to
+.IR volume-label .
+The maximum length of the volume label is 16 bytes.
+.TP
 .BI "\-T " #
 Set all files to the given UNIX timestamp. Reproducible builds requires setting
 all to a specific one.
diff --git a/mkfs/main.c b/mkfs/main.c
index 594ecf9..08a4215 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -84,6 +84,7 @@ static void usage(void)
 	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
 	      " -C#                   specify the size of compress physical cluster in bytes\n"
 	      " -EX[,...]             X=extended options\n"
+	      " -L volume-label        set the volume label (max 16 bytes).\n"
 	      " -T#                   set a fixed UNIX timestamp # to all files\n"
 #ifdef HAVE_LIBUUID
 	      " -UX                   use a given filesystem UUID\n"
@@ -212,7 +213,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 	int opt, i;
 	bool quiet = false;
 
-	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
+	while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
 				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
@@ -255,6 +256,15 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt)
 				return opt;
 			break;
+
+		case 'L':
+			if (optarg == NULL || strlen(optarg) > 16) {
+				erofs_err("invalid volume label");
+				return -EINVAL;
+			}
+			strncpy(sbi.volume_name, optarg, 16);
+			break;
+
 		case 'T':
 			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
 			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
@@ -483,6 +493,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 	sb.blocks       = cpu_to_le32(*blocks);
 	sb.root_nid     = cpu_to_le16(root_nid);
 	memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
+	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
 
 	if (erofs_sb_has_compr_cfgs())
 		sb.u1.available_compr_algs = sbi.available_compr_algs;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:43       ` Naoto Yamaguchi
@ 2022-10-04 16:49         ` Gao Xiang
  2022-10-04 17:01           ` [PATCH v3] " Naoto Yamaguchi
  2022-10-04 17:04           ` [PATCH] " Naoto Yamaguchi
  0 siblings, 2 replies; 10+ messages in thread
From: Gao Xiang @ 2022-10-04 16:49 UTC (permalink / raw)
  To: Naoto Yamaguchi; +Cc: Naoto Yamaguchi, linux-erofs

On Wed, Oct 05, 2022 at 01:43:24AM +0900, Naoto Yamaguchi wrote:
> The erofs_super_block has volume_name field.  On the other hand,
> mkfs.erofs is not supporting to set volume name.
> This patch add volume-name setting support to mkfs.erofs.
> Option keyword is similar to mkfs.vfat.
> 
> usage:
>   mkfs.erofs -n volume-name image-fn dir
> 

commit message is not updated... also it'd be better to bump
up the patch version in the subject line like:

[PATCH v2] erofs-utils: mkfs: ...

> Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> ---
>  include/erofs/internal.h |  1 +
>  man/mkfs.erofs.1         |  5 +++++
>  mkfs/main.c              | 13 ++++++++++++-
>  3 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/erofs/internal.h b/include/erofs/internal.h
> index 2e0aae8..7dc42eb 100644
> --- a/include/erofs/internal.h
> +++ b/include/erofs/internal.h
> @@ -92,6 +92,7 @@ struct erofs_sb_info {
>  	u64 inos;
>  
>  	u8 uuid[16];
> +	char volume_name[16];
>  
>  	u16 available_compr_algs;
>  	u16 lz4_max_distance;
> diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
> index 11e8323..b65d01b 100644
> --- a/man/mkfs.erofs.1
> +++ b/man/mkfs.erofs.1
> @@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
>  more space and the tail part I/O. (Linux v5.17+)
>  .RE
>  .TP
> +.BI "\-L " volume-label
> +Set the volume label for the filesystem to
> +.IR volume-label .
> +The maximum length of the volume label is 16 bytes.
> +.TP
>  .BI "\-T " #
>  Set all files to the given UNIX timestamp. Reproducible builds requires setting
>  all to a specific one.
> diff --git a/mkfs/main.c b/mkfs/main.c
> index 594ecf9..08a4215 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -84,6 +84,7 @@ static void usage(void)
>  	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
>  	      " -C#                   specify the size of compress physical cluster in bytes\n"
>  	      " -EX[,...]             X=extended options\n"
> +	      " -L volume-label        set the volume label (max 16 bytes).\n"

Not aligned here.

>  	      " -T#                   set a fixed UNIX timestamp # to all files\n"
>  #ifdef HAVE_LIBUUID
>  	      " -UX                   use a given filesystem UUID\n"
> @@ -212,7 +213,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>  	int opt, i;
>  	bool quiet = false;
>  
> -	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
> +	while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
>  				  long_options, NULL)) != -1) {
>  		switch (opt) {
>  		case 'z':
> @@ -255,6 +256,15 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>  			if (opt)
>  				return opt;
>  			break;
> +
> +		case 'L':
> +			if (optarg == NULL || strlen(optarg) > 16) {

					sizeof(sbi.volume_name);

> +				erofs_err("invalid volume label");
> +				return -EINVAL;
> +			}
> +			strncpy(sbi.volume_name, optarg, 16);

						sizeof(sbi.volume_name)?


Thanks,
Gao Xiang

> +			break;
> +
>  		case 'T':
>  			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
>  			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
> @@ -483,6 +493,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
>  	sb.blocks       = cpu_to_le32(*blocks);
>  	sb.root_nid     = cpu_to_le16(root_nid);
>  	memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
> +	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
>  
>  	if (erofs_sb_has_compr_cfgs())
>  		sb.u1.available_compr_algs = sbi.available_compr_algs;
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:49         ` Gao Xiang
@ 2022-10-04 17:01           ` Naoto Yamaguchi
  2022-10-04 17:04           ` [PATCH] " Naoto Yamaguchi
  1 sibling, 0 replies; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 17:01 UTC (permalink / raw)
  To: linux-erofs; +Cc: Naoto Yamaguchi

The erofs_super_block has volume_name field.  On the other hand,
mkfs.erofs is not supporting to set volume name.
This patch add volume-name setting support to mkfs.erofs.
Option keyword is similar to mkfs.vfat.

usage:
  mkfs.erofs -L volume-label image-fn dir

Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
---
 include/erofs/internal.h |  1 +
 man/mkfs.erofs.1         |  5 +++++
 mkfs/main.c              | 13 ++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 2e0aae8..7dc42eb 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -92,6 +92,7 @@ struct erofs_sb_info {
 	u64 inos;
 
 	u8 uuid[16];
+	char volume_name[16];
 
 	u16 available_compr_algs;
 	u16 lz4_max_distance;
diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
index 11e8323..b65d01b 100644
--- a/man/mkfs.erofs.1
+++ b/man/mkfs.erofs.1
@@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
 more space and the tail part I/O. (Linux v5.17+)
 .RE
 .TP
+.BI "\-L " volume-label
+Set the volume label for the filesystem to
+.IR volume-label .
+The maximum length of the volume label is 16 bytes.
+.TP
 .BI "\-T " #
 Set all files to the given UNIX timestamp. Reproducible builds requires setting
 all to a specific one.
diff --git a/mkfs/main.c b/mkfs/main.c
index 594ecf9..08a4215 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -84,6 +84,7 @@ static void usage(void)
 	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
 	      " -C#                   specify the size of compress physical cluster in bytes\n"
 	      " -EX[,...]             X=extended options\n"
+	      " -L volume-label        set the volume label (max 16 bytes).\n"
 	      " -T#                   set a fixed UNIX timestamp # to all files\n"
 #ifdef HAVE_LIBUUID
 	      " -UX                   use a given filesystem UUID\n"
@@ -212,7 +213,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 	int opt, i;
 	bool quiet = false;
 
-	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
+	while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
 				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
@@ -255,6 +256,15 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt)
 				return opt;
 			break;
+
+		case 'L':
+			if (optarg == NULL || strlen(optarg) > 16) {
+				erofs_err("invalid volume label");
+				return -EINVAL;
+			}
+			strncpy(sbi.volume_name, optarg, 16);
+			break;
+
 		case 'T':
 			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
 			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
@@ -483,6 +493,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 	sb.blocks       = cpu_to_le32(*blocks);
 	sb.root_nid     = cpu_to_le16(root_nid);
 	memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
+	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
 
 	if (erofs_sb_has_compr_cfgs())
 		sb.u1.available_compr_algs = sbi.available_compr_algs;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 16:49         ` Gao Xiang
  2022-10-04 17:01           ` [PATCH v3] " Naoto Yamaguchi
@ 2022-10-04 17:04           ` Naoto Yamaguchi
  2022-10-04 17:54             ` Gao Xiang
  1 sibling, 1 reply; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 17:04 UTC (permalink / raw)
  To: Naoto Yamaguchi, linux-erofs, Naoto Yamaguchi

Hi Gao

Sorry I'm missing subject and commit message.
I inclement and fix commit message.

Thanks,
Naoto Yamaguchi.
a member of Automotive Grade Linux Instrument Cluster EG.

2022年10月5日(水) 1:49 Gao Xiang <xiang@kernel.org>:
>
> On Wed, Oct 05, 2022 at 01:43:24AM +0900, Naoto Yamaguchi wrote:
> > The erofs_super_block has volume_name field.  On the other hand,
> > mkfs.erofs is not supporting to set volume name.
> > This patch add volume-name setting support to mkfs.erofs.
> > Option keyword is similar to mkfs.vfat.
> >
> > usage:
> >   mkfs.erofs -n volume-name image-fn dir
> >
>
> commit message is not updated... also it'd be better to bump
> up the patch version in the subject line like:
>
> [PATCH v2] erofs-utils: mkfs: ...
>
> > Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> > ---
> >  include/erofs/internal.h |  1 +
> >  man/mkfs.erofs.1         |  5 +++++
> >  mkfs/main.c              | 13 ++++++++++++-
> >  3 files changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/erofs/internal.h b/include/erofs/internal.h
> > index 2e0aae8..7dc42eb 100644
> > --- a/include/erofs/internal.h
> > +++ b/include/erofs/internal.h
> > @@ -92,6 +92,7 @@ struct erofs_sb_info {
> >       u64 inos;
> >
> >       u8 uuid[16];
> > +     char volume_name[16];
> >
> >       u16 available_compr_algs;
> >       u16 lz4_max_distance;
> > diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
> > index 11e8323..b65d01b 100644
> > --- a/man/mkfs.erofs.1
> > +++ b/man/mkfs.erofs.1
> > @@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
> >  more space and the tail part I/O. (Linux v5.17+)
> >  .RE
> >  .TP
> > +.BI "\-L " volume-label
> > +Set the volume label for the filesystem to
> > +.IR volume-label .
> > +The maximum length of the volume label is 16 bytes.
> > +.TP
> >  .BI "\-T " #
> >  Set all files to the given UNIX timestamp. Reproducible builds requires setting
> >  all to a specific one.
> > diff --git a/mkfs/main.c b/mkfs/main.c
> > index 594ecf9..08a4215 100644
> > --- a/mkfs/main.c
> > +++ b/mkfs/main.c
> > @@ -84,6 +84,7 @@ static void usage(void)
> >             " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
> >             " -C#                   specify the size of compress physical cluster in bytes\n"
> >             " -EX[,...]             X=extended options\n"
> > +           " -L volume-label        set the volume label (max 16 bytes).\n"
>
> Not aligned here.
>
> >             " -T#                   set a fixed UNIX timestamp # to all files\n"
> >  #ifdef HAVE_LIBUUID
> >             " -UX                   use a given filesystem UUID\n"
> > @@ -212,7 +213,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
> >       int opt, i;
> >       bool quiet = false;
> >
> > -     while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
> > +     while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
> >                                 long_options, NULL)) != -1) {
> >               switch (opt) {
> >               case 'z':
> > @@ -255,6 +256,15 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
> >                       if (opt)
> >                               return opt;
> >                       break;
> > +
> > +             case 'L':
> > +                     if (optarg == NULL || strlen(optarg) > 16) {
>
>                                         sizeof(sbi.volume_name);
>
> > +                             erofs_err("invalid volume label");
> > +                             return -EINVAL;
> > +                     }
> > +                     strncpy(sbi.volume_name, optarg, 16);
>
>                                                 sizeof(sbi.volume_name)?
>
>
> Thanks,
> Gao Xiang
>
> > +                     break;
> > +
> >               case 'T':
> >                       cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
> >                       if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
> > @@ -483,6 +493,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
> >       sb.blocks       = cpu_to_le32(*blocks);
> >       sb.root_nid     = cpu_to_le16(root_nid);
> >       memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
> > +     memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
> >
> >       if (erofs_sb_has_compr_cfgs())
> >               sb.u1.available_compr_algs = sbi.available_compr_algs;
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 17:04           ` [PATCH] " Naoto Yamaguchi
@ 2022-10-04 17:54             ` Gao Xiang
  2022-10-04 21:33               ` Naoto Yamaguchi
  0 siblings, 1 reply; 10+ messages in thread
From: Gao Xiang @ 2022-10-04 17:54 UTC (permalink / raw)
  To: Naoto Yamaguchi; +Cc: Naoto Yamaguchi, linux-erofs

Hi Naoto,

On Wed, Oct 05, 2022 at 02:04:39AM +0900, Naoto Yamaguchi wrote:
> Hi Gao
> 
> Sorry I'm missing subject and commit message.
> I inclement and fix commit message.
> 

I've fixed some minor stuffs as below, please help check if it looks
good to you so that I could apply this version then.

Thanks,
Gao Xiang

> Thanks,
> Naoto Yamaguchi.
> a member of Automotive Grade Linux Instrument Cluster EG.
> 

From b1114ba7b3acfc60c9ab5a707f0a5f38eb4ac825 Mon Sep 17 00:00:00 2001
From: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
Date: Wed, 5 Oct 2022 02:01:15 +0900
Subject: [PATCH] erofs-utils: mkfs: Add volume-label setting support

The on-disk erofs_super_block has the volume_name field.  On the other
hand, mkfs.erofs doesn't support setting volume label.

This patch adds volume-label setting support to mkfs.erofs.
Option keyword is similar to mke2fs.

Usage:
  mkfs.erofs -L volume-label image-fn dir

Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 include/erofs/internal.h |  1 +
 man/mkfs.erofs.1         |  5 +++++
 mkfs/main.c              | 15 ++++++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index db7ac2d..13c691b 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -94,6 +94,7 @@ struct erofs_sb_info {
 	u64 inos;
 
 	u8 uuid[16];
+	char volume_name[16];
 
 	u16 available_compr_algs;
 	u16 lz4_max_distance;
diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
index 11e8323..b65d01b 100644
--- a/man/mkfs.erofs.1
+++ b/man/mkfs.erofs.1
@@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
 more space and the tail part I/O. (Linux v5.17+)
 .RE
 .TP
+.BI "\-L " volume-label
+Set the volume label for the filesystem to
+.IR volume-label .
+The maximum length of the volume label is 16 bytes.
+.TP
 .BI "\-T " #
 Set all files to the given UNIX timestamp. Reproducible builds requires setting
 all to a specific one.
diff --git a/mkfs/main.c b/mkfs/main.c
index 8b97796..00a2deb 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -86,6 +86,7 @@ static void usage(void)
 	      " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
 	      " -C#                   specify the size of compress physical cluster in bytes\n"
 	      " -EX[,...]             X=extended options\n"
+	      " -L volume-label       set the volume label (maximum 16)\n"
 	      " -T#                   set a fixed UNIX timestamp # to all files\n"
 #ifdef HAVE_LIBUUID
 	      " -UX                   use a given filesystem UUID\n"
@@ -237,7 +238,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 	int opt, i;
 	bool quiet = false;
 
-	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
+	while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
 				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
@@ -280,6 +281,17 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt)
 				return opt;
 			break;
+
+		case 'L':
+			if (optarg == NULL ||
+			    strlen(optarg) > sizeof(sbi.volume_name)) {
+				erofs_err("invalid volume label");
+				return -EINVAL;
+			}
+			strncpy(sbi.volume_name, optarg,
+				sizeof(sbi.volume_name));
+			break;
+
 		case 'T':
 			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
 			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
@@ -510,6 +522,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 	sb.root_nid     = cpu_to_le16(root_nid);
 	sb.packed_nid    = cpu_to_le64(packed_nid);
 	memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
+	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
 
 	if (erofs_sb_has_compr_cfgs())
 		sb.u1.available_compr_algs = sbi.available_compr_algs;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] erofs-utils: mkfs: Add volume-name setting support
  2022-10-04 17:54             ` Gao Xiang
@ 2022-10-04 21:33               ` Naoto Yamaguchi
  0 siblings, 0 replies; 10+ messages in thread
From: Naoto Yamaguchi @ 2022-10-04 21:33 UTC (permalink / raw)
  To: Naoto Yamaguchi, linux-erofs, Naoto Yamaguchi

Hi Gao

Thank you follow up.

Good for this patch.  I agree to this update.

Thanks,
Naoto Yamaguchi.
a member of Automotive Grade Linux Instrument Cluster EG.

2022年10月5日(水) 2:54 Gao Xiang <xiang@kernel.org>:
>
> Hi Naoto,
>
> On Wed, Oct 05, 2022 at 02:04:39AM +0900, Naoto Yamaguchi wrote:
> > Hi Gao
> >
> > Sorry I'm missing subject and commit message.
> > I inclement and fix commit message.
> >
>
> I've fixed some minor stuffs as below, please help check if it looks
> good to you so that I could apply this version then.
>
> Thanks,
> Gao Xiang
>
> > Thanks,
> > Naoto Yamaguchi.
> > a member of Automotive Grade Linux Instrument Cluster EG.
> >
>
> From b1114ba7b3acfc60c9ab5a707f0a5f38eb4ac825 Mon Sep 17 00:00:00 2001
> From: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> Date: Wed, 5 Oct 2022 02:01:15 +0900
> Subject: [PATCH] erofs-utils: mkfs: Add volume-label setting support
>
> The on-disk erofs_super_block has the volume_name field.  On the other
> hand, mkfs.erofs doesn't support setting volume label.
>
> This patch adds volume-label setting support to mkfs.erofs.
> Option keyword is similar to mke2fs.
>
> Usage:
>   mkfs.erofs -L volume-label image-fn dir
>
> Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
>  include/erofs/internal.h |  1 +
>  man/mkfs.erofs.1         |  5 +++++
>  mkfs/main.c              | 15 ++++++++++++++-
>  3 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/include/erofs/internal.h b/include/erofs/internal.h
> index db7ac2d..13c691b 100644
> --- a/include/erofs/internal.h
> +++ b/include/erofs/internal.h
> @@ -94,6 +94,7 @@ struct erofs_sb_info {
>         u64 inos;
>
>         u8 uuid[16];
> +       char volume_name[16];
>
>         u16 available_compr_algs;
>         u16 lz4_max_distance;
> diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1
> index 11e8323..b65d01b 100644
> --- a/man/mkfs.erofs.1
> +++ b/man/mkfs.erofs.1
> @@ -66,6 +66,11 @@ Pack the tail part (pcluster) of compressed files into its metadata to save
>  more space and the tail part I/O. (Linux v5.17+)
>  .RE
>  .TP
> +.BI "\-L " volume-label
> +Set the volume label for the filesystem to
> +.IR volume-label .
> +The maximum length of the volume label is 16 bytes.
> +.TP
>  .BI "\-T " #
>  Set all files to the given UNIX timestamp. Reproducible builds requires setting
>  all to a specific one.
> diff --git a/mkfs/main.c b/mkfs/main.c
> index 8b97796..00a2deb 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -86,6 +86,7 @@ static void usage(void)
>               " -zX[,Y]               X=compressor (Y=compression level, optional)\n"
>               " -C#                   specify the size of compress physical cluster in bytes\n"
>               " -EX[,...]             X=extended options\n"
> +             " -L volume-label       set the volume label (maximum 16)\n"
>               " -T#                   set a fixed UNIX timestamp # to all files\n"
>  #ifdef HAVE_LIBUUID
>               " -UX                   use a given filesystem UUID\n"
> @@ -237,7 +238,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>         int opt, i;
>         bool quiet = false;
>
> -       while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
> +       while ((opt = getopt_long(argc, argv, "C:E:L:T:U:d:x:z:",
>                                   long_options, NULL)) != -1) {
>                 switch (opt) {
>                 case 'z':
> @@ -280,6 +281,17 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>                         if (opt)
>                                 return opt;
>                         break;
> +
> +               case 'L':
> +                       if (optarg == NULL ||
> +                           strlen(optarg) > sizeof(sbi.volume_name)) {
> +                               erofs_err("invalid volume label");
> +                               return -EINVAL;
> +                       }
> +                       strncpy(sbi.volume_name, optarg,
> +                               sizeof(sbi.volume_name));
> +                       break;
> +
>                 case 'T':
>                         cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
>                         if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
> @@ -510,6 +522,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
>         sb.root_nid     = cpu_to_le16(root_nid);
>         sb.packed_nid    = cpu_to_le64(packed_nid);
>         memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid));
> +       memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
>
>         if (erofs_sb_has_compr_cfgs())
>                 sb.u1.available_compr_algs = sbi.available_compr_algs;
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-04 21:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 16:02 [PATCH] erofs-utils: mkfs: Add volume-name setting support Naoto Yamaguchi
2022-10-04 16:15 ` Gao Xiang
2022-10-04 16:25   ` Naoto Yamaguchi
2022-10-04 16:33     ` Gao Xiang
2022-10-04 16:43       ` Naoto Yamaguchi
2022-10-04 16:49         ` Gao Xiang
2022-10-04 17:01           ` [PATCH v3] " Naoto Yamaguchi
2022-10-04 17:04           ` [PATCH] " Naoto Yamaguchi
2022-10-04 17:54             ` Gao Xiang
2022-10-04 21:33               ` Naoto Yamaguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).