From: Karel Zak Date: Mon, 3 Feb 2025 11:03:10 +0000 (+0100) Subject: mkswap: add features list to --version output X-Git-Tag: v2.42-start~65^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ea0649193bab545f80bbc4d23735df774e0fc80;p=thirdparty%2Futil-linux.git mkswap: add features list to --version output * Define USE_NOCOW to simplify code * Add array of features Signed-off-by: Karel Zak --- diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index e1ccc80b6..d73c3f0aa 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -66,6 +66,10 @@ # define USE_EXTENDS_CHECK 1 #endif +#if defined(FS_IOC_GETFLAGS) && defined(FS_NOCOW_FL) +# define USE_NOCOW 1 +#endif + #define MIN_GOODPAGES 10 #define SELINUX_SWAPFILE_TYPE "swapfile_t" @@ -417,7 +421,7 @@ static void open_device(struct mkswap_control *ctl) /* Let's attempt to set the "nocow" attribute for Btrfs, etc. * Ignore if unsupported. */ -#if defined(FS_IOC_GETFLAGS) && defined(FS_NOCOW_FL) +#ifdef USE_NOCOW if (ioctl(ctl->fd, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; if (ioctl(ctl->fd, FS_IOC_SETFLAGS, &attr) < 0 && @@ -647,8 +651,30 @@ int main(int argc, char **argv) ctl.file = 1; break; case 'V': - print_version(EXIT_SUCCESS); - break; + { + static const char *const features[] = { +#ifdef USE_EXTENDS_CHECK + "extends-check", +#endif +#ifdef USE_NOCOW + "nocow", +#endif +#if defined(HAVE_POSIX_FALLOCATE) || defined(HAVE_FALLOCATE) + "fallocate", +#endif +#ifdef HAVE_LIBBLKID + "blkid-check", +#endif +#ifdef HAVE_LIBUUID + "uuid", +#endif +#ifdef HAVE_LIBSELINUX + "selinux", +#endif + NULL, + }; + print_version_with_features(EXIT_SUCCESS, features); + } case OPT_LOCK: ctl.lockmode = "1"; if (optarg) {