All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] Add an option to only dump/fsck an inode by path
@ 2021-12-01 21:48 Kelvin Zhang via Linux-erofs
  2021-12-02  1:29 ` Gao Xiang
  2021-12-06 13:35 ` [PATCH v2] erofs-utils: add an option to dump " Gao Xiang
  0 siblings, 2 replies; 4+ messages in thread
From: Kelvin Zhang via Linux-erofs @ 2021-12-01 21:48 UTC (permalink / raw)
  To: linux-erofs mailing list, Miao Xie, Fang Wei; +Cc: Kelvin Zhang

This is useful when playing around with EROFS images locally. For
example, it allows us to inspect block mappings of a filepath.

Change-Id: Iac1aebba5d510dd3d4f38e65d4056ea9ac9871bb
Signed-off-by: Kelvin Zhang <zhangkelvin@google.com>
---
 dump/main.c | 15 ++++++++++++++-
 fsck/main.c | 16 +++++++++++++++-
 mkfs/main.c |  7 +++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index b7560ec..dcf577e 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include <time.h>
+#include "erofs/internal.h"
 #include "erofs/print.h"
 #include "erofs/inode.h"
 #include "erofs/io.h"
@@ -23,6 +24,7 @@ struct erofsdump_cfg {
 	bool show_superblock;
 	bool show_statistics;
 	erofs_nid_t nid;
+	const char *inode_path;
 };
 static struct erofsdump_cfg dumpcfg;
 
@@ -71,6 +73,7 @@ static struct option long_options[] = {
 	{"help", no_argument, NULL, 1},
 	{"nid", required_argument, NULL, 2},
 	{"device", required_argument, NULL, 3},
+	{"path", required_argument, NULL, 4},
 	{0, 0, 0, 0},
 };
 
@@ -103,6 +106,7 @@ static void usage(void)
 	      " -s              show information about superblock\n"
 	      " --device=X      specify an extra device to be used together\n"
 	      " --nid=#         show the target inode info of nid #\n"
+	      " --path=str      show the target inode info of path\n"
 	      " --help          display this help and exit.\n",
 	      stderr);
 }
@@ -148,6 +152,10 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
 				return err;
 			++sbi.extra_devices;
 			break;
+		case 4:
+			dumpcfg.inode_path = optarg;
+			dumpcfg.show_inode = true;
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -449,7 +457,12 @@ static void erofsdump_show_fileinfo(bool show_extent)
 		.m_la = 0,
 	};
 
-	err = erofs_read_inode_from_disk(&inode);
+	if (dumpcfg.inode_path) {
+		err = erofs_ilookup(dumpcfg.inode_path, &inode);
+	} else {
+		err = erofs_read_inode_from_disk(&inode);
+	}
+
 	if (err) {
 		erofs_err("read inode failed @ nid %llu", inode.nid | 0ULL);
 		return;
diff --git a/fsck/main.c b/fsck/main.c
index aefa881..ecdd0bf 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include <time.h>
+#include "erofs/internal.h"
 #include "erofs/print.h"
 #include "erofs/io.h"
 #include "erofs/decompress.h"
@@ -18,6 +19,7 @@ struct erofsfsck_cfg {
 	bool check_decomp;
 	u64 physical_blocks;
 	u64 logical_blocks;
+	const char *inode_path;
 };
 static struct erofsfsck_cfg fsckcfg;
 
@@ -25,6 +27,7 @@ static struct option long_options[] = {
 	{"help", no_argument, 0, 1},
 	{"extract", no_argument, 0, 2},
 	{"device", required_argument, 0, 3},
+	{"path", required_argument, 0, 4},
 	{0, 0, 0, 0},
 };
 
@@ -37,6 +40,7 @@ static void usage(void)
 	      " -p              print total compression ratio of all files\n"
 	      " --device=X      specify an extra device to be used together\n"
 	      " --extract       check if all files are well encoded\n"
+	      " --path					check if a specific file well encoded\n"
 	      " --help          display this help and exit.\n",
 	      stderr);
 }
@@ -79,6 +83,10 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
 				return ret;
 			++sbi.extra_devices;
 			break;
+		case 4:
+			fsckcfg.inode_path = optarg;
+			fsckcfg.check_decomp = true;
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -582,7 +590,13 @@ int main(int argc, char **argv)
 		goto exit_dev_close;
 	}
 
