From: "Darrick J. Wong" <djwong@kernel.org>
To: Catherine Hoang <catherine.hoang@oracle.com>
Cc: "linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] xfs_io: add fsuuid command
Date: Wed, 21 Dec 2022 08:24:55 -0800 [thread overview]
Message-ID: <Y6MzV7o6+FeUfZQk@magnolia> (raw)
In-Reply-To: <7F927E70-E9EA-4527-BDEC-EE00A2BC6A54@oracle.com>
On Wed, Dec 21, 2022 at 07:11:42AM +0000, Catherine Hoang wrote:
> > On Dec 20, 2022, at 1:55 PM, Darrick J. Wong <djwong@kernel.org> wrote:
> >
> > 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@oracle.com>
> >> Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
> >> ---
> >> 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.
>
> I noticed xfs_db also prints “uuid" in uppercase, so I didn’t change it
Lol, dunno why I didn't notice that. :/
Carry on!
--D
> > With that fixed,
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>
> Thanks for reviewing!
> >
> > --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
> >>
>
next prev parent reply other threads:[~2022-12-21 16:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 18:18 [PATCH v2 0/2] get UUID of mounted filesystems Catherine Hoang
2022-12-19 18:18 ` [PATCH v2 1/2] xfs_io: add fsuuid command Catherine Hoang
2022-12-20 21:55 ` Darrick J. Wong
2022-12-21 7:11 ` Catherine Hoang
2022-12-21 16:24 ` Darrick J. Wong [this message]
2022-12-19 18:18 ` [PATCH v2 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
2022-12-20 22:29 ` Darrick J. Wong
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=Y6MzV7o6+FeUfZQk@magnolia \
--to=djwong@kernel.org \
--cc=catherine.hoang@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.