public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: Catherine Hoang <catherine.hoang@oracle.com>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH v1] xfs_spaceman: add fsuuid command
Date: Fri, 11 Nov 2022 21:31:45 +0000	[thread overview]
Message-ID: <2d21d7fea86d7aa48cbe0d1616ea99b56a0617c4.camel@oracle.com> (raw)
In-Reply-To: <20221109222335.84920-1-catherine.hoang@oracle.com>

On Wed, 2022-11-09 at 14:23 -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>
I think it looks good
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
> ---
>  spaceman/Makefile |  4 +--
>  spaceman/fsuuid.c | 63
> +++++++++++++++++++++++++++++++++++++++++++++++
>  spaceman/init.c   |  1 +
>  spaceman/space.h  |  1 +
>  4 files changed, 67 insertions(+), 2 deletions(-)
>  create mode 100644 spaceman/fsuuid.c
> 
> diff --git a/spaceman/Makefile b/spaceman/Makefile
> index 1f048d54..901e4e6d 100644
> --- a/spaceman/Makefile
> +++ b/spaceman/Makefile
> @@ -7,10 +7,10 @@ include $(TOPDIR)/include/builddefs
>  
>  LTCOMMAND = xfs_spaceman
>  HFILES = init.h space.h
> -CFILES = info.c init.c file.c health.c prealloc.c trim.c
> +CFILES = info.c init.c file.c health.c prealloc.c trim.c fsuuid.c
>  LSRCFILES = xfs_info.sh
>  
> -LLDLIBS = $(LIBXCMD) $(LIBFROG)
> +LLDLIBS = $(LIBXCMD) $(LIBFROG) $(LIBUUID)
>  LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
>  LLDFLAGS = -static
>  
> diff --git a/spaceman/fsuuid.c b/spaceman/fsuuid.c
> new file mode 100644
> index 00000000..be12c1ad
> --- /dev/null
> +++ b/spaceman/fsuuid.c
> @@ -0,0 +1,63 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 Oracle.
> + * All Rights Reserved.
> + */
> +
> +#include "libxfs.h"
> +#include "libfrog/fsgeom.h"
> +#include "libfrog/paths.h"
> +#include "command.h"
> +#include "init.h"
> +#include "space.h"
> +#include <sys/ioctl.h>
> +
> +#ifndef FS_IOC_GETFSUUID
> +#define FS_IOC_GETFSUUID       _IOR('f', 44, struct fsuuid)
> +#define UUID_SIZE 16
> +struct fsuuid {
> +    __u32   fsu_len;
> +    __u32   fsu_flags;
> +    __u8    fsu_uuid[];
> +};
> +#endif
> +
> +static cmdinfo_t fsuuid_cmd;
> +
> +static int
> +fsuuid_f(
> +       int             argc,
> +       char            **argv)
> +{
> +       struct fsuuid   fsuuid;
> +       int             error;
> +       char            bp[40];
> +
> +       fsuuid.fsu_len = UUID_SIZE;
> +       fsuuid.fsu_flags = 0;
> +
> +       error = ioctl(file->xfd.fd, FS_IOC_GETFSUUID, &fsuuid);
> +
> +       if (error) {
> +               perror("fsuuid");
> +               exitcode = 1;
> +       } else {
> +               platform_uuid_unparse((uuid_t *)fsuuid.fsu_uuid, bp);
> +               printf("UUID = %s\n", bp);
> +       }
> +
> +       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;
> +       fsuuid_cmd.oneline = _("get mounted filesystem UUID");
> +
> +       add_command(&fsuuid_cmd);
> +}
> diff --git a/spaceman/init.c b/spaceman/init.c
> index cf1ff3cb..efe1bf9b 100644
> --- a/spaceman/init.c
> +++ b/spaceman/init.c
> @@ -35,6 +35,7 @@ init_commands(void)
>         trim_init();
>         freesp_init();
>         health_init();
> +       fsuuid_init();
>  }
>  
>  static int
> diff --git a/spaceman/space.h b/spaceman/space.h
> index 723209ed..dcbdca08 100644
> --- a/spaceman/space.h
> +++ b/spaceman/space.h
> @@ -33,5 +33,6 @@ extern void   freesp_init(void);
>  #endif
>  extern void    info_init(void);
>  extern void    health_init(void);
> +extern void    fsuuid_init(void);
>  
>  #endif /* XFS_SPACEMAN_SPACE_H_ */


  parent reply	other threads:[~2022-11-11 21:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 22:23 [PATCH v1] xfs_spaceman: add fsuuid command Catherine Hoang
2022-11-11 21:05 ` Dave Chinner
2022-11-14 22:55   ` Catherine Hoang
2022-11-11 21:31 ` Allison Henderson [this message]
2022-11-17 20:37 ` Darrick J. Wong
2022-11-17 21:51   ` Dave Chinner
2022-11-17 23:58     ` Darrick J. Wong
2022-11-21 23:33       ` Dave Chinner
2022-11-22  6:21         ` Darrick J. Wong
2022-11-22 23:45           ` Dave Chinner

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=2d21d7fea86d7aa48cbe0d1616ea99b56a0617c4.camel@oracle.com \
    --to=allison.henderson@oracle.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox