linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <xiang@kernel.org>
To: Guo Xuenan <guoxuenan@huawei.com>
Cc: xiang@kernel.org, linux-erofs@lists.ozlabs.org, mpiglet@outlook.com
Subject: Re: [PATCH v1 2/5] dump.erofs: add "-s" option to dump superblock information
Date: Sat, 11 Sep 2021 23:58:26 +0800	[thread overview]
Message-ID: <20210911155825.GB3160@hsiangkao-HP-ZHAN-66-Pro-G1> (raw)
In-Reply-To: <20210911134635.1253426-2-guoxuenan@huawei.com>

On Sat, Sep 11, 2021 at 09:46:32PM +0800, Guo Xuenan wrote:
> Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
> Signed-off-by: mpiglet <mpiglet@outlook.com>

Same here.

> ---
>  dump/main.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/dump/main.c b/dump/main.c
> index 8fbc24a..25ac89f 100644
> --- a/dump/main.c
> +++ b/dump/main.c
> @@ -17,6 +17,12 @@
>  #include "erofs/print.h"
>  #include "erofs/io.h"
>  
> +struct dumpcfg {
> +	bool print_superblock;
> +	bool print_version;
> +};
> +static struct dumpcfg dumpcfg;
> +
>  static struct option long_options[] = {
>  	{"help", no_argument, 0, 1},
>  	{0, 0, 0, 0},
> @@ -26,6 +32,7 @@ static void usage(void)
>  {
>  	fputs("usage: [options] erofs-image \n\n"
>  		"Dump erofs layout from erofs-image, and [options] are:\n"
> +		"-s          print information about superblock\n"
>  		"-v/-V      print dump.erofs version info\n"
>  		"-h/--help  display this help and exit\n", stderr);
>  }
> @@ -41,6 +48,9 @@ static int dumpfs_parse_options_cfg(int argc, char **argv)
>  	while ((opt = getopt_long(argc, argv, "sSvVi:I:h",
>  					long_options, NULL)) != -1) {
>  		switch (opt) {
> +		case 's':
> +			dumpcfg.print_superblock = true;
> +			break;
>  		case 'v':
>  		case 'V':
>  			dumpfs_print_version();
> @@ -68,6 +78,39 @@ static int dumpfs_parse_options_cfg(int argc, char **argv)
>  	return 0;
>  }
>  
> +static void dumpfs_print_superblock(void)
> +{
> +	time_t time = sbi.build_time;
> +
> +	fprintf(stderr, "Filesystem magic number:	0x%04X\n", EROFS_SUPER_MAGIC_V1);
> +	fprintf(stderr, "Filesystem blocks: 		%lu\n", sbi.blocks);
> +	fprintf(stderr, "Filesystem meta block:		%u\n", sbi.meta_blkaddr);

Filesystem inode metadata start block:

> +	fprintf(stderr, "Filesystem xattr block:	%u\n", sbi.xattr_blkaddr);

Filesystem shared xattr metadata start block:

> +	fprintf(stderr, "Filesystem root nid:		%ld\n", sbi.root_nid);


> +	fprintf(stderr, "Filesystem valid inos:		%lu\n", sbi.inos);

Inode count:

> +	fprintf(stderr, "Filesystem created:		%s", ctime(&time));
> +	fprintf(stderr, "Filesystem uuid:		");

Filesystem UUID:

How about printing to stdout directly? according to
dumpe2fs:
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/tree/misc/dumpe2fs.c#n219

Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          c46ea44a-e249-446f-af40-xxxxxxxxxxxx
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              8003584
Block count:              32000000
Reserved block count:     1600000
Free blocks:              18661241
Free inodes:              7681550
First block:              0
Block size:               4096
Fragment size:            4096


> +	for (int i = 0; i < 16; i++)
> +		fprintf(stderr, "%02x", sbi.uuid[i]);
> +	fprintf(stderr, "\n");

It seems not the correct UUID style...

> +
> +	if (erofs_sb_has_lz4_0padding())
> +		fprintf(stderr, "Filesystem support lz4 0padding\n");
> +	else
> +		fprintf(stderr, "Filesystem not support lz4 0padding\n");
> +
> +	if (erofs_sb_has_big_pcluster())
> +		fprintf(stderr, "Filesystem support big pcluster\n");
> +	else
> +		fprintf(stderr, "Filesystem not support big pcluster\n");
> +
> +	if (erofs_sb_has_sb_chksum())
> +		fprintf(stderr, "Filesystem has super block checksum feature\n");
> +	else
> +		fprintf(stderr, "Filesystem has no superblock checksum feature\n");

How about showing the features in a list as above?

Thanks,
Gao Xiang

> +
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	int err = 0;
> @@ -80,5 +123,20 @@ int main(int argc, char **argv)
>  		return -1;
>  	}
>  
> +	err = dev_open_ro(cfg.c_img_path);
> +	if (err) {
> +		erofs_err("open image file failed");
> +		return -1;
> +	}
> +
> +	err = erofs_read_superblock();
> +	if (err) {
> +		erofs_err("read superblock failed");
> +		return -1;
> +	}
> +
> +	if (dumpcfg.print_superblock)
> +		dumpfs_print_superblock();
> +
>  	return 0;
>  }
> -- 
> 2.25.4
> 

  reply	other threads:[~2021-09-11 15:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 13:46 [PATCH v1 1/5] erofs-utils: introduce dump.erofs for utils Guo Xuenan
2021-09-11 13:46 ` [PATCH v1 2/5] dump.erofs: add "-s" option to dump superblock information Guo Xuenan
2021-09-11 15:58   ` Gao Xiang [this message]
2021-09-11 13:46 ` [PATCH v1 3/5] dump.erofs: add -S options for collecting statistics of the whole filesystem Guo Xuenan
2021-09-11 16:13   ` Gao Xiang
2021-09-13  4:30     ` Huang Jianan via Linux-erofs
2021-09-13 12:46       ` Gao Xiang
2021-09-14  2:31         ` Guo Xuenan
2021-09-11 13:46 ` [PATCH v1 4/5] dump.erofs: add -i options to dump file information of specific inode number Guo Xuenan
2021-09-11 16:25   ` Gao Xiang
2021-09-11 13:46 ` [PATCH v1 5/5] dump.erofs: add -I options to dump the layout of a particular inode on disk Guo Xuenan
2021-09-11 16:29   ` Gao Xiang
2021-09-11 15:45 ` [PATCH v1 1/5] erofs-utils: introduce dump.erofs for utils Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210911155825.GB3160@hsiangkao-HP-ZHAN-66-Pro-G1 \
    --to=xiang@kernel.org \
    --cc=guoxuenan@huawei.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=mpiglet@outlook.com \
    --subject='Re: [PATCH v1 2/5] dump.erofs: add "-s" option to dump superblock information' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).