Re: [PATCH v2 1/2] xfs_io: add fsuuid command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 19, 2022 at 10:18:23AM -0800, Catherine Hoang wrote:
> Add support for the fsuuid command to retrieve the UUID of a mounted
> filesystem.
> 
> Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx>
> Reviewed-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
> ---
>  io/Makefile       |  6 +++---
>  io/fsuuid.c       | 49 +++++++++++++++++++++++++++++++++++++++++++++++
>  io/init.c         |  1 +
>  io/io.h           |  1 +
>  man/man8/xfs_io.8 |  3 +++
>  5 files changed, 57 insertions(+), 3 deletions(-)
>  create mode 100644 io/fsuuid.c
> 
> diff --git a/io/Makefile b/io/Makefile
> index 498174cf..53fef09e 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -10,12 +10,12 @@ LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh
>  HFILES = init.h io.h
>  CFILES = init.c \
>  	attr.c bmap.c bulkstat.c crc32cselftest.c cowextsize.c encrypt.c \
> -	file.c freeze.c fsync.c getrusage.c imap.c inject.c label.c link.c \
> -	mmap.c open.c parent.c pread.c prealloc.c pwrite.c reflink.c \
> +	file.c freeze.c fsuuid.c fsync.c getrusage.c imap.c inject.c label.c \
> +	link.c mmap.c open.c parent.c pread.c prealloc.c pwrite.c reflink.c \
>  	resblks.c scrub.c seek.c shutdown.c stat.c swapext.c sync.c \
>  	truncate.c utimes.c
>  
> -LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD)
> +LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) $(LIBUUID)
>  LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG)
>  LLDFLAGS = -static-libtool-libs
>  
> diff --git a/io/fsuuid.c b/io/fsuuid.c
> new file mode 100644
> index 00000000..7e14a95d
> --- /dev/null
> +++ b/io/fsuuid.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 Oracle.
> + * All Rights Reserved.
> + */
> +
> +#include "libxfs.h"
> +#include "command.h"
> +#include "init.h"
> +#include "io.h"
> +#include "libfrog/fsgeom.h"
> +#include "libfrog/logging.h"
> +
> +static cmdinfo_t fsuuid_cmd;
> +
> +static int
> +fsuuid_f(
> +	int			argc,
> +	char			**argv)
> +{
> +	struct xfs_fsop_geom	fsgeo;
> +	int			ret;
> +	char			bp[40];
> +
> +	ret = -xfrog_geometry(file->fd, &fsgeo);
> +
> +	if (ret) {
> +		xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
> +		exitcode = 1;
> +	} else {
> +		platform_uuid_unparse((uuid_t *)fsgeo.uuid, bp);
> +		printf("UUID = %s\n", bp);

Lowercase "uuid" to match the xfs_db uuid command.

With that fixed,
Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>

--D

> +	}
> +
> +	return 0;
> +}
> +
> +void
> +fsuuid_init(void)
> +{
> +	fsuuid_cmd.name = "fsuuid";
> +	fsuuid_cmd.cfunc = fsuuid_f;
> +	fsuuid_cmd.argmin = 0;
> +	fsuuid_cmd.argmax = 0;
> +	fsuuid_cmd.flags = CMD_FLAG_ONESHOT | CMD_NOMAP_OK;
> +	fsuuid_cmd.oneline = _("get mounted filesystem UUID");
> +
> +	add_command(&fsuuid_cmd);
> +}
> diff --git a/io/init.c b/io/init.c
> index 033ed67d..104cd2c1 100644
> --- a/io/init.c
> +++ b/io/init.c
> @@ -56,6 +56,7 @@ init_commands(void)
>  	flink_init();
>  	freeze_init();
>  	fsmap_init();
> +	fsuuid_init();
>  	fsync_init();
>  	getrusage_init();
>  	help_init();
> diff --git a/io/io.h b/io/io.h
> index 64b7a663..fe474faf 100644
> --- a/io/io.h
> +++ b/io/io.h
> @@ -94,6 +94,7 @@ extern void		encrypt_init(void);
>  extern void		file_init(void);
>  extern void		flink_init(void);
>  extern void		freeze_init(void);
> +extern void		fsuuid_init(void);
>  extern void		fsync_init(void);
>  extern void		getrusage_init(void);
>  extern void		help_init(void);
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index 223b5152..ef7087b3 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -1455,6 +1455,9 @@ This option is not compatible with the
>  flag.
>  .RE
>  .PD
> +.TP
> +.B fsuuid
> +Print the mounted filesystem UUID.
>  
>  
>  .SH OTHER COMMANDS
> -- 
> 2.25.1
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux