xfs_db: add command to copy out files
cover xfs_db: add command to copy out files
Hi all,
This patchset adds a new xfs_db command that enables users to copy out files from a block device to a specified destination.
Comments and feedback appreciated!
Catherine
Catherine Hoang (2):
xfs_db: create header file for directory iteration code
xfs_db: add a directory copy command
db/Makefile | 4 +- db/command.c | 1 + db/command.h | 1 + db/copyout.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++ db/namei.c | 48 ++++--- db/namei.h | 13 ++ man/man8/xfs_db.8 | 7 + 7 files changed, 373 insertions(+), 21 deletions(-) create mode 100644 db/copyout.c create mode 100644 db/namei.h
Signature · 1 line
2.34.1
PATCH 1/2 xfs_db: create header file for directory iteration code
Create a namei.h header so that we can export functions needed to walk a directory. This will be used in the next patch to recursively list directory entries.
--- db/Makefile | 4 ++-- db/namei.c | 48 +++++++++++++++++++++++++++++------------------- db/namei.h | 13 +++++++++++++ 3 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 db/namei.h
db/Makefile +2 -2
@@ -11,10 +11,10 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ btblock.h bmroot.h check.h command.h crc.h debug.h \ dir2.h dir2sf.h dquot.h echo.h faddr.h field.h \ flist.h fprint.h frag.h freesp.h hash.h help.h init.h inode.h input.h \ - io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \ + io.h logformat.h malloc.h metadump.h namei.h output.h print.h quit.h sb.h \ sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \ fuzz.h -CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c info.c namei.c \ +CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c info.c \ timelimit.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
db/namei.c +29 -19
139 lines not on this page · raw message
db/namei.h new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2023 Oracle. +* All Rights Reserved. +*/ + +typedef void (*list_dir_fn )(struct xfs_mount *mp,xfs_dir2_dataptr_t off, +char *name,ssize_t namelen,xfs_ino_t inode,uint8_t dtype, +void *priv); + +extern void namei_init (void ); +extern int listdir (struct xfs_inode *dp,list_dir_fn list_fn,void *priv); +extern int path_walk (char * path);
Signature · 1 line
2.34.1
PATCH 2/2 xfs_db: add a directory copy command
In reply to Catherine HoangAdd support for a command to recursively copy files from a block device to the native filesystem.
--- db/Makefile | 2 +- db/command.c | 1 + db/command.h | 1 + db/copyout.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 7 + 5 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 db/copyout.c
db/Makefile +1 -1
@@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ io.h logformat.h malloc.h metadump.h namei.h output.h print.h quit.h sb.h \ sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \ fuzz.h -CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c info.c \ +CFILES = $(HFILES:.h=.c) btdump.c btheight.c convert.c copyout.c info.c \ timelimit.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
db/command.c +1 -0
@@ -116,6 +116,7 @@ init_commands(void)btheight_init ();check_init ();convert_init (); +copyout_init ();crc_init ();debug_init ();echo_init ();
db/command.h +1 -0
@@ -34,3 +34,4 @@ extern void info_init(void);extern void btheight_init (void );extern void timelimit_init (void );extern void namei_init (void ); +extern void copyout_init (void );
db/copyout.c new file +320 -0
320 lines not on this page · raw message
man/man8/xfs_db.8 +7 -0
@@ -579,6 +579,13 @@ print the current debug option bits. These are for the use of the implementor. .BI "dquot [" \-g | \-p | \-u ] " id" Set current address to a group, project or user quota block for the given ID. Defaults to user quota. .TP +.BI "copyout [" directories ] " destination" +Recursively copy one or more +.IR directories +from an XFS filesystem to the named +.IR destination , +which should be an existing directory on the native file system. +.TP .BI "echo [" arg "] ..." Echo the arguments to the output. .TP
Signature · 1 line
2.34.1