@@ -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
new file mode 100644
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2023 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);
+ }
+
+ 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);
+}
@@ -56,6 +56,7 @@ init_commands(void)
flink_init();
freeze_init();
fsmap_init();
+ fsuuid_init();
fsync_init();
getrusage_init();
help_init();
@@ -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);
@@ -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