-	erofs_check_inode(sbi.root_nid, sbi.root_nid);
+	if (fsckcfg.inode_path) {
+		struct erofs_inode inode;
+		erofs_ilookup(fsckcfg.inode_path, &inode);
+		erofs_verify_inode_data(&inode);
+	} else {
+		erofs_check_inode(sbi.root_nid, sbi.root_nid);
+	}
 
 	if (fsckcfg.corrupted) {
 		erofs_err("Found some filesystem corruption");
diff --git a/mkfs/main.c b/mkfs/main.c
index 58a6441..d6bc7dd 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -24,6 +24,13 @@
 #include "erofs/compress_hints.h"
 #include "erofs/blobchunk.h"
 
+#ifdef WITH_ANDROID
+#include <selinux/android.h>
+#include <private/android_filesystem_config.h>
+#include <private/canned_fs_config.h>
+#include <private/fs_config.h>
+#endif
+
 #ifdef HAVE_LIBUUID
 #include <uuid.h>
 #endif
-- 
2.34.0.rc2.393.gf8c9666880-goog


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

* Re: [PATCH v1] Add an option to only dump/fsck an inode by path
  2021-12-01 21:48 [PATCH v1] Add an option to only dump/fsck an inode by path Kelvin Zhang via Linux-erofs
@ 2021-12-02  1:29 ` Gao Xiang
  2021-12-06 13:35 ` [PATCH v2] erofs-utils: add an option to dump " Gao Xiang
  1 sibling, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2021-12-02  1:29 UTC (permalink / raw)
  To: Kelvin Zhang; +Cc: Miao Xie, linux-erofs mailing list

Hi,

On Wed, Dec 01, 2021 at 01:48:02PM -0800, Kelvin Zhang wrote:

...

I will check this main patchset later..
Working on another stuff now.

> diff --git a/mkfs/main.c b/mkfs/main.c
> index 58a6441..d6bc7dd 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -24,6 +24,13 @@
>  #include "erofs/compress_hints.h"
>  #include "erofs/blobchunk.h"
>  
> +#ifdef WITH_ANDROID
> +#include <selinux/android.h>
> +#include <private/android_filesystem_config.h>
> +#include <private/canned_fs_config.h>
> +#include <private/fs_config.h>
> +#endif

I planned to add
#include "../lib/liberofs_private.h" instead in the previous patch.

Please help check if any other regression out of Android build...

Thanks,
Gao Xiang

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

* [PATCH v2] erofs-utils: add an option to dump an inode by path
  2021-12-01 21:48 [PATCH v1] Add an option to only dump/fsck an inode by path Kelvin Zhang via Linux-erofs
  2021-12-02  1:29 ` Gao Xiang
@ 2021-12-06 13:35 ` Gao Xiang
  2021-12-07 14:05   ` [PATCH v3] " Gao Xiang
  1 sibling, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2021-12-06 13:35 UTC (permalink / raw)
  To: linux-erofs; +Cc: Kelvin Zhang, Gao Xiang

From: Kelvin Zhang <zhangkelvin@google.com>

This is useful when playing around with EROFS images locally.
For example, it allows us to inspect block mappings of a filepath.

Signed-off-by: Kelvin Zhang <zhangkelvin@google.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
Hi Kelvin,

I plan to apply the following path, since it's somewhat weird to just
fsck a specific path. Also I completed the manpage and fix some minor
issues.

Thanks,
Gao Xiang

 dump/main.c      | 14 +++++++++++++-
 man/dump.erofs.1 |  3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dump/main.c b/dump/main.c
index f85903b059d2..b8ee88761ff0 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -23,6 +23,7 @@ struct erofsdump_cfg {
 	bool show_superblock;
 	bool show_statistics;
 	erofs_nid_t nid;
+	const char *inode_path;
 };
 static struct erofsdump_cfg dumpcfg;
 
@@ -71,6 +72,7 @@ static struct option long_options[] = {
 	{"help", no_argument, NULL, 1},
 	{"nid", required_argument, NULL, 2},
 	{"device", required_argument, NULL, 3},
+	{"path", required_argument, NULL, 4},
 	{0, 0, 0, 0},
 };
 
@@ -103,6 +105,7 @@ static void usage(void)
 	      " -s              show information about superblock\n"
 	      " --device=X      specify an extra device to be used together\n"
 	      " --nid=#         show the target inode info of nid #\n"
+	      " --path=X        show the target inode info of path X\n"
 	      " --help          display this help and exit.\n",
 	      stderr);
 }
@@ -148,6 +151,11 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
 				return err;
 			++sbi.extra_devices;
 			break;
+		case 4:
+			dumpcfg.inode_path = optarg;
+			dumpcfg.show_inode = true;
+			++dumpcfg.totalshow;
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -450,7 +458,11 @@ static void erofsdump_show_fileinfo(bool show_extent)
 		.m_la = 0,
 	};
 
-	err = erofs_read_inode_from_disk(&inode);
+	if (dumpcfg.inode_path)
+		err = erofs_ilookup(dumpcfg.inode_path, &inode);
+	else
+		err = erofs_read_inode_from_disk(&inode);
+
 	if (err) {
 		erofs_err("read inode failed @ nid %llu", inode.nid | 0ULL);
 		return;
diff --git a/man/dump.erofs.1 b/man/dump.erofs.1
index 8efb161b65f1..fd437cfcc250 100644
--- a/man/dump.erofs.1
+++ b/man/dump.erofs.1
@@ -22,6 +22,9 @@ You may give multiple `--device' options in the correct order.
 .BI "\-\-nid=" NID
 Specify an inode NID in order to print its file information.
 .TP
+.BI "\-\-path=" path
+Specify an inode path in order to print its file information.
+.TP
 .BI \-e
 Show the file extent information. The option depends on option --nid to specify NID.
 .TP
-- 
2.24.4


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

* [PATCH v3] erofs-utils: add an option to dump an inode by path
  2021-12-06 13:35 ` [PATCH v2] erofs-utils: add an option to dump " Gao Xiang
@ 2021-12-07 14:05   ` Gao Xiang
  0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2021-12-07 14:05 UTC (permalink / raw)
  To: linux-erofs; +Cc: Kelvin Zhang, Gao Xiang

From: Kelvin Zhang <zhangkelvin@google.com>

This is useful when playing around with EROFS images locally.
For example, it allows us to inspect block mappings of a filepath.

Signed-off-by: Kelvin Zhang <zhangkelvin@google.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
changes since v2:
 - use different failure message for path.

 dump/main.c      | 25 +++++++++++++++++++++----
 man/dump.erofs.1 |  3 +++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index f85903b059d2..072d726da71b 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -23,6 +23,7 @@ struct erofsdump_cfg {
 	bool show_superblock;
 	bool show_statistics;
 	erofs_nid_t nid;
+	const char *inode_path;
 };
 static struct erofsdump_cfg dumpcfg;
 
@@ -71,6 +72,7 @@ static struct option long_options[] = {
 	{"help", no_argument, NULL, 1},
 	{"nid", required_argument, NULL, 2},
 	{"device", required_argument, NULL, 3},
+	{"path", required_argument, NULL, 4},
 	{0, 0, 0, 0},
 };
 
@@ -103,6 +105,7 @@ static void usage(void)
 	      " -s              show information about superblock\n"
 	      " --device=X      specify an extra device to be used together\n"
 	      " --nid=#         show the target inode info of nid #\n"
+	      " --path=X        show the target inode info of path X\n"
 	      " --help          display this help and exit.\n",
 	      stderr);
 }
@@ -148,6 +151,11 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
 				return err;
 			++sbi.extra_devices;
 			break;
+		case 4:
+			dumpcfg.inode_path = optarg;
+			dumpcfg.show_inode = true;
+			++dumpcfg.totalshow;
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -450,10 +458,19 @@ static void erofsdump_show_fileinfo(bool show_extent)
 		.m_la = 0,
 	};
 
-	err = erofs_read_inode_from_disk(&inode);
-	if (err) {
-		erofs_err("read inode failed @ nid %llu", inode.nid | 0ULL);
-		return;
+	if (dumpcfg.inode_path) {
+		err = erofs_ilookup(dumpcfg.inode_path, &inode);
+		if (err) {
+			erofs_err("read inode failed @ %s", dumpcfg.inode_path);
+			return;
+		}
+	} else {
+		err = erofs_read_inode_from_disk(&inode);
+		if (err) {
+			erofs_err("read inode failed @ nid %llu",
+				  inode.nid | 0ULL);
+			return;
+		}
 	}
 
 	err = erofs_get_occupied_size(&inode, &size);
diff --git a/man/dump.erofs.1 b/man/dump.erofs.1
index 8efb161b65f1..fd437cfcc250 100644
--- a/man/dump.erofs.1
+++ b/man/dump.erofs.1
@@ -22,6 +22,9 @@ You may give multiple `--device' options in the correct order.
 .BI "\-\-nid=" NID
 Specify an inode NID in order to print its file information.
 .TP
+.BI "\-\-path=" path
+Specify an inode path in order to print its file information.
+.TP
 .BI \-e
 Show the file extent information. The option depends on option --nid to specify NID.
 .TP
-- 
2.24.4


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

end of thread, other threads:[~2021-12-07 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 21:48 [PATCH v1] Add an option to only dump/fsck an inode by path Kelvin Zhang via Linux-erofs
2021-12-02  1:29 ` Gao Xiang
2021-12-06 13:35 ` [PATCH v2] erofs-utils: add an option to dump " Gao Xiang
2021-12-07 14:05   ` [PATCH v3] " Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.