Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 3/3] treewide: consistently use tabs for indentation where it is the rule
From: Benno Schulenberg @ 2025-12-09 15:02 UTC (permalink / raw)
  To: util-linux
In-Reply-To: <20251209150222.50981-1-bensberg@telfort.nl>

Also unwrap a line, delete two blank lines, and improve three comments.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 disk-utils/blockdev.c          |  20 ++--
 disk-utils/cfdisk.c            |   8 +-
 disk-utils/fdformat.c          |   2 +-
 disk-utils/fdisk-menu.c        |  10 +-
 disk-utils/fdisk.c             |   6 +-
 disk-utils/mkfs.bfs.c          |   2 +-
 disk-utils/mkfs.cramfs.c       |   6 +-
 disk-utils/mkswap.c            |   3 +-
 disk-utils/sfdisk.c            |   4 +-
 lib/buffer.c                   |   2 +-
 lib/env.c                      |  86 ++++++++---------
 lib/fileeq.c                   |   2 +-
 lib/ismounted.c                |  32 +++---
 lib/logindefs.c                |  46 ++++-----
 lib/loopdev.c                  |  38 ++++----
 lib/procfs.c                   |   4 +-
 lib/pty-session.c              |   6 +-
 lib/shells.c                   |  54 +++++------
 lib/strutils.c                 | 148 ++++++++++++++--------------
 lib/sysfs.c                    | 171 ++++++++++++++++-----------------
 lib/timer.c                    |   2 +-
 login-utils/login.c            |   4 +-
 login-utils/sulogin-consoles.c |  10 +-
 misc-utils/findmnt.c           |  16 +--
 misc-utils/lastlog2.c          |   7 +-
 misc-utils/lsblk-devtree.c     |  16 +--
 misc-utils/rename.c            |   4 +-
 sys-utils/ipcrm.c              |   2 +-
 sys-utils/ldattach.c           |   6 +-
 sys-utils/losetup.c            |   2 +-
 sys-utils/lscpu-topology.c     |   2 +-
 sys-utils/lsns.c               |  16 +--
 sys-utils/swapoff.c            |   2 +-
 sys-utils/tunelp.c             |   4 +-
 sys-utils/unshare.c            |  16 +--
 sys-utils/zramctl.c            |   6 +-
 term-utils/agetty.c            |  14 +--
 term-utils/mesg.c              |   4 +-
 term-utils/script.c            |   2 +-
 term-utils/scriptreplay.c      |   4 +-
 text-utils/col.c               |  65 ++++++-------
 text-utils/hexdump-display.c   |   4 +-
 text-utils/hexdump-parse.c     |  10 +-
 text-utils/hexdump.c           |   2 +-
 44 files changed, 433 insertions(+), 437 deletions(-)

diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c
index 55b47acf6..3ef74aa22 100644
--- a/disk-utils/blockdev.c
+++ b/disk-utils/blockdev.c
@@ -140,7 +140,7 @@ static const struct bdc bdcms[] =
 		.argname = "<bytes>",
 		.argtype = ARG_INT,
 		.flags = FL_NORESULT,
-	        .help = N_("set blocksize on file descriptor opening the block device")
+		.help = N_("set blocksize on file descriptor opening the block device")
 	},{
 		IOCTL_ENTRY(BLKGETSIZE),
 		.name = "--getsize",
@@ -210,23 +210,23 @@ static void __attribute__((__noreturn__)) usage(void)
 
 	fputs(USAGE_HEADER, stdout);
 	fprintf(stdout, _(
-	         " %1$s [-v|-q] commands devices\n"
-	         " %1$s --report [devices]\n"
-	         " %1$s -h|-V\n"
-		), program_invocation_short_name);
+	          " %1$s [-v|-q] commands devices\n"
+	          " %1$s --report [devices]\n"
+	          " %1$s -h|-V\n"
+	       ), program_invocation_short_name);
 
 	fputs(USAGE_SEPARATOR, stdout);
-	fputsln(  _("Call block device ioctls from the command line."), stdout);
+	fputsln(_("Call block device ioctls from the command line."), stdout);
 
 	fputs(USAGE_OPTIONS, stdout);
-	fputsln(  _(" -q             quiet mode"), stdout);
-	fputsln(  _(" -v             verbose mode"), stdout);
-	fputsln(  _("     --report   print report for specified (or all) devices"), stdout);
+	fputsln(_(" -q             quiet mode"), stdout);
+	fputsln(_(" -v             verbose mode"), stdout);
+	fputsln(_("     --report   print report for specified (or all) devices"), stdout);
 	fputs(USAGE_SEPARATOR, stdout);
 	fprintf(stdout, USAGE_HELP_OPTIONS(16));
 
 	fputs(USAGE_SEPARATOR, stdout);
-	fputsln(  _("Available commands:"), stdout);
+	fputsln(_("Available commands:"), stdout);
 	fprintf(stdout, _(" %-25s get size in 512-byte sectors\n"), "--getsz");
 	for (i = 0; i < ARRAY_SIZE(bdcms); i++) {
 		if (bdcms[i].argname)
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index e4e16001e..e2f1cd74d 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -1760,7 +1760,7 @@ static int ui_refresh(struct cfdisk *cf)
 {
 	struct fdisk_label *lb;
 	char *id = NULL;
-        uint64_t bytes = fdisk_get_nsectors(cf->cxt) * fdisk_get_sector_size(cf->cxt);
+	uint64_t bytes = fdisk_get_nsectors(cf->cxt) * fdisk_get_sector_size(cf->cxt);
 	char *strsz;
 
 	if (!ui_enabled)
@@ -2783,9 +2783,9 @@ int main(int argc, char *argv[])
 			if (optarg)
 				colormode = colormode_or_err(optarg);
 			break;
-                case 'r':
-                        read_only = 1;
-                        break;
+		case 'r':
+			read_only = 1;
+			break;
 		case 'V':
 			print_version(EXIT_SUCCESS);
 		case 'z':
diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c
index 49cb51d8a..04e414a53 100644
--- a/disk-utils/fdformat.c
+++ b/disk-utils/fdformat.c
@@ -164,7 +164,7 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_(" -f, --from <N>    start at the track N (default 0)\n"), out);
 	fputs(_(" -t, --to <N>      stop at the track N\n"), out);
 	fputs(_(" -r, --repair <N>  try to repair tracks failed during\n"
-                "                     the verification (max N retries)\n"), out);
+		"                     the verification (max N retries)\n"), out);
 	fputs(_(" -n, --no-verify   disable the verification after the format\n"), out);
 
 	fputs(USAGE_SEPARATOR, out);
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
index 707394d4e..f3c9f154e 100644
--- a/disk-utils/fdisk-menu.c
+++ b/disk-utils/fdisk-menu.c
@@ -499,9 +499,9 @@ static int script_read(struct fdisk_context *cxt)
 		fdisk_warnx(cxt, _("Failed to apply script %s"), filename);
 		fdisk_warnx(cxt, _("Resetting fdisk!"));
 		rc = fdisk_reassign_device(cxt);
-                if (rc == 0 && !fdisk_has_label(cxt)) {
-                        fdisk_info(cxt, _("Device does not contain a recognized partition table."));
-                        rc = fdisk_create_disklabel(cxt, NULL);
+		if (rc == 0 && !fdisk_has_label(cxt)) {
+			fdisk_info(cxt, _("Device does not contain a recognized partition table."));
+			rc = fdisk_create_disklabel(cxt, NULL);
 		}
 	} else
 		fdisk_info(cxt, _("Script successfully applied."));
@@ -751,8 +751,8 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
 		case 'i':
 			return fdisk_set_disklabel_id(cxt);
 		case 'l':
-	                rc =  fdisk_ask_number(cxt, 1, fdisk_get_npartitions(cxt),
-	                                ~(uint32_t)0, _("New maximum entries"), &length);
+			rc =  fdisk_ask_number(cxt, 1, fdisk_get_npartitions(cxt),
+			                       ~(uint32_t)0, _("New maximum entries"), &length);
 			if (rc)
 				return rc;
 			return fdisk_gpt_set_npartitions(cxt, (uint32_t) length);
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index 72feed587..f44a4899e 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -494,11 +494,11 @@ static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt, int
 	*canceled = 0;
 
 	if (fdisk_label_has_parttypes_shortcuts(lb))
-		 q = fdisk_label_has_code_parttypes(lb) ?
+		q = fdisk_label_has_code_parttypes(lb) ?
 			_("Hex code or alias (type L to list all): ") :
 			_("Partition type or alias (type L to list all): ");
 	else
-	        q = fdisk_label_has_code_parttypes(lb) ?
+		q = fdisk_label_has_code_parttypes(lb) ?
 			_("Hex code (type L to list all codes): ") :
 			_("Partition type (type L to list all types): ");
 	do {
@@ -523,7 +523,7 @@ static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt, int
 				fdisk_info(cxt, _("Failed to parse '%s' partition type."), buf);
 			return t;
 		}
-        } while (1);
+	} while (1);
 
 	return NULL;
 }
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index 30c28d9e7..838fb59b4 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
 			/* when called via mkfs we may get options c,l,v */
 			break;
 
-                case OPT_LOCK:
+		case OPT_LOCK:
 			lockmode = "1";
 			if (optarg) {
 				if (*optarg == '=')
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index a91016d26..0b1695e77 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -764,9 +764,9 @@ int main(int argc, char **argv)
 			fslen_ub += (image_length + 3); /* 3 is for padding */
 			break;
 		case 'l':
-                        lockmode = "1";
+			lockmode = "1";
 			if (optarg) {
-                                if (*optarg == '=')
+				if (*optarg == '=')
 					optarg++;
 				lockmode = optarg;
 			}
@@ -810,7 +810,7 @@ int main(int argc, char **argv)
 	if (fd < 0)
 		err(MKFS_EX_USAGE, _("cannot open %s"), outfile);
 
-        if (blkdev_lock(fd, outfile, lockmode) != 0)
+	if (blkdev_lock(fd, outfile, lockmode) != 0)
 		exit(MKFS_EX_ERROR);
 
 	root_entry = xcalloc(1, sizeof(struct entry));
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 3cb7a043b..17ec1603f 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -800,8 +800,7 @@ int main(int argc, char **argv)
 	deinit_signature_page(&ctl);
 
 #ifdef HAVE_LIBSELINUX
-	if ((ctl.file || S_ISREG(ctl.devstat.st_mode)) &&
-            is_selinux_enabled() > 0) {
+	if ((ctl.file || S_ISREG(ctl.devstat.st_mode)) && is_selinux_enabled() > 0) {
 		const char *context_string;
 		char *oldcontext;
 		context_t newcontext;
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index b691cb084..aeab826c2 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -478,7 +478,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
 			fdisk_info(sf->cxt, _(" typescript file: %s"), typescript);
 		printf(_("  start sector: (from/to) %ju / %ju\n"), (uintmax_t) from, (uintmax_t) to);
 		printf(_("  sectors: %ju\n"), (uintmax_t) nsectors);
-	        printf(_("  step size: %zu bytes\n"), step_bytes);
+		printf(_("  step size: %zu bytes\n"), step_bytes);
 		putchar('\n');
 		fflush(stdout);
 
@@ -602,7 +602,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
 					i + 1, nsectors,
 					100.0 / ((double) nsectors/(i+1)));
 			fflush(stdout);
-                        fputc('\r', stdout);
+			fputc('\r', stdout);
 
 		}
 next:
diff --git a/lib/buffer.c b/lib/buffer.c
index bdc4744bc..76aefe950 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -303,6 +303,6 @@ int main(void)
 
 	ul_buffer_free_data(&buf);
 
-        return EXIT_SUCCESS;
+	return EXIT_SUCCESS;
 }
 #endif /* TEST_PROGRAM_BUFFER */
diff --git a/lib/env.c b/lib/env.c
index 039fad0dc..e5e66337f 100644
--- a/lib/env.c
+++ b/lib/env.c
@@ -27,28 +27,28 @@ extern char **environ;
 #endif
 
 static char * const forbid[] = {
-        "BASH_ENV=",    /* GNU creeping featurism strikes again... */
-        "ENV=",
-        "HOME=",
-        "IFS=",
-        "KRB_CONF=",
-        "LD_",          /* anything with the LD_ prefix */
-        "LIBPATH=",
-        "MAIL=",
-        "NLSPATH=",
-        "PATH=",
-        "SHELL=",
-        "SHLIB_PATH=",
-        (char *) 0
+	"BASH_ENV=",    /* GNU creeping featurism strikes again... */
+	"ENV=",
+	"HOME=",
+	"IFS=",
+	"KRB_CONF=",
+	"LD_",	  /* anything with the LD_ prefix */
+	"LIBPATH=",
+	"MAIL=",
+	"NLSPATH=",
+	"PATH=",
+	"SHELL=",
+	"SHLIB_PATH=",
+	(char *) 0
 };
 
 /* these are allowed, but with no slashes inside
    (to work around security problems in GNU gettext) */
 static char * const noslash[] = {
-        "LANG=",
-        "LANGUAGE=",
-        "LC_",          /* anything with the LC_ prefix */
-        (char *) 0
+	"LANG=",
+	"LANGUAGE=",
+	"LC_",	  /* anything with the LC_ prefix */
+	(char *) 0
 };
 
 
@@ -218,39 +218,39 @@ void env_list_free(struct ul_env_list *ls)
  */
 void __sanitize_env(struct ul_env_list **org)
 {
-        char **envp = environ;
-        char * const *bad;
-        char **cur;
-        int last = 0;
+	char **envp = environ;
+	char * const *bad;
+	char **cur;
+	int last = 0;
 
-        for (cur = envp; *cur; cur++)
-                last++;
+	for (cur = envp; *cur; cur++)
+		last++;
 
-        for (cur = envp; *cur; cur++) {
-                for (bad = forbid; *bad; bad++) {
-                        if (strncmp(*cur, *bad, strlen(*bad)) == 0) {
+	for (cur = envp; *cur; cur++) {
+		for (bad = forbid; *bad; bad++) {
+			if (strncmp(*cur, *bad, strlen(*bad)) == 0) {
 				if (org)
 					*org = env_list_add_from_string(*org, *cur);
-                                last = ul_remove_entry(envp, cur - envp, last);
-                                cur--;
-                                break;
-                        }
-                }
-        }
+				last = ul_remove_entry(envp, cur - envp, last);
+				cur--;
+				break;
+			}
+		}
+	}
 
-        for (cur = envp; *cur; cur++) {
-                for (bad = noslash; *bad; bad++) {
-                        if (strncmp(*cur, *bad, strlen(*bad)) != 0)
-                                continue;
-                        if (!strchr(*cur, '/'))
-                                continue;  /* OK */
+	for (cur = envp; *cur; cur++) {
+		for (bad = noslash; *bad; bad++) {
+			if (strncmp(*cur, *bad, strlen(*bad)) != 0)
+				continue;
+			if (!strchr(*cur, '/'))
+				continue;  /* OK */
 			if (org)
 				*org = env_list_add_from_string(*org, *cur);
-                        last = ul_remove_entry(envp, cur - envp, last);
-                        cur--;
-                        break;
-                }
-        }
+			last = ul_remove_entry(envp, cur - envp, last);
+			cur--;
+			break;
+		}
+	}
 }
 
 void sanitize_env(void)
diff --git a/lib/fileeq.c b/lib/fileeq.c
index ffd208962..762619563 100644
--- a/lib/fileeq.c
+++ b/lib/fileeq.c
@@ -335,7 +335,7 @@ static int get_fd(struct ul_fileeq *eq, struct ul_fileeq_data *data, off_t *off)
 			return data->fd;
 
 #if defined(POSIX_FADV_SEQUENTIAL) && defined(HAVE_POSIX_FADVISE)
-	        ignore_result( posix_fadvise(data->fd, o, 0, POSIX_FADV_SEQUENTIAL) );
+		ignore_result( posix_fadvise(data->fd, o, 0, POSIX_FADV_SEQUENTIAL) );
 #endif
 		if (o) {
 			DBG(DATA, ul_debugobj(data, "lseek off=%ju", (uintmax_t) o));
diff --git a/lib/ismounted.c b/lib/ismounted.c
index ae5327c90..28ddc0d58 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -216,31 +216,31 @@ static int check_getmntinfo(const char *file, int *mount_flags,
 				  char *mtpt, int mtlen)
 {
 	struct statfs *mp;
-        int    len, n;
-        const  char   *s1;
+	int    len, n;
+	const  char   *s1;
 	char	*s2;
 
-        n = getmntinfo(&mp, MNT_NOWAIT);
-        if (n == 0)
+	n = getmntinfo(&mp, MNT_NOWAIT);
+	if (n == 0)
 		return errno;
 
-        len = sizeof(_PATH_DEV) - 1;
-        s1 = file;
-        if (strncmp(_PATH_DEV, s1, len) == 0)
-                s1 += len;
+	len = sizeof(_PATH_DEV) - 1;
+	s1 = file;
+	if (strncmp(_PATH_DEV, s1, len) == 0)
+		s1 += len;
 
 	*mount_flags = 0;
-        while (--n >= 0) {
-                s2 = mp->f_mntfromname;
-                if (strncmp(_PATH_DEV, s2, len) == 0) {
-                        s2 += len - 1;
-                        *s2 = 'r';
-                }
-                if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) {
+	while (--n >= 0) {
+		s2 = mp->f_mntfromname;
+		if (strncmp(_PATH_DEV, s2, len) == 0) {
+			s2 += len - 1;
+			*s2 = 'r';
+		}
+		if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) {
 			*mount_flags = MF_MOUNTED;
 			break;
 		}
-                ++mp;
+		++mp;
 	}
 	if (mtpt && n >= 0)
 		xstrncpy(mtpt, mp->f_mntonname, mtlen);
diff --git a/lib/logindefs.c b/lib/logindefs.c
index 079f2dabf..3da5911d1 100644
--- a/lib/logindefs.c
+++ b/lib/logindefs.c
@@ -253,7 +253,7 @@ static void load_defaults(void)
 	econf_err error;
 
 	if (file != NULL)
-	        free_getlogindefs_data();
+		free_getlogindefs_data();
 
 #ifdef HAVE_ECONF_READCONFIG
 	error = econf_readConfig(&file, NULL,
@@ -282,10 +282,10 @@ void logindefs_load_file(const char *filename)
 	xasprintf(&path, _PATH_VENDORDIR"/%s", filename);
 
 	if (!econf_readFile(&file_l, path, "= \t", "#")) {
-	        if (file == NULL)
-		        file = file_l;
-	        else if (!econf_mergeFiles(&file_m, file, file_l)) {
-		        econf_free(file);
+		if (file == NULL)
+			file = file_l;
+		else if (!econf_mergeFiles(&file_m, file, file_l)) {
+			econf_free(file);
 			file = file_m;
 			econf_free(file_l);
 		}
@@ -296,10 +296,10 @@ void logindefs_load_file(const char *filename)
 	xasprintf(&path, "/etc/%s", filename);
 
 	if (!econf_readFile(&file_l, path, "= \t", "#")) {
-	        if (file == NULL)
-		        file = file_l;
-	        else if (!econf_mergeFiles(&file_m, file, file_l)) {
-	                econf_free(file);
+		if (file == NULL)
+			file = file_l;
+		else if (!econf_mergeFiles(&file_m, file, file_l)) {
+			econf_free(file);
 			file = file_m;
 			econf_free(file_l);
 		}
@@ -319,18 +319,18 @@ void logindefs_load_file(const char *filename)
 
 int getlogindefs_bool(const char *name, int dflt)
 {
-        bool value;
+	bool value;
 	econf_err error;
 
 	if (!file)
-	        load_defaults();
+		load_defaults();
 
 	if (!file)
 		return dflt;
 
 	if ((error = econf_getBoolValue(file, NULL, name, &value))) {
-	        if (error != ECONF_NOKEY)
-	                syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
+		if (error != ECONF_NOKEY)
+			syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
 			       econf_errString(error));
 		return dflt;
 	}
@@ -343,14 +343,14 @@ unsigned long getlogindefs_num(const char *name, unsigned long dflt)
 	econf_err error;
 
 	if (!file)
-	        load_defaults();
+		load_defaults();
 
 	if (!file)
 		return dflt;
 
 	if ((error = econf_getUInt64Value(file, NULL, name, &value))) {
-	        if (error != ECONF_NOKEY)
-		        syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
+		if (error != ECONF_NOKEY)
+			syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
 			       econf_errString(error));
 		return dflt;
 	}
@@ -365,19 +365,19 @@ unsigned long getlogindefs_num(const char *name, unsigned long dflt)
  */
 const char *getlogindefs_str(const char *name, const char *dflt)
 {
-        char *value;
+	char *value;
 	econf_err error;
 
 	if (!file)
-	        load_defaults();
+		load_defaults();
 
 	if (!file)
 		return dflt;
 
 	if ((error = econf_getStringValue(file, NULL, name, &value))) {
-	        if (error != ECONF_NOKEY)
-		  syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
-			 econf_errString(error));
+		if (error != ECONF_NOKEY)
+			syslog(LOG_NOTICE, _("couldn't fetch %s: %s"), name,
+			       econf_errString(error));
 		return dflt;
 	}
 	if (value)
@@ -591,10 +591,10 @@ int main(int argc, char *argv[])
 				NULL};
 
 		for (i = 0; keys[i] != NULL; i++) {
-		  	char *value = NULL;
+			char *value = NULL;
 
 			econf_getStringValue(file, NULL, keys[i], &value);
-		        printf ("%s: $%s: '%s'\n", argv[1], keys[i], value);
+			printf ("%s: $%s: '%s'\n", argv[1], keys[i], value);
 		}
 
 		econf_free (file);
diff --git a/lib/loopdev.c b/lib/loopdev.c
index efc997f87..6b27e451f 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -326,7 +326,7 @@ static int __loopcxt_get_fd(struct loopdev_cxt *lc, mode_t mode)
 		lc->fd = open(lc->device, lc->mode | O_CLOEXEC);
 		DBG(CXT, ul_debugobj(lc, "open %s [%s]: %m", lc->device,
 				mode == O_RDONLY ? "ro" :
-			        mode == O_RDWR ? "rw" : "??"));
+				mode == O_RDWR ? "rw" : "??"));
 
 		if (lc->fd < 0 && old >= 0) {
 			/* restore original on error */
@@ -1661,28 +1661,28 @@ int loopcxt_detach_device(struct loopdev_cxt *lc)
 
 int loopcxt_remove_device(struct loopdev_cxt *lc)
 {
-       int rc = -EINVAL;
-       int ctl, nr = -1;
+	int rc = -EINVAL;
+	int ctl, nr = -1;
 
-       if (!(lc->flags & LOOPDEV_FL_CONTROL)) {
-               rc = -ENOSYS;
-               goto done;
-       }
+	if (!(lc->flags & LOOPDEV_FL_CONTROL)) {
+		rc = -ENOSYS;
+		goto done;
+	}
 
-       rc = loopcxt_get_device_nr(lc, &nr);
-       if (rc)
-               goto done;
+	rc = loopcxt_get_device_nr(lc, &nr);
+	if (rc)
+		goto done;
 
-       ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
-       if (ctl >= 0) {
-               DBG(CXT, ul_debugobj(lc, "remove_device %d", nr));
-               rc = ioctl(ctl, LOOP_CTL_REMOVE, nr);
-               close(ctl);
-       }
-       lc->control_ok = rc >= 0 ? 1 : 0;
+	ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
+	if (ctl >= 0) {
+		DBG(CXT, ul_debugobj(lc, "remove_device %d", nr));
+		rc = ioctl(ctl, LOOP_CTL_REMOVE, nr);
+		close(ctl);
+	}
+	lc->control_ok = rc >= 0 ? 1 : 0;
 done:
-       DBG(CXT, ul_debugobj(lc, "remove_device done [rc=%d]", rc));
-       return rc;
+	DBG(CXT, ul_debugobj(lc, "remove_device done [rc=%d]", rc));
+	return rc;
 }
 
 int loopcxt_add_device(struct loopdev_cxt *lc)
diff --git a/lib/procfs.c b/lib/procfs.c
index ca34e54b0..1f6b01a85 100644
--- a/lib/procfs.c
+++ b/lib/procfs.c
@@ -476,7 +476,7 @@ static int test_tasks(int argc, char *argv[], const char *prefix)
 		printf(" %d", tid);
 
 	printf("\n");
-        ul_unref_path(pc);
+	ul_unref_path(pc);
 	return EXIT_SUCCESS;
 }
 
@@ -501,7 +501,7 @@ static int test_fds(int argc, char *argv[], const char *prefix)
 		printf(" %d", fd);
 
 	fputc('\n', stdout);
-        ul_unref_path(pc);
+	ul_unref_path(pc);
 	return EXIT_SUCCESS;
 }
 
diff --git a/lib/pty-session.c b/lib/pty-session.c
index e9db4988b..b3e41e0c8 100644
--- a/lib/pty-session.c
+++ b/lib/pty-session.c
@@ -169,7 +169,7 @@ int ul_pty_setup(struct ul_pty *pty)
 	sigprocmask(0, NULL, &pty->orgsig);
 
 	if (pty->isterm) {
-	        DBG(SETUP, ul_debugobj(pty, "create for terminal"));
+		DBG(SETUP, ul_debugobj(pty, "create for terminal"));
 
 		/* original setting of the current terminal */
 		if (tcgetattr(STDIN_FILENO, &pty->stdin_attrs) != 0) {
@@ -594,9 +594,9 @@ static int handle_signal(struct ul_pty *pty, int fd)
 	case SIGQUIT:
 		DBG(SIG, ul_debugobj(pty, " get signal SIG{TERM,INT,QUIT}"));
 		pty->delivered_signal = info.ssi_signo;
-                /* Child termination is going to generate SIGCHLD (see above) */
+		/* Child termination is going to generate SIGCHLD (see above) */
 		if (pty->child > 0)
-	                kill(pty->child, SIGTERM);
+			kill(pty->child, SIGTERM);
 
 		if (pty->callbacks.log_signal)
 			rc = pty->callbacks.log_signal(pty->callback_data,
diff --git a/lib/shells.c b/lib/shells.c
index ef2aecd0f..f773f0df8 100644
--- a/lib/shells.c
+++ b/lib/shells.c
@@ -44,34 +44,34 @@ static econf_file *open_etc_shells(void)
 extern void print_shells(FILE *out, const char *format)
 {
 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
-        size_t size = 0;
-        econf_err error;
-        char **keys = NULL;
-        econf_file *key_file = open_etc_shells();
+	size_t size = 0;
+	econf_err error;
+	char **keys = NULL;
+	econf_file *key_file = open_etc_shells();
 
 	if (!key_file)
 	  return;
 
-        error = econf_getKeys(key_file, NULL, &size, &keys);
-        if (error) {
-                econf_free(key_file);
-                errx(EXIT_FAILURE,
-                  _("Cannot evaluate entries in shells files: %s"),
-                  econf_errString(error));
-        }
+	error = econf_getKeys(key_file, NULL, &size, &keys);
+	if (error) {
+		econf_free(key_file);
+		errx(EXIT_FAILURE,
+		  _("Cannot evaluate entries in shells files: %s"),
+		  econf_errString(error));
+	}
 
-        for (size_t i = 0; i < size; i++) {
-	        fprintf(out, format, keys[i]);
-        }
-        econf_free(keys);
-        econf_free(key_file);
+	for (size_t i = 0; i < size; i++) {
+		fprintf(out, format, keys[i]);
+	}
+	econf_free(keys);
+	econf_free(key_file);
 #else
-        char *s;
+	char *s;
 
 	setusershell();
-        while ((s = getusershell()))
-	        fprintf(out, format, s);
-        endusershell();
+	while ((s = getusershell()))
+		fprintf(out, format, s);
+	endusershell();
 #endif
 }
 
@@ -91,19 +91,19 @@ extern int is_known_shell(const char *shell_name)
 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
 	char *val = NULL;
 	econf_err error;
-        econf_file *key_file = open_etc_shells();
+	econf_file *key_file = open_etc_shells();
 
 	if (!key_file)
-	  return 0;
+		return 0;
 
 	error = econf_getStringValue (key_file, NULL, shell_name, &val);
 	if (error) {
-	        if (error != ECONF_NOKEY)
-		       syslog(LOG_ALERT,
-		               _("Cannot evaluate entries in shells files: %s"),
-			      econf_errString(error));
+		if (error != ECONF_NOKEY)
+			syslog(LOG_ALERT,
+			       _("Cannot evaluate entries in shells files: %s"),
+			       econf_errString(error));
 	} else
-	        ret = 1;
+		ret = 1;
 
 	free(val);
 	econf_free(key_file);
diff --git a/lib/strutils.c b/lib/strutils.c
index a3b1376e3..72d0352c8 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -281,20 +281,20 @@ int ul_parse_switch(const char *arg, ...)
 #ifndef HAVE_MEMPCPY
 void *mempcpy(void *restrict dest, const void *restrict src, size_t n)
 {
-    return ((char *)memcpy(dest, src, n)) + n;
+	return ((char *)memcpy(dest, src, n)) + n;
 }
 #endif
 
 #ifndef HAVE_STRNLEN
 size_t strnlen(const char *s, size_t maxlen)
 {
-        size_t i;
+	size_t i;
 
-        for (i = 0; i < maxlen; i++) {
-                if (s[i] == '\0')
-                        return i;
-        }
-        return maxlen;
+	for (i = 0; i < maxlen; i++) {
+		if (s[i] == '\0')
+			return i;
+	}
+	return maxlen;
 }
 #endif
 
@@ -980,38 +980,38 @@ int streq_paths(const char *a, const char *b)
 /* concatenate two strings to a new string, the size of the second string is limited by @b */
 char *ul_strnconcat(const char *s, const char *suffix, size_t b)
 {
-        size_t a;
-        char *r;
+	size_t a;
+	char *r;
 
-        if (!s && !suffix)
-                return strdup("");
-        if (!s)
-                return strndup(suffix, b);
-        if (!suffix)
-                return strdup(s);
+	if (!s && !suffix)
+		return strdup("");
+	if (!s)
+		return strndup(suffix, b);
+	if (!suffix)
+		return strdup(s);
 
-        assert(s);
-        assert(suffix);
+	assert(s);
+	assert(suffix);
 
-        a = strlen(s);
-        if (b > ((size_t) -1) - a)
-                return NULL;
+	a = strlen(s);
+	if (b > ((size_t) -1) - a)
+		return NULL;
 
-        r = malloc(a + b + 1);
-        if (!r)
-                return NULL;
+	r = malloc(a + b + 1);
+	if (!r)
+		return NULL;
 
-        memcpy(r, s, a);
-        memcpy(r + a, suffix, b);
-        r[a+b] = 0;
+	memcpy(r, s, a);
+	memcpy(r + a, suffix, b);
+	r[a+b] = 0;
 
-        return r;
+	return r;
 }
 
 /* concatenate two strings to a new string */
 char *ul_strconcat(const char *s, const char *suffix)
 {
-        return ul_strnconcat(s, suffix, suffix ? strlen(suffix) : 0);
+	return ul_strnconcat(s, suffix, suffix ? strlen(suffix) : 0);
 }
 
 /* concatenate @s and string defined by @format to a new string */
@@ -1088,20 +1088,20 @@ extern int ul_strvfappend(char **a, const char *format, va_list ap)
 
 static size_t strcspn_escaped(const char *s, const char *reject)
 {
-        int escaped = 0;
-        int n;
+	int escaped = 0;
+	int n;
 
-        for (n=0; s[n]; n++) {
-                if (escaped)
-                        escaped = 0;
-                else if (s[n] == '\\')
-                        escaped = 1;
-                else if (strchr(reject, s[n]))
-                        break;
-        }
+	for (n=0; s[n]; n++) {
+		if (escaped)
+			escaped = 0;
+		else if (s[n] == '\\')
+			escaped = 1;
+		else if (strchr(reject, s[n]))
+			break;
+	}
 
-        /* if s ends in \, return index of previous char */
-        return n - escaped;
+	/* if s ends in \, return index of previous char */
+	return n - escaped;
 }
 
 /*
@@ -1138,46 +1138,46 @@ char *ul_strchr_escaped(const char *s, int c)
 /* Split a string into words. */
 const char *ul_split(const char **state, size_t *l, const char *separator, int quoted)
 {
-        const char *current;
+	const char *current;
 
-        current = *state;
+	current = *state;
 
-        if (!*current) {
-                assert(**state == '\0');
-                return NULL;
-        }
+	if (!*current) {
+		assert(**state == '\0');
+		return NULL;
+	}
 
-        current += strspn(current, separator);
-        if (!*current) {
-                *state = current;
-                return NULL;
-        }
+	current += strspn(current, separator);
+	if (!*current) {
+		*state = current;
+		return NULL;
+	}
 
-        if (quoted && strchr("\'\"", *current)) {
-                char quotechars[2] = {*current, '\0'};
+	if (quoted && strchr("\'\"", *current)) {
+		char quotechars[2] = {*current, '\0'};
 
-                *l = strcspn_escaped(current + 1, quotechars);
-                if (current[*l + 1] == '\0' || current[*l + 1] != quotechars[0] ||
-                    (current[*l + 2] && !strchr(separator, current[*l + 2]))) {
-                        /* right quote missing or garbage at the end */
-                        *state = current;
-                        return NULL;
-                }
-                *state = current++ + *l + 2;
-        } else if (quoted) {
-                *l = strcspn_escaped(current, separator);
-                if (current[*l] && !strchr(separator, current[*l])) {
-                        /* unfinished escape */
-                        *state = current;
-                        return NULL;
-                }
-                *state = current + *l;
-        } else {
-                *l = strcspn(current, separator);
-                *state = current + *l;
-        }
+		*l = strcspn_escaped(current + 1, quotechars);
+		if (current[*l + 1] == '\0' || current[*l + 1] != quotechars[0] ||
+		    (current[*l + 2] && !strchr(separator, current[*l + 2]))) {
+			/* right quote missing or garbage at the end */
+			*state = current;
+			return NULL;
+		}
+		*state = current++ + *l + 2;
+	} else if (quoted) {
+		*l = strcspn_escaped(current, separator);
+		if (current[*l] && !strchr(separator, current[*l])) {
+			/* unfinished escape */
+			*state = current;
+			return NULL;
+		}
+		*state = current + *l;
+	} else {
+		*l = strcspn(current, separator);
+		*state = current + *l;
+	}
 
-        return current;
+	return current;
 }
 
 /* Rewind file pointer forward to new line.  */
diff --git a/lib/sysfs.c b/lib/sysfs.c
index c888617b7..13977ee5b 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -183,7 +183,7 @@ char *sysfs_blkdev_get_name(struct path_cxt *pc, char *buf, size_t bufsiz)
 	char *name;
 	ssize_t	sz;
 
-        /* read /sys/dev/block/<maj:min> link */
+	/* read /sys/dev/block/<maj:min> link */
 	sz = ul_path_readlink(pc, link, sizeof(link), NULL);
 	if (sz < 0)
 		return NULL;
@@ -522,29 +522,29 @@ int sysfs_blkdev_is_removable(struct path_cxt *pc)
 }
 
 static int get_dm_wholedisk(struct path_cxt *pc, char *diskname,
-                size_t len, dev_t *diskdevno)
+                            size_t len, dev_t *diskdevno)
 {
-    int rc = 0;
-    char *name;
+	int rc = 0;
+	char *name;
 
-    /* Note, sysfs_blkdev_get_slave() returns the first slave only,
-     * if there is more slaves, then return NULL
-     */
-    name = sysfs_blkdev_get_slave(pc);
-    if (!name)
-        return -1;
+	/* Note: sysfs_blkdev_get_slave() returns the first slave only;
+	 * if there are more slaves, it returns NULL.
+	 */
+	name = sysfs_blkdev_get_slave(pc);
+	if (!name)
+		return -1;
 
-    if (diskname && len)
-        xstrncpy(diskname, name, len);
+	if (diskname && len)
+		xstrncpy(diskname, name, len);
 
-    if (diskdevno) {
-        *diskdevno = __sysfs_devname_to_devno(ul_path_get_prefix(pc), name, NULL);
-        if (!*diskdevno)
-            rc = -1;
-    }
+	if (diskdevno) {
+		*diskdevno = __sysfs_devname_to_devno(ul_path_get_prefix(pc), name, NULL);
+		if (!*diskdevno)
+			rc = -1;
+	}
 
-    free(name);
-    return rc;
+	free(name);
+	return rc;
 }
 
 /*
@@ -556,85 +556,84 @@ int sysfs_blkdev_get_wholedisk(	struct path_cxt *pc,
 				size_t len,
 				dev_t *diskdevno)
 {
-    int is_part = 0;
+	int is_part = 0;
 
-    if (!pc)
-        return -1;
+	if (!pc)
+		return -1;
 
-    is_part = ul_path_access(pc, F_OK, "partition") == 0;
-    if (!is_part) {
-        /*
-         * Extra case for partitions mapped by device-mapper.
-         *
-         * All regular partitions (added by BLKPG ioctl or kernel PT
-         * parser) have the /sys/.../partition file. The partitions
-         * mapped by DM don't have such file, but they have "part"
-         * prefix in DM UUID.
-         */
-        char *uuid = NULL, *tmp, *prefix;
+	is_part = ul_path_access(pc, F_OK, "partition") == 0;
+	if (!is_part) {
+		/*
+		 * Extra case for partitions mapped by device-mapper.
+		 *
+		 * All regular partitions (added by BLKPG ioctl or kernel PT
+		 * parser) have the /sys/.../partition file. The partitions
+		 * mapped by DM don't have such file, but they have "part"
+		 * prefix in DM UUID.
+		 */
+		char *uuid = NULL, *tmp, *prefix;
 
-	ul_path_read_string(pc, &uuid, "dm/uuid");
-	tmp = uuid;
-	prefix = uuid ? strsep(&tmp, "-") : NULL;
+		ul_path_read_string(pc, &uuid, "dm/uuid");
+		tmp = uuid;
+		prefix = uuid ? strsep(&tmp, "-") : NULL;
 
-        if (prefix && c_strncasecmp(prefix, "part", 4) == 0)
-            is_part = 1;
-        free(uuid);
+		if (prefix && c_strncasecmp(prefix, "part", 4) == 0)
+			is_part = 1;
+		free(uuid);
 
-        if (is_part &&
-            get_dm_wholedisk(pc, diskname, len, diskdevno) == 0)
-            /*
-             * partitioned device, mapped by DM
-             */
-            goto done;
+		if (is_part &&
+			get_dm_wholedisk(pc, diskname, len, diskdevno) == 0)
+			/*
+			 * partitioned device, mapped by DM
+			 */
+			goto done;
 
-        is_part = 0;
-    }
+		is_part = 0;
+	}
 
-    if (!is_part) {
-        /*
-         * unpartitioned device
-         */
-        if (diskname && !sysfs_blkdev_get_name(pc, diskname, len))
-            goto err;
-        if (diskdevno)
-            *diskdevno = sysfs_blkdev_get_devno(pc);
+	if (!is_part) {
+		/*
+		 * unpartitioned device
+		 */
+		if (diskname && !sysfs_blkdev_get_name(pc, diskname, len))
+			goto err;
+		if (diskdevno)
+			*diskdevno = sysfs_blkdev_get_devno(pc);
+	} else {
+		/*
+		 * partitioned device
+		 *  - readlink /sys/dev/block/8:1   = ../../block/sda/sda1
+		 *  - dirname  ../../block/sda/sda1 = ../../block/sda
+		 *  - basename ../../block/sda	  = sda
+		 */
+		char linkpath[PATH_MAX];
+		char *name;
+		ssize_t	linklen;
 
-    } else {
-        /*
-         * partitioned device
-         *  - readlink /sys/dev/block/8:1   = ../../block/sda/sda1
-         *  - dirname  ../../block/sda/sda1 = ../../block/sda
-         *  - basename ../../block/sda      = sda
-         */
-        char linkpath[PATH_MAX];
-        char *name;
-	ssize_t	linklen;
+		linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath), NULL);
+		if (linklen < 0)
+			goto err;
 
-	linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath), NULL);
-        if (linklen < 0)
-            goto err;
+		stripoff_last_component(linkpath);	  /* dirname */
+		name = stripoff_last_component(linkpath);   /* basename */
+		if (!name)
+			goto err;
 
-        stripoff_last_component(linkpath);      /* dirname */
-        name = stripoff_last_component(linkpath);   /* basename */
-        if (!name)
-            goto err;
+		sysfs_devname_sys_to_dev(name);
+		if (diskname && len)
+			xstrncpy(diskname, name, len);
 
-	sysfs_devname_sys_to_dev(name);
-        if (diskname && len)
-            xstrncpy(diskname, name, len);
-
-        if (diskdevno) {
-            *diskdevno = __sysfs_devname_to_devno(ul_path_get_prefix(pc), name, NULL);
-            if (!*diskdevno)
-                goto err;
-        }
-    }
+		if (diskdevno) {
+			*diskdevno = __sysfs_devname_to_devno(ul_path_get_prefix(pc), name, NULL);
+			if (!*diskdevno)
+				goto err;
+		}
+	}
 
 done:
-    return 0;
+	return 0;
 err:
-    return -1;
+	return -1;
 }
 
 int sysfs_devno_to_wholedisk(dev_t devno, char *diskname,
@@ -790,7 +789,7 @@ char *sysfs_blkdev_scsi_host_strdup_attribute(struct path_cxt *pc,
 		return NULL;
 
 	if (!(f = fopen(buf, "r" UL_CLOEXECSTR)))
-                return NULL;
+		return NULL;
 
 	rc = fscanf(f, "%1023[^\n]", buf);
 	fclose(f);
@@ -1093,7 +1092,7 @@ char *sysfs_chrdev_devno_to_devname(dev_t devno, char *buf, size_t bufsiz)
 	if (!pc)
 		return NULL;
 
-        /* read /sys/dev/char/<maj:min> link */
+	/* read /sys/dev/char/<maj:min> link */
 	sz = ul_path_readlink(pc, link, sizeof(link), NULL);
 	ul_unref_path(pc);
 
diff --git a/lib/timer.c b/lib/timer.c
index cfa18f6fd..2f7e90cd4 100644
--- a/lib/timer.c
+++ b/lib/timer.c
@@ -92,7 +92,7 @@ int setup_timer(struct ul_timer *timer,
 void cancel_timer(struct ul_timer *timer)
 {
 	setitimer(ITIMER_REAL, &timer->old_timer, NULL);
-        sigaction(SIGALRM, &timer->old_sa, NULL);
+	sigaction(SIGALRM, &timer->old_sa, NULL);
 
 }
 #endif /* !HAVE_TIMER_CREATE */
diff --git a/login-utils/login.c b/login-utils/login.c
index 604d63c23..84a361d73 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1306,8 +1306,8 @@ static void load_credentials(struct login_context *cxt) {
 	struct path_cxt *pc;
 
 	env = safe_getenv("CREDENTIALS_DIRECTORY");
-        if (!env)
-                return;
+	if (!env)
+		return;
 
 	pc = ul_new_path("%s", env);
 	if (!pc) {
diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c
index 93eeab111..7faf19da1 100644
--- a/login-utils/sulogin-consoles.c
+++ b/login-utils/sulogin-consoles.c
@@ -124,7 +124,7 @@ void emergency_do_mounts(void)
 	if (stat("/dev", &xt) == 0
 	    && rt.st_dev == xt.st_dev
 	    && mount("devtmpfs", "/dev", "devtmpfs",
-		     MS_RELATIME, "mode=0755,nr_inodes=0") == 0) {
+	             MS_RELATIME, "mode=0755,nr_inodes=0") == 0) {
 
 		emergency_flags |= MNT_DEVTMPFS;
 		mknod("/dev/console", S_IFCHR|S_IRUSR|S_IWUSR,
@@ -249,9 +249,9 @@ char* scandev(DIR *dir, const dev_t comparedev)
 			    "/dev/char/%u:%u", major(comparedev), minor(comparedev))) > 0 &&
 	    (size_t)len < sizeof(path)) {
 
-	    name = realpath(path, NULL);
-	    if (name)
-		    goto out;
+		name = realpath(path, NULL);
+		if (name)
+			goto out;
 	}
 
 	fd = dirfd(dir);
@@ -771,7 +771,7 @@ console:
 fallback:
 	if (fallback >= 0) {
 		const char *name;
-	        char *n;
+		char *n;
 		struct console *console;
 
 		if (device && *device != '\0')
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 78511dca7..f1526bcad 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -812,14 +812,14 @@ static char *get_tabdiff_data(struct libmnt_fs *old_fs,
 		break;
 	case COL_OLD_OPTIONS:
 		if (old_fs && (change == MNT_TABDIFF_REMOUNT ||
-			       change == MNT_TABDIFF_UMOUNT)
+		               change == MNT_TABDIFF_UMOUNT)
 		           && mnt_fs_get_options(old_fs))
 			str = xstrdup(mnt_fs_get_options(old_fs));
 		break;
 	case COL_OLD_TARGET:
 		if (old_fs && (change == MNT_TABDIFF_MOVE ||
-			       change == MNT_TABDIFF_UMOUNT)
-			   && mnt_fs_get_target(old_fs))
+		               change == MNT_TABDIFF_UMOUNT)
+		           && mnt_fs_get_target(old_fs))
 			str = xstrdup(mnt_fs_get_target(old_fs));
 		break;
 	default:
@@ -1519,10 +1519,10 @@ static void __attribute__((__noreturn__)) usage(void)
 
 	fputs(USAGE_HEADER, out);
 	fprintf(out, _(
-	" %1$s [options]\n"
-	" %1$s [options] <device> | <mountpoint>\n"
-	" %1$s [options] <device> <mountpoint>\n"
-	" %1$s [options] [--source <device>] [--target <path> | --mountpoint <dir>]\n"),
+		" %1$s [options]\n"
+		" %1$s [options] <device> | <mountpoint>\n"
+		" %1$s [options] <device> <mountpoint>\n"
+		" %1$s [options] [--source <device>] [--target <path> | --mountpoint <dir>]\n"),
 		program_invocation_short_name);
 
 	fputs(USAGE_SEPARATOR, out);
@@ -1677,7 +1677,7 @@ static struct libscols_table *init_scols_table(struct findmnt *findmnt)
 						scols_wrapzero_nextchunk,
 						NULL);
 		if ((flags & FL_JSON) || use_filter)
-	                scols_column_set_json_type(cl, get_column_json_type(id, fl, NULL,
+			scols_column_set_json_type(cl, get_column_json_type(id, fl, NULL,
 									    flags));
 	}
 
diff --git a/misc-utils/lastlog2.c b/misc-utils/lastlog2.c
index e973b5461..be33f2ae3 100644
--- a/misc-utils/lastlog2.c
+++ b/misc-utils/lastlog2.c
@@ -68,10 +68,9 @@ static int print_entry(const char *user, int64_t ll_time,
 	/* Print only if newer than t days */
 	if (tflg && ((time (NULL) - ll_time) > t_days))
 		return 0;
-        /* this is necessary if you compile this on architectures with
-           a 32bit time_t type. */
-        time_t t_time = ll_time;
-        tm = localtime_r(&t_time, &tm_buf);
+	/* This is needed on architectures with a 32bit time_t type. */
+	time_t t_time = ll_time;
+	tm = localtime_r(&t_time, &tm_buf);
 	if (tm == NULL)
 		datep = "(unknown)";
 	else {
diff --git a/misc-utils/lsblk-devtree.c b/misc-utils/lsblk-devtree.c
index 07f67b4da..5e9d38da1 100644
--- a/misc-utils/lsblk-devtree.c
+++ b/misc-utils/lsblk-devtree.c
@@ -160,7 +160,7 @@ int lsblk_device_new_dependence(struct lsblk_device *parent, struct lsblk_device
 	dp->parent = parent;
 	list_add_tail(&dp->ls_parents, &child->parents);
 
-        DBG(DEV, ul_debugobj(parent, "add dependence 0x%p [%s->%s]", dp, parent->name, child->name));
+	DBG(DEV, ul_debugobj(parent, "add dependence 0x%p [%s->%s]", dp, parent->name, child->name));
 
 	return 0;
 }
@@ -307,16 +307,16 @@ int lsblk_devtree_add_root(struct lsblk_devtree *tr, struct lsblk_device *dev)
 	/* We don't increment reference counter for tr->roots list. The primary
 	 * reference is tr->devices */
 
-        DBG(TREE, ul_debugobj(tr, "add root device 0x%p [%s]", dev, dev->name));
-        list_add_tail(&dev->ls_roots, &tr->roots);
+	DBG(TREE, ul_debugobj(tr, "add root device 0x%p [%s]", dev, dev->name));
+	list_add_tail(&dev->ls_roots, &tr->roots);
 	return 0;
 }
 
 int lsblk_devtree_remove_root(struct lsblk_devtree *tr __attribute__((unused)),
 			      struct lsblk_device *dev)
 {
-        DBG(TREE, ul_debugobj(tr, "remove root device 0x%p [%s]", dev, dev->name));
-        list_del_init(&dev->ls_roots);
+	DBG(TREE, ul_debugobj(tr, "remove root device 0x%p [%s]", dev, dev->name));
+	list_del_init(&dev->ls_roots);
 
 	return 0;
 }
@@ -343,8 +343,8 @@ int lsblk_devtree_add_device(struct lsblk_devtree *tr, struct lsblk_device *dev)
 {
 	lsblk_ref_device(dev);
 
-        DBG(TREE, ul_debugobj(tr, "add device 0x%p [%s]", dev, dev->name));
-        list_add_tail(&dev->ls_devices, &tr->devices);
+	DBG(TREE, ul_debugobj(tr, "add device 0x%p [%s]", dev, dev->name));
+	list_add_tail(&dev->ls_devices, &tr->devices);
 	return 0;
 }
 
@@ -398,7 +398,7 @@ struct lsblk_device *lsblk_devtree_get_device(struct lsblk_devtree *tr, const ch
 
 int lsblk_devtree_remove_device(struct lsblk_devtree *tr, struct lsblk_device *dev)
 {
-        DBG(TREE, ul_debugobj(tr, "remove device 0x%p [%s]", dev, dev->name));
+	DBG(TREE, ul_debugobj(tr, "remove device 0x%p [%s]", dev, dev->name));
 
 	if (!lsblk_devtree_has_device(tr, dev))
 		return 1;
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index d7bf4c5d7..629c48840 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -147,8 +147,8 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
 	ssize_t ssz;
 	struct stat sb;
 
-	if ( faccessat(AT_FDCWD, s, F_OK, AT_SYMLINK_NOFOLLOW) != 0 &&
-	     errno != EINVAL )
+	if (faccessat(AT_FDCWD, s, F_OK, AT_SYMLINK_NOFOLLOW) != 0 &&
+	    errno != EINVAL )
 	   /* Skip if AT_SYMLINK_NOFOLLOW is not supported; lstat() below will
 	      detect the access error */
 	{
diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c
index 8e38f8d61..740d4f3c6 100644
--- a/sys-utils/ipcrm.c
+++ b/sys-utils/ipcrm.c
@@ -78,7 +78,7 @@ static void __attribute__((__noreturn__)) usage(void)
 
 static int remove_id(int type, int iskey, int id)
 {
-        int ret;
+	int ret;
 	char *errmsg;
 	/* needed to delete semaphores */
 	union semun arg;
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
index 0bc97c903..eba8da126 100644
--- a/sys-utils/ldattach.c
+++ b/sys-utils/ldattach.c
@@ -304,9 +304,9 @@ int main(int argc, char **argv)
 		{"help", no_argument, NULL, 'h'},
 		{"version", no_argument, NULL, 'V'},
 		{"debug", no_argument, NULL, 'd'},
-	        {"intro-command", required_argument, NULL, 'c'},
-	        {"pause", required_argument, NULL, 'p'},
-	        {"mtu", required_argument, NULL, 'm'},
+		{"intro-command", required_argument, NULL, 'c'},
+		{"pause", required_argument, NULL, 'p'},
+		{"mtu", required_argument, NULL, 'm'},
 		{NULL, 0, NULL, 0}
 	};
 
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index fe30d70da..be8bfd933 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -830,7 +830,7 @@ int main(int argc, char **argv)
 		case OPT_SIZELIMIT:			/* --sizelimit */
 			sizelimit = strtosize_or_err(optarg, _("failed to parse size"));
 			flags |= LOOPDEV_FL_SIZELIMIT;
-                        break;
+			break;
 
 		case 'h':
 			usage();
diff --git a/sys-utils/lscpu-topology.c b/sys-utils/lscpu-topology.c
index 6e0782f64..460ba449b 100644
--- a/sys-utils/lscpu-topology.c
+++ b/sys-utils/lscpu-topology.c
@@ -465,7 +465,7 @@ static int read_caches(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
 		if (ul_path_readf_s32(sys, &level, "cpu%d/cache/index%zu/level", num, i) != 0)
 			continue;
 		if (ul_path_readf_buffer(sys, buf, sizeof(buf),
-                                        "cpu%d/cache/index%zu/type", num, i) <= 0)
+		                         "cpu%d/cache/index%zu/type", num, i) <= 0)
 			continue;
 
 		if (id == -1)
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 2b7337777..dd94e8ab4 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -1593,16 +1593,16 @@ static void __attribute__((__noreturn__)) usage(void)
 
 static void __attribute__((__noreturn__)) list_colunms(struct lsns *ls)
 {
-   struct libscols_table *col_tb = xcolumn_list_table_new("lsns-columns", stdout, ls->raw, ls->json);
+	struct libscols_table *col_tb = xcolumn_list_table_new("lsns-columns", stdout, ls->raw, ls->json);
 
-   for (size_t i = 0; i < ARRAY_SIZE(infos); i++)
-           xcolumn_list_table_append_line(col_tb, infos[i].name,
-					  infos[i].json_type, NULL,
-					  _(infos[i].help));
-   scols_print_table(col_tb);
-   scols_unref_table(col_tb);
+	for (size_t i = 0; i < ARRAY_SIZE(infos); i++)
+		xcolumn_list_table_append_line(col_tb, infos[i].name,
+					       infos[i].json_type, NULL,
+					       _(infos[i].help));
+	scols_print_table(col_tb);
+	scols_unref_table(col_tb);
 
-   exit(EXIT_SUCCESS);
+	exit(EXIT_SUCCESS);
 }
 
 static int stat_self_ns (const char *ns, struct stat *st)
diff --git a/sys-utils/swapoff.c b/sys-utils/swapoff.c
index 21c8e1ee8..152d1e11b 100644
--- a/sys-utils/swapoff.c
+++ b/sys-utils/swapoff.c
@@ -96,7 +96,7 @@ static char *resolve_swapfile_tag(const char *name, const char *value)
 
 static int do_swapoff(const char *orig_special, int quiet, int canonic)
 {
-        const char *special = orig_special;
+	 const char *special = orig_special;
 	char *buf = NULL;
 	int rc = SWAPOFF_EX_OK;
 
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 68b795d3b..3ada170db 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
 	/* Need to open O_NONBLOCK in case ABORTOPEN is already set
 	 * and printer is off or off-line or in an error condition.
 	 * Otherwise we would abort...
-         */
+	 */
 	if (fd < 0)
 		err(EXIT_FAILURE, "%s", filename);
 
@@ -264,7 +264,7 @@ int main(int argc, char **argv)
 	 */
 	if (LPGETIRQ >= 0x0600 && ioctl(fd, LPGETIRQ, &irq) < 0
 	    && errno == EINVAL)
-	        /* We don't understand the new ioctls */
+		/* We don't understand the new ioctls */
 		offset = 0x0600;
 
 	cmds = cmdst;
diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c
index 11aeae48e..7b177e618 100644
--- a/sys-utils/unshare.c
+++ b/sys-utils/unshare.c
@@ -1038,7 +1038,7 @@ int main(int argc, char *argv[])
 				kill_child_signo = SIGKILL;
 			}
 			break;
-                case OPT_KEEPCAPS:
+		case OPT_KEEPCAPS:
 			keepcaps = 1;
 			cap_last_cap(); /* Force last cap to be cached before we fork. */
 			break;
@@ -1056,11 +1056,11 @@ int main(int argc, char *argv[])
 		case 'w':
 			newdir = optarg;
 			break;
-                case OPT_MONOTONIC:
+		case OPT_MONOTONIC:
 			monotonic = strtos64_or_err(optarg, _("failed to parse monotonic offset"));
 			force_monotonic = 1;
 			break;
-                case OPT_BOOTTIME:
+		case OPT_BOOTTIME:
 			boottime = strtos64_or_err(optarg, _("failed to parse boottime offset"));
 			force_boottime = 1;
 			break;
@@ -1206,13 +1206,13 @@ int main(int argc, char *argv[])
 #endif
 	}
 
-        if (mapuser != (uid_t) -1 && !usermap)
+	if (mapuser != (uid_t) -1 && !usermap)
 		map_id(_PATH_PROC_UIDMAP, mapuser, real_euid);
 
-        /* Since Linux 3.19 unprivileged writing of /proc/self/gid_map
-         * has been disabled unless /proc/self/setgroups is written
-         * first to permanently disable the ability to call setgroups
-         * in that user namespace. */
+	/* Since Linux 3.19 unprivileged writing of /proc/self/gid_map
+	 * has been disabled unless /proc/self/setgroups is written
+	 * first to permanently disable the ability to call setgroups
+	 * in that user namespace. */
 	if (mapgroup != (gid_t) -1 && !groupmap) {
 		if (setgrpcmd == SETGROUPS_ALLOW)
 			errx(EXIT_FAILURE, _("options --setgroups=allow and "
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 057e4a3c0..a890d1b9d 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -224,7 +224,7 @@ static int zram_wait_initialized(struct zram *z)
 	/* Wait up to 3 seconds. */
 	r = sd_event_add_time_relative(event, NULL, CLOCK_BOOTTIME, 3 * 1000 * 1000, 0, NULL, (void*) (intptr_t) (-ETIMEDOUT));
 	if (r < 0)
-	        return r;
+		return r;
 
 	/* Check if the device is already initialized. */
 #if HAVE_DECL_SD_DEVICE_OPEN
@@ -277,7 +277,7 @@ static int zram_lock(struct zram *z, int operation)
 #if HAVE_DECL_SD_DEVICE_OPEN
 	if (z->device) {
 		fd = sd_device_open(z->device, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
-	        if (fd < 0)
+		if (fd < 0)
 			return fd;
 	} else {
 #endif
@@ -909,7 +909,7 @@ int main(int argc, char **argv)
 		if (outarg && string_add_to_idarray(outarg,
 					columns, ARRAY_SIZE(columns),
 					&ncolumns, column_name_to_id) < 0)
-	                return EXIT_FAILURE;
+			return EXIT_FAILURE;
 
 		if (optind < argc) {
 			zram = new_zram(argv[optind++]);
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index f4d720448..d3b650023 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1706,8 +1706,8 @@ static int issuefile_read_stream(struct issue *ie, FILE *f, struct options *op,
 static int issuedir_read(struct issue *ie, const char *dirname,
 			 struct options *op, struct termios *tp)
 {
-        int dd, nfiles, i;
-        struct dirent **namelist = NULL;
+	int dd, nfiles, i;
+	struct dirent **namelist = NULL;
 
 	dd = open(dirname, O_RDONLY|O_CLOEXEC|O_DIRECTORY);
 	if (dd < 0)
@@ -1943,9 +1943,9 @@ skip:
 	struct list_head *current = NULL;
 	char *name = NULL;
 
-        /* Reading all issue files and concatinating all contents to one content.
-         * The ordering rules are defineded in:
-         * https://github.com/uapi-group/specifications/blob/main/specs/configuration_files_specification.md
+	/* Reading all issue files and concatinating all contents to one content.
+	 * The ordering rules are defineded in:
+	 * https://github.com/uapi-group/specifications/blob/main/specs/configuration_files_specification.md
 	 *
 	 * Note that _PATH_RUNSTATEDIR (/run) is always read by ul_configs_file_list().
 	 */
@@ -3120,8 +3120,8 @@ static void load_credentials(struct options *op) {
 	struct path_cxt *pc;
 
 	env = safe_getenv("CREDENTIALS_DIRECTORY");
-        if (!env)
-                return;
+	if (!env)
+		return;
 
 	pc = ul_new_path("%s", env);
 	if (!pc) {
diff --git a/term-utils/mesg.c b/term-utils/mesg.c
index 3ff3b9e04..e51f659a6 100644
--- a/term-utils/mesg.c
+++ b/term-utils/mesg.c
@@ -173,8 +173,8 @@ int main(int argc, char *argv[])
 	case RPMATCH_INVALID:
 		warnx(_("invalid argument: %s"), argv[0]);
 		errtryhelp(EXIT_FAILURE);
-        default:
-                abort();
+	default:
+		abort();
 	}
 	close(fd);
 	return ret;
diff --git a/term-utils/script.c b/term-utils/script.c
index 4e302347f..8076df41c 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -1078,7 +1078,7 @@ int main(int argc, char **argv)
 			log_info(&ctl, "INPUT_LOG", "%s", infile);
 	}
 
-        /* this is the main loop */
+	/* this is the main loop */
 	rc = ul_pty_proxy_master(ctl.pty);
 
 	/* all done; cleanup and kill */
diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c
index 7e1eec7db..3efcd3015 100644
--- a/term-utils/scriptreplay.c
+++ b/term-utils/scriptreplay.c
@@ -175,8 +175,8 @@ main(int argc, char *argv[])
 	char streams[6] = {0};		/* IOSI - in, out, signal,info */
 	const char *log_out = NULL,
 	           *log_in = NULL,
-		   *log_io = NULL,
-		   *log_tm = NULL;
+	           *log_io = NULL,
+	           *log_tm = NULL;
 	double divi = 1;
 	int diviopt = FALSE, idx;
 	int ch, rc = 0, crmode = REPLAY_CRMODE_AUTO, summary = 0;
diff --git a/text-utils/col.c b/text-utils/col.c
index 5866d7d0e..ddf2a6109 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -601,45 +601,44 @@ static void free_line_allocations(struct col_alloc *root)
 
 static void process_char(struct col_ctl *ctl, struct col_lines *lns)
 {
-                /* Deal printable characters */
-                if (!iswgraph(lns->ch) && handle_not_graphic(ctl, lns))
-                        return;
+	/* Deal with non-printable characters. */
+	if (!iswgraph(lns->ch) && handle_not_graphic(ctl, lns))
+		return;
 
-                /* Must stuff ch in a line - are we at the right one? */
-                if ((size_t)lns->cur_line != lns->this_line - lns->adjust)
-                        update_cur_line(ctl, lns);
+	/* Must stuff ch in a line - are we at the right one? */
+	if ((size_t)lns->cur_line != lns->this_line - lns->adjust)
+		update_cur_line(ctl, lns);
 
-                /* Does line buffer need to grow? */
-                if (ctl->l->l_lsize <= ctl->l->l_line_len + 1) {
-                        size_t need;
+	/* Does line buffer need to grow? */
+	if (ctl->l->l_lsize <= ctl->l->l_line_len + 1) {
+		size_t need;
 
-                        need = ctl->l->l_lsize ? ctl->l->l_lsize * 2 : NALLOC;
-                        ctl->l->l_line = xrealloc(ctl->l->l_line, need * sizeof(struct col_char));
-                        ctl->l->l_lsize = need;
-                }
+		need = ctl->l->l_lsize ? ctl->l->l_lsize * 2 : NALLOC;
+		ctl->l->l_line = xrealloc(ctl->l->l_line, need * sizeof(struct col_char));
+		ctl->l->l_lsize = need;
+	}
 
-                /* Store character */
-                lns->c = &ctl->l->l_line[ctl->l->l_line_len++];
-                lns->c->c_char = lns->ch;
-                lns->c->c_set = lns->cur_set;
+	/* Store character */
+	lns->c = &ctl->l->l_line[ctl->l->l_line_len++];
+	lns->c->c_char = lns->ch;
+	lns->c->c_set = lns->cur_set;
 
-                if (0 < lns->cur_col)
-                        lns->c->c_column = lns->cur_col;
-                else
-                        lns->c->c_column = 0;
-                lns->c->c_width = wcwidth(lns->ch);
-
-                /*
-                 * If things are put in out of order, they will need sorting
-                 * when it is flushed.
-                 */
-                if (lns->cur_col < ctl->l->l_max_col)
-                        ctl->l->l_needs_sort = 1;
-                else
-                        ctl->l->l_max_col = lns->cur_col;
-                if (0 < lns->c->c_width)
-                        lns->cur_col += lns->c->c_width;
+	if (0 < lns->cur_col)
+		lns->c->c_column = lns->cur_col;
+	else
+		lns->c->c_column = 0;
+	lns->c->c_width = wcwidth(lns->ch);
 
+	/*
+	 * If things are put in out of order, they will need sorting
+	 * when it is flushed.
+	 */
+	if (lns->cur_col < ctl->l->l_max_col)
+		ctl->l->l_needs_sort = 1;
+	else
+		ctl->l->l_max_col = lns->cur_col;
+	if (0 < lns->c->c_width)
+		lns->cur_col += lns->c->c_width;
 }
 
 int main(int argc, char **argv)
diff --git a/text-utils/hexdump-display.c b/text-utils/hexdump-display.c
index c865127c8..b605cad44 100644
--- a/text-utils/hexdump-display.c
+++ b/text-utils/hexdump-display.c
@@ -448,7 +448,7 @@ doskip(const char *fname, int statok, struct hexdump *hex)
 
 	if (statok) {
 		if (fstat(fileno(stdin), &sbuf))
-		        err(EXIT_FAILURE, "%s", fname);
+			err(EXIT_FAILURE, "%s", fname);
 		if (S_ISREG(sbuf.st_mode) && hex->skip > sbuf.st_size) {
 		  /* If size valid and skip >= size */
 			hex->skip -= sbuf.st_size;
@@ -458,7 +458,7 @@ doskip(const char *fname, int statok, struct hexdump *hex)
 	}
 	/* sbuf may be undefined here - do not test it */
 	if (fseek(stdin, hex->skip, SEEK_SET))
-	        err(EXIT_FAILURE, "%s", fname);
+		err(EXIT_FAILURE, "%s", fname);
 	address += hex->skip;
 	hex->skip = 0;
 }
diff --git a/text-utils/hexdump-parse.c b/text-utils/hexdump-parse.c
index 018013e5e..efc39c3b3 100644
--- a/text-utils/hexdump-parse.c
+++ b/text-utils/hexdump-parse.c
@@ -52,22 +52,22 @@ static struct list_head *color_fmt(char *cfmt, int bcnt);
 
 static void __attribute__ ((__noreturn__)) badcnt(const char *s)
 {
-        errx(EXIT_FAILURE, _("bad byte count for conversion character %s"), s);
+	errx(EXIT_FAILURE, _("bad byte count for conversion character %s"), s);
 }
 
 static void __attribute__ ((__noreturn__)) badsfmt(void)
 {
-        errx(EXIT_FAILURE, _("%%s requires a precision or a byte count"));
+	errx(EXIT_FAILURE, _("%%s requires a precision or a byte count"));
 }
 
 static void __attribute__ ((__noreturn__)) badfmt(const char *fmt)
 {
-        errx(EXIT_FAILURE, _("bad format {%s}"), fmt);
+	errx(EXIT_FAILURE, _("bad format {%s}"), fmt);
 }
 
 static void __attribute__ ((__noreturn__)) badconv(const char *ch)
 {
-        errx(EXIT_FAILURE, _("bad conversion character %%%s"), ch);
+	errx(EXIT_FAILURE, _("bad conversion character %%%s"), ch);
 }
 
 #define first_letter(s,f) strchr(f, *(s))
@@ -81,7 +81,7 @@ void addfile(char *name, struct hexdump *hex)
 	size_t n = 0;
 
 	if ((fp = fopen(name, "r")) == NULL)
-	        err(EXIT_FAILURE, _("can't read %s"), name);
+		err(EXIT_FAILURE, _("can't read %s"), name);
 
 	while (getline(&buf, &n, fp) != -1) {
 		fmt = buf;
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index 60bf6f94b..ba8d5e1f6 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -116,7 +116,7 @@ parse_args(int argc, char **argv, struct hexdump *hex)
 			colormode = UL_COLORMODE_AUTO;
 			if (optarg)
 				colormode = colormode_or_err(optarg);
-                        break;
+			break;
 		case 'n':
 			hex->length = strtosize_or_err(optarg, _("failed to parse length"));
 			break;
-- 
2.51.2


^ permalink raw reply related

* Re: v2.41.3 planning
From: Chris Hofstaedtler @ 2025-12-09 18:50 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <ajxw7xn6mh3puhs44cmj5mxxe7stxqwqi3vzzzueqa4srn2zgx@iukpxdgp4dkk>

Hi Karel,

* Karel Zak <kzak@redhat.com> [251208 15:01]:
>I'd like to release the stable update v2.41.3, primarily to provide an
>upstream tarball with the fixed CVE-2025-14104 and to fix compilation
>with gcc-15, along with some other minor fixes.
>
>Do you see anything in the master branch that we need to include in
>this stable maintenance update?

Thank you. In Debian we picked c332544d215ccb466a64a441eb5a421b9fe8cdfd
"lscpu: use maximum CPU speed from DMI, avoid duplicate version 
string" because that seemed like a good fix to have.

I think this is not in stable/v2.41 so far. *Maybe* you want to 
consider it.

Best,
Chris


^ permalink raw reply

* Re: v2.41.3 planning
From: Masatake YAMATO @ 2025-12-09 21:35 UTC (permalink / raw)
  To: kzak; +Cc: util-linux
In-Reply-To: <ajxw7xn6mh3puhs44cmj5mxxe7stxqwqi3vzzzueqa4srn2zgx@iukpxdgp4dkk>

> 
> 
> Hi all,
> 
> I'd like to release the stable update v2.41.3, primarily to provide an
> upstream tarball with the fixed CVE-2025-14104 and to fix compilation
> with gcc-15, along with some other minor fixes.
> 
> Do you see anything in the master branch that we need to include in
> this stable maintenance update?
> 
> For the current state, see the stable/2.41 branch.

I made a pull request about lsfd.
https://github.com/util-linux/util-linux/pull/3896

Masatake YAMATO

>     Karel
>     
> -- 
>  Karel Zak  <kzak@redhat.com>
>  http://karelzak.blogspot.com
> 
> 


^ permalink raw reply

* Re: v2.41.3 planning
From: Karel Zak @ 2025-12-10  9:40 UTC (permalink / raw)
  To: Chris Hofstaedtler; +Cc: util-linux
In-Reply-To: <oegibjegz34kkaahppwq6rkpitwc5hd6bmpne7ubpn7e4vb35e@wwbtzujfrvzo>

On Tue, Dec 09, 2025 at 07:50:59PM +0100, Chris Hofstaedtler wrote:
> Hi Karel,
> 
> * Karel Zak <kzak@redhat.com> [251208 15:01]:
> > I'd like to release the stable update v2.41.3, primarily to provide an
> > upstream tarball with the fixed CVE-2025-14104 and to fix compilation
> > with gcc-15, along with some other minor fixes.
> > 
> > Do you see anything in the master branch that we need to include in
> > this stable maintenance update?
> 
> Thank you. In Debian we picked c332544d215ccb466a64a441eb5a421b9fe8cdfd
> "lscpu: use maximum CPU speed from DMI, avoid duplicate version string"
> because that seemed like a good fix to have.
> 
> I think this is not in stable/v2.41 so far. *Maybe* you want to consider it.

Applied, thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: v2.41.3 planning
From: Karel Zak @ 2025-12-10  9:40 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: util-linux
In-Reply-To: <20251210.063501.976895848370886654.yamato@redhat.com>

On Wed, Dec 10, 2025 at 06:35:01AM +0900, Masatake YAMATO wrote:
> I made a pull request about lsfd.
> https://github.com/util-linux/util-linux/pull/3896

Applied, thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Partition incorrectly identified as LUKS
From: Anthony Rossomano @ 2025-12-11 15:20 UTC (permalink / raw)
  To: util-linux

OS: AlmaLinux 8.9
util-linux-2.32.1-44.el8_9.1.x86_64

LUKS image is stored on XFS partition. When secondary LUKS signature winds up at one of the offsets checked by libblkid partition then we have the side effects of partition reported with crypto_LUKS fstype, no by-label link created by udev, mount requires fstype, etc

Don’t think that this has been addressed upstream but need to confirm.

Also looking for input about possible workarounds.

^ permalink raw reply

* [PATCH 0/3] blkpr: add read-keys and read-reservations commands
From: Stefan Hajnoczi @ 2025-12-11 16:09 UTC (permalink / raw)
  To: util-linux; +Cc: pizhenwei, hare, kwolf, Stefan Hajnoczi

New <linux/pr.h> ioctls make it possible to fetch the list of registered keys
and the details of the current reservation from a block device. The relevant
Linux commits are:

3e2cb9ee76c27 block: add IOC_PR_READ_RESERVATION ioctl
22a1ffea5f805 block: add IOC_PR_READ_KEYS ioctl

Add the appropriate commands to blkpr. Users can use these for troubleshooting
and cluster management tools may use them to query the state of persistent
reservations during recovery.

Stefan Hajnoczi (3):
  blkpr: prepare for _IOR() ioctls
  blkpr: add read-keys command
  blkpr: add read-reservation command

 meson.build            |   6 +++
 sys-utils/blkpr.c      | 106 ++++++++++++++++++++++++++++++++++++++---
 configure.ac           |   8 ++++
 sys-utils/blkpr.8.adoc |   3 +-
 4 files changed, 115 insertions(+), 8 deletions(-)

-- 
2.52.0


^ permalink raw reply

* [PATCH 2/3] blkpr: add read-keys command
From: Stefan Hajnoczi @ 2025-12-11 16:09 UTC (permalink / raw)
  To: util-linux; +Cc: pizhenwei, hare, kwolf, Stefan Hajnoczi
In-Reply-To: <20251211160956.1540114-1-stefanha@redhat.com>

The new IOC_PR_READ_KEYS ioctl lists registered keys on a device. Add a
command so that users can inspect keys. This is useful both for
troubleshooting and for recovery scenarios.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 meson.build            |  3 +++
 sys-utils/blkpr.c      | 46 ++++++++++++++++++++++++++++++++++++++++++
 configure.ac           |  4 ++++
 sys-utils/blkpr.8.adoc |  3 ++-
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 8b7880e46..47b43c2af 100644
--- a/meson.build
+++ b/meson.build
@@ -765,6 +765,9 @@ conf.set('HAVE_DECL_BLK_ZONE_REP_CAPACITY', have ? 1 : false)
 have = cc.has_header_symbol('linux/pr.h', 'PR_REP_CAPACITY')
 conf.set('HAVE_DECL_PR_REP_CAPACITY', have ? 1 : false)
 
+have = cc.has_header_symbol('linux/pr.h', 'IOC_PR_READ_KEYS')
+conf.set('HAVE_DECL_IOC_PR_READ_KEYS', have ? 1 : false)
+
 code = '''
 #include <time.h>
 #if !@0@
diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c
index c6b030def..843ef7da1 100644
--- a/sys-utils/blkpr.c
+++ b/sys-utils/blkpr.c
@@ -103,6 +103,12 @@ static const struct type_string pr_command[] = {
 	{IOC_PR_CLEAR,         "clear",
 	"  * clear: This command unregisters both key and any other reservation\n"
 	"    key registered with the device and drops any existing reservation.\n"},
+
+#if HAVE_DECL_IOC_PR_READ_KEYS
+	{IOC_PR_READ_KEYS,     "read-keys",
+	"  * read-keys: This command lists reservation keys currently registered\n"
+	"    with the device.\n"},
+#endif
 };
 
 static const struct type_string pr_flag[] = {
@@ -151,6 +157,41 @@ PARSE(pr_type)
 PARSE(pr_command)
 PARSE(pr_flag)
 
+#if HAVE_DECL_IOC_PR_READ_KEYS
+static int do_pr_read_keys(int fd)
+{
+	struct pr_read_keys pr_rk;
+	uint32_t num_keys = 8;
+	uint64_t *keys = NULL;
+	int ret;
+
+	/* Loop to grow keys[] until it is large enough */
+	do {
+		num_keys *= 2;
+		keys = xreallocarray(keys, num_keys, sizeof(keys[0]));
+
+		pr_rk.keys_ptr = (uintptr_t)keys;
+		pr_rk.num_keys = num_keys;
+
+		ret = ioctl(fd, IOC_PR_READ_KEYS, &pr_rk);
+		if (ret)
+			goto out;
+	} while (pr_rk.num_keys > num_keys);
+
+	if (pr_rk.num_keys) {
+		for (uint32_t i = 0; i < pr_rk.num_keys; i++) {
+			printf(_("%#" PRIx64 "\n"), (uint64_t)keys[i]);
+		}
+	} else {
+		printf(_("No registered keys\n"));
+	}
+
+out:
+	free(keys);
+	return ret;
+}
+#endif /* HAVE_DECL_IOC_PR_READ_KEYS */
+
 static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, int flag)
 {
 	struct pr_registration pr_reg;
@@ -190,6 +231,11 @@ static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, in
 		pr_clr.flags = flag;
 		ret = ioctl(fd, op, &pr_clr);
 		break;
+#if HAVE_DECL_IOC_PR_READ_KEYS
+	case IOC_PR_READ_KEYS:
+		ret = do_pr_read_keys(fd);
+		break;
+#endif
 	default:
 		errno = EINVAL;
 		err(EXIT_FAILURE, _("unknown command"));
diff --git a/configure.ac b/configure.ac
index a424e0947..bbd2156d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -445,6 +445,10 @@ AC_CHECK_DECLS([PR_REP_CAPACITY], [], [], [
 	#include <linux/pr.h>
 ])
 
+AC_CHECK_DECLS([IOC_PR_READ_KEYS], [], [], [
+	#include <linux/pr.h>
+])
+
 AC_CHECK_HEADERS([security/openpam.h], [], [], [
 #ifdef HAVE_SECURITY_PAM_APPL_H
 #include <security/pam_appl.h>
diff --git a/sys-utils/blkpr.8.adoc b/sys-utils/blkpr.8.adoc
index 98983b779..3a157af38 100644
--- a/sys-utils/blkpr.8.adoc
+++ b/sys-utils/blkpr.8.adoc
@@ -25,7 +25,8 @@ The _device_ argument is the pathname of the block device.
 
 *-c*, *--command* _command_::
 The command for managing persistent reservations. Supported commands are:
-*register*, *reserve*, *release*, *preempt*, *preempt-abort*, and *clear*.
+*register*, *reserve*, *release*, *preempt*, *preempt-abort*, *clear*, and
+*read-keys*.
 
 *-k*, *--key* _key_::
 The key the command should operate on.
-- 
2.52.0


^ permalink raw reply related

* [PATCH 1/3] blkpr: prepare for _IOR() ioctls
From: Stefan Hajnoczi @ 2025-12-11 16:09 UTC (permalink / raw)
  To: util-linux; +Cc: pizhenwei, hare, kwolf, Stefan Hajnoczi
In-Reply-To: <20251211160956.1540114-1-stefanha@redhat.com>

parse_pr_command() returns the ioctl command constant for a given
command or -1 when the command is unknown. Up until now all ioctl
command constants were positive, so the following check worked:

  if (command < 0)
      err(EXIT_FAILURE, _("unknown command"));

The top two bits of ioctl command constants encode the direction (_IO,
_IOR, _IOW, _IOWR). ioctl commands defined with _IOR have negative ioctl
command constants.

Explicitly check for -1 to differentiate "unknown command" from valid
ioctls commands. Later commits will add ioctl commands that use _IOR.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 sys-utils/blkpr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c
index 03ca9f7e5..c6b030def 100644
--- a/sys-utils/blkpr.c
+++ b/sys-utils/blkpr.c
@@ -276,7 +276,7 @@ int main(int argc, char **argv)
 			break;
 		case 'c':
 			command = parse_pr_command(optarg);
-			if (command < 0)
+			if (command == -1)
 				err(EXIT_FAILURE, _("unknown command"));
 			break;
 		case 't':
-- 
2.52.0


^ permalink raw reply related

* [PATCH 3/3] blkpr: add read-reservation command
From: Stefan Hajnoczi @ 2025-12-11 16:09 UTC (permalink / raw)
  To: util-linux; +Cc: pizhenwei, hare, kwolf, Stefan Hajnoczi
In-Reply-To: <20251211160956.1540114-1-stefanha@redhat.com>

The new IOC_PR_READ_RESERVATION ioctl reports the current reservation on
a device. Add a command so that users can inspect the current
reservation. This is useful both for troubleshooting and for recovery
scenarios.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 meson.build            |  3 +++
 sys-utils/blkpr.c      | 60 +++++++++++++++++++++++++++++++++++++-----
 configure.ac           |  4 +++
 sys-utils/blkpr.8.adoc |  4 +--
 4 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/meson.build b/meson.build
index 47b43c2af..b759e992f 100644
--- a/meson.build
+++ b/meson.build
@@ -768,6 +768,9 @@ conf.set('HAVE_DECL_PR_REP_CAPACITY', have ? 1 : false)
 have = cc.has_header_symbol('linux/pr.h', 'IOC_PR_READ_KEYS')
 conf.set('HAVE_DECL_IOC_PR_READ_KEYS', have ? 1 : false)
 
+have = cc.has_header_symbol('linux/pr.h', 'IOC_PR_READ_RESERVATION')
+conf.set('HAVE_DECL_IOC_PR_READ_RESERVATION', have ? 1 : false)
+
 code = '''
 #include <time.h>
 #if !@0@
diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c
index 843ef7da1..0cb73a3bd 100644
--- a/sys-utils/blkpr.c
+++ b/sys-utils/blkpr.c
@@ -73,7 +73,7 @@ static const struct type_string pr_type[] = {
 };
 
 static const struct type_string pr_command[] = {
-	{IOC_PR_REGISTER,      "register",
+	{IOC_PR_REGISTER,         "register",
 	"  * register: This command registers a new reservation if the key argument\n"
 	"    is non-null. If no existing reservation exists oldkey must be zero, if\n"
 	"    an existing reservation should be replaced oldkey must contain the old\n"
@@ -81,34 +81,39 @@ static const struct type_string pr_command[] = {
 	"    reservation passed in oldkey.\n"
 	},
 
-	{IOC_PR_RESERVE,       "reserve",
+	{IOC_PR_RESERVE,          "reserve",
 	"  * reserve: This command reserves the device and thus restricts access for\n"
 	"    other devices based on the type argument.  The key argument must be\n"
 	"    the existing reservation key for the device as acquired by the register,\n"
 	"    preempt, preempt-abort commands.\n"},
 
-	{IOC_PR_RELEASE,       "release",
+	{IOC_PR_RELEASE,          "release",
 	"  * release: This command releases the reservation specified by key and flags\n"
 	"    and thus removes any access restriction implied by it.\n"},
 
-	{IOC_PR_PREEMPT,       "preempt",
+	{IOC_PR_PREEMPT,          "preempt",
 	"  * preempt: This command releases the existing reservation referred to by\n"
 	"    old_key and replaces it with a new reservation of type for the\n"
 	"    reservation key key.\n"},
 
-	{IOC_PR_PREEMPT_ABORT, "preempt-abort",
+	{IOC_PR_PREEMPT_ABORT,    "preempt-abort",
 	"  * preempt-abort: This command works like preempt except that it also aborts\n"
 	"    any outstanding command sent over a connection identified by oldkey.\n"},
 
-	{IOC_PR_CLEAR,         "clear",
+	{IOC_PR_CLEAR,            "clear",
 	"  * clear: This command unregisters both key and any other reservation\n"
 	"    key registered with the device and drops any existing reservation.\n"},
 
 #if HAVE_DECL_IOC_PR_READ_KEYS
-	{IOC_PR_READ_KEYS,     "read-keys",
+	{IOC_PR_READ_KEYS,        "read-keys",
 	"  * read-keys: This command lists reservation keys currently registered\n"
 	"    with the device.\n"},
 #endif
+
+#if HAVE_DECL_IOC_PR_READ_RESERVATION
+	{IOC_PR_READ_RESERVATION, "read-reservation",
+	"  * read-reservation: This command shows the current reservation.\n"},
+#endif
 };
 
 static const struct type_string pr_flag[] = {
@@ -140,6 +145,18 @@ static int parse_type_by_str(const struct type_string *ts, int nmem, char *patte
 	return -1;
 }
 
+static inline const char *type_to_str(const struct type_string *ts, int nmem,
+                                      int type)
+{
+	int i;
+
+	for (i = 0; i < nmem; i++) {
+		if (ts[i].type == type)
+			return ts[i].str;
+	}
+	return "unknown type";
+}
+
 
 #define PRINT_SUPPORTED(XX) \
 	static void print_##XX(FILE *out) \
@@ -192,6 +209,30 @@ out:
 }
 #endif /* HAVE_DECL_IOC_PR_READ_KEYS */
 
+#if HAVE_DECL_IOC_PR_READ_RESERVATION
+static int do_pr_read_reservation(int fd)
+{
+	struct pr_read_reservation pr_rr;
+	const char *type_str;
+	int ret;
+
+	ret = ioctl(fd, IOC_PR_READ_RESERVATION, &pr_rr);
+	if (ret)
+		return ret;
+
+	type_str = type_to_str(pr_type, ARRAY_SIZE(pr_type), pr_rr.type);
+
+	if (pr_rr.key) {
+		printf(_("Key: %#" PRIx64 "\n"), (uint64_t)pr_rr.key);
+		printf(_("Generation: %#x\n"), pr_rr.generation);
+		printf(_("Type: %s\n"), type_str);
+	} else {
+		printf(_("No reservation\n"));
+	}
+	return 0;
+}
+#endif /* HAVE_DECL_IOC_PR_READ_RESERVATION */
+
 static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, int flag)
 {
 	struct pr_registration pr_reg;
@@ -235,6 +276,11 @@ static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, in
 	case IOC_PR_READ_KEYS:
 		ret = do_pr_read_keys(fd);
 		break;
+#endif
+#if HAVE_DECL_IOC_PR_READ_RESERVATION
+	case IOC_PR_READ_RESERVATION:
+		ret = do_pr_read_reservation(fd);
+		break;
 #endif
 	default:
 		errno = EINVAL;
diff --git a/configure.ac b/configure.ac
index bbd2156d7..9dfb12a7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -449,6 +449,10 @@ AC_CHECK_DECLS([IOC_PR_READ_KEYS], [], [], [
 	#include <linux/pr.h>
 ])
 
+AC_CHECK_DECLS([IOC_PR_READ_RESERVATION], [], [], [
+	#include <linux/pr.h>
+])
+
 AC_CHECK_HEADERS([security/openpam.h], [], [], [
 #ifdef HAVE_SECURITY_PAM_APPL_H
 #include <security/pam_appl.h>
diff --git a/sys-utils/blkpr.8.adoc b/sys-utils/blkpr.8.adoc
index 3a157af38..630bafb92 100644
--- a/sys-utils/blkpr.8.adoc
+++ b/sys-utils/blkpr.8.adoc
@@ -25,8 +25,8 @@ The _device_ argument is the pathname of the block device.
 
 *-c*, *--command* _command_::
 The command for managing persistent reservations. Supported commands are:
-*register*, *reserve*, *release*, *preempt*, *preempt-abort*, *clear*, and
-*read-keys*.
+*register*, *reserve*, *release*, *preempt*, *preempt-abort*, *clear*,
+*read-keys*, and *read-reservation*.
 
 *-k*, *--key* _key_::
 The key the command should operate on.
-- 
2.52.0


^ permalink raw reply related

* Re: Partition incorrectly identified as LUKS
From: Milan Broz @ 2025-12-11 21:22 UTC (permalink / raw)
  To: Anthony Rossomano, util-linux
In-Reply-To: <4C27EBF0-B758-4528-903C-9199916EB6F9@gmail.com>

On 12/11/25 4:20 PM, Anthony Rossomano wrote:
> LUKS image is stored on XFS partition. When secondary LUKS signature
> winds up at one of the offsets checked by libblkid partition then we
> have the side effects of partition reported with crypto_LUKS fstype,
> no by-label link created by udev, mount requires fstype, etc
> 
> Don’t think that this has been addressed upstream but need to
> confirm.
LUKS2 metadata contains offset, so it is not possible to detect
it on a wrong offset.

If it is detected on partition (secondary LUKS2 header),
it probably means that partition was not properly wiped before reformat.
(wipefs -a should wipe both LUKS2 headers)

Anyway, without the reproducer image it is just guessing.

Milan


^ permalink raw reply

* Re: Partition incorrectly identified as LUKS
From: Anthony Rossomano @ 2025-12-11 23:24 UTC (permalink / raw)
  To: Milan Broz; +Cc: util-linux
In-Reply-To: <13c13750-6420-40a8-a99c-35b46b9b009a@gmail.com>



> On Dec 11, 2025, at 1:22 PM, Milan Broz <gmazyland@gmail.com> wrote:
> 
> On 12/11/25 4:20 PM, Anthony Rossomano wrote:
>> LUKS image is stored on XFS partition. When secondary LUKS signature
>> winds up at one of the offsets checked by libblkid partition then we
>> have the side effects of partition reported with crypto_LUKS fstype,
>> no by-label link created by udev, mount requires fstype, etc
>> Don’t think that this has been addressed upstream but need to
>> confirm.
> LUKS2 metadata contains offset, so it is not possible to detect
> it on a wrong offset.
> 
> If it is detected on partition (secondary LUKS2 header),
> it probably means that partition was not properly wiped before reformat.
> (wipefs -a should wipe both LUKS2 headers)
> 
> Anyway, without the reproducer image it is just guessing.
> 
> Milan
> 
Make sure we’re on the same page. This partition is properly wiped and formatted as XFS. There are LUKS encrypted squashfs image files stored in the partition. These images are updated periodically. The issue occurs when secondary LUKS signature in one of the image files winds up at offset on disk checked by libblkid. 

Tony

^ permalink raw reply

* Re: Partition incorrectly identified as LUKS
From: Milan Broz @ 2025-12-12  7:35 UTC (permalink / raw)
  To: Anthony Rossomano; +Cc: util-linux
In-Reply-To: <A4CF73A8-06D0-47DD-81CD-0B852DDA0F11@gmail.com>

On 12/12/25 12:24 AM, Anthony Rossomano wrote:
> Make sure we’re on the same page. This partition is properly wiped
> and formatted as XFS. There are LUKS encrypted squashfs image files
> stored in the partition. These images are updated periodically. The
> issue occurs when secondary LUKS signature in one of the image files
> winds up at offset on disk checked by libblkid.

This just cannot happen until there is a bug in libblkid
(which should check offset) or something different happens.
The offset checking patch was added later, perhaps your distro did not backport the patch.

LUKS1 must be on offset 0.

LUKS2 is designed exactly to prevent this to happen by checking
header offset in on expected location form device start.

If upstream util-linux misdetects LUKS, then please send a testing image somewhere.

Thanks,
Milan


^ permalink raw reply

* [PATCH] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Kiran Rangoon @ 2025-12-13 20:04 UTC (permalink / raw)
  To: util-linux; +Cc: Kiran Rangoon

gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
now use signed arithmetic to prevent unsigned wraparound.

This fixes uuidparse displaying far-future dates for historical UUIDs.

Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
---
 libuuid/src/uuid_time.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
index c7516152b..b7fcc892d 100644
--- a/libuuid/src/uuid_time.c
+++ b/libuuid/src/uuid_time.c
@@ -60,15 +60,22 @@
 /* prototype to make compiler happy */
 time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
 
-static uint64_t gregorian_to_unix(uint64_t ts)
+static int64_t gregorian_to_unix(uint64_t ts)
 {
-	return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
+    uint64_t offset = ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
+
+    if (ts < offset) {
+        errno = EOVERFLOW;
+        return -1;
+    }
+
+    return ts - offset;
 }
 
 static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
 {
 	uint32_t high;
-	uint64_t clock_reg;
+	int64_t clock_reg;
 
 	high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
 	clock_reg = uuid->time_low | ((uint64_t) high << 32);
@@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
 
 static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
 {
-	uint64_t clock_reg;
+	int64_t clock_reg;
 
 	clock_reg = uuid->time_low;
 	clock_reg <<= 16;
-- 
2.47.3


^ permalink raw reply related

* Re: [PATCH] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Thomas Weißschuh  @ 2025-12-13 23:36 UTC (permalink / raw)
  To: Kiran Rangoon; +Cc: util-linux
In-Reply-To: <20251213200410.31256-1-kiranrangoon0@gmail.com>

Hey Kiran,

thanks for your patch!


Dec 14, 2025 05:04:23 Kiran Rangoon <kiranrangoon0@gmail.com>:

> gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
> for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
> now use signed arithmetic to prevent unsigned wraparound.
>
> This fixes uuidparse displaying far-future dates for historical UUIDs.

Can you add an example for the issue here?

>
> Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
> ---
> libuuid/src/uuid_time.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)

Could you also add some tests?

>
> diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
> index c7516152b..b7fcc892d 100644
> --- a/libuuid/src/uuid_time.c
> +++ b/libuuid/src/uuid_time.c
> @@ -60,15 +60,22 @@
> /* prototype to make compiler happy */
> time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
>
> -static uint64_t gregorian_to_unix(uint64_t ts)
> +static int64_t gregorian_to_unix(uint64_t ts)
> {
> -   return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
> +    uint64_t offset = ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);

In general, IMO we should just use a 64bit constant here instead of the calculation.
(Not your fault obviously)

> +
> +    if (ts < offset) {
> +        errno = EOVERFLOW;
> +        return -1;

Instead of erroring out here, do you think it would be possible to
gracefully handle such negative values through changes in some other places?

> +    }
> +
> +    return ts - offset;
> }
>
> static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
> {
>     uint32_t high;
> -   uint64_t clock_reg;
> +   int64_t clock_reg;
>
>     high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
>     clock_reg = uuid->time_low | ((uint64_t) high << 32);
> @@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
>
> static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
> {
> -   uint64_t clock_reg;
> +   int64_t clock_reg;
>
>     clock_reg = uuid->time_low;
>     clock_reg <<= 16;
> --
> 2.47.3


^ permalink raw reply

* [PATCH v2] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Kiran Rangoon @ 2025-12-14  1:01 UTC (permalink / raw)
  To: util-linux; +Cc: Kiran Rangoon
In-Reply-To: <20251213200410.31256-1-kiranrangoon0@gmail.com>

gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
now use signed arithmetic to prevent unsigned wraparound.

This fixes uuidparse displaying far-future dates for historical UUIDs.

The regression test has been updated to show actual result instead of hardcoded wrong
date.

Example output:
    $ ./build/uuidparse bf2eb110-d788-1003-aa59-ce1e9e293641
Before:
    60041-08-13 16:41:36,271592-04:00
After:
    1969-12-31 19:00:00,000000-05:00

Handling negative timestamps gracefully would require broader changes, so I’ve kept this patch focused on preventing pre-1970 wraparound.

Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
---
 libuuid/src/uuid_time.c       | 15 +++++++++++----
 tests/expected/uuid/uuidparse |  2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
index c7516152b..f0d2c8f36 100644
--- a/libuuid/src/uuid_time.c
+++ b/libuuid/src/uuid_time.c
@@ -60,15 +60,22 @@
 /* prototype to make compiler happy */
 time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
 
-static uint64_t gregorian_to_unix(uint64_t ts)
+static int64_t gregorian_to_unix(uint64_t ts)
 {
-	return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
+    const uint64_t offset = 0x01B21DD213814000ULL;
+
+    if (ts < offset) {
+        errno = EOVERFLOW;
+        return -1;
+    }
+
+    return ts - offset;
 }
 
 static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
 {
 	uint32_t high;
-	uint64_t clock_reg;
+	int64_t clock_reg;
 
 	high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
 	clock_reg = uuid->time_low | ((uint64_t) high << 32);
@@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
 
 static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
 {
-	uint64_t clock_reg;
+	int64_t clock_reg;
 
 	clock_reg = uuid->time_low;
 	clock_reg <<= 16;
diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse
index 9edb05e4e..0f521a760 100644
--- a/tests/expected/uuid/uuidparse
+++ b/tests/expected/uuid/uuidparse
@@ -11,7 +11,7 @@ UUID                                  VARIANT   TYPE       TIME
 00000000-0000-3000-8000-000000000000  DCE       name-based 
 00000000-0000-4000-8000-000000000000  DCE       random     
 00000000-0000-5000-8000-000000000000  DCE       sha1-based 
-00000000-0000-6000-8000-000000000000  DCE       time-v6    60038-03-11 05:36:10,955161+00:00
+00000000-0000-6000-8000-000000000000  DCE       time-v6    1970-01-01 00:00:00,000000+00:00
 00000000-0000-0000-d000-000000000000  Microsoft            
 00000000-0000-1000-d000-000000000000  Microsoft            
 00000000-0000-2000-d000-000000000000  Microsoft            
-- 
2.47.3


^ permalink raw reply related

* [ANNOUNCE] util-linux v2.41.3
From: Karel Zak @ 2025-12-15 15:02 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, util-linux


The util-linux release v2.41.3 is now available at
 
  http://www.kernel.org/pub/linux/utils/util-linux/v2.41
 
This release addresses build issues with GCC 15 (C23) and fixes
CVE-2025-14104.

Feedback and bug reports, as always, are welcomed.
 
  Karel



util-linux 2.41.3 Release Notes
===============================

bash-completion:
    - (mount) add missing options (by Christian Goeschel Ndjomouo)
    - add lsfd (by Karel Zak)
    - add blkpr (by Karel Zak)
    - add bits to dist tarball (by Karel Zak)

dmesg:
    - fix const qualifier warnings in parse_callerid (by Karel Zak)

eject:
    - fix const qualifier warning in read_speed (by Karel Zak)

enosys:
    - fix const qualifier warning in parse_block (by Karel Zak)

libblkid:
    - fix const qualifier warning in blkid_parse_tag_string (by Karel Zak)
    - use snprintf() instead of sprintf() (by Karel Zak)

libfdisk:
    - (dos) fix off-by-one in maximum last sector calculation (by Karel Zak)

liblastlog2:
    - fix operator precedence in conditional assignments (by Karel Zak)

lib, lscpu:
    - fix const qualifier discarded warnings in bsearch (by Karel Zak)

libmount:
    - fix const qualifier warning in mnt_parse_mountinfo_line (by Karel Zak)
    - fix const qualifier warnings for C23 (by Karel Zak)

logger:
    - fix const qualifier warnings for C23 (by Karel Zak)

login-utils:
    - fix setpwnam() buffer use [CVE-2025-14104] (by Karel Zak)

losetup:
    - sort 'O' correctly for the mutual-exclusive check to work (by Benno Schulenberg)

lscpu:
    - use maximum CPU speed from DMI, avoid duplicate version string (by Karel Zak)
    - Add a few missing Arm CPU identifiers (by Jonathan Thackray)

lsfd:
    - fix memory leak related to stat_error_class (by Masatake YAMATO)
    - (bugfix) use PRIu32 for prining lport of netlink socket (by Masatake YAMATO)
    - fix const qualifier warning in strnrstr (by Karel Zak)
    - fix const qualifier warning in new_counter_spec (by Karel Zak)
    - fix bsearch macro usage with glibc C23 (by Cristian Rodríguez)

lsns:
    - fix const qualifier warnings for C23 (by Karel Zak)

namei:
    - fix const qualifier warning in readlink_to_namei (by Karel Zak)

partx:
    - fix const qualifier warning in get_max_partno (by Karel Zak)

po:
    - update sr.po (from translationproject.org) (by Мирослав Николић)

po-man:
    - merge changes (by Karel Zak)
    - update sr.po (from translationproject.org) (by Мирослав Николић)

umount:
    - consider helper return status for success message (by Christian Goeschel Ndjomouo)

wdctl:
    - remove -d option leftover (by Munehisa Kamata)

whereis:
    - fix const qualifier warnings for C23 (by Karel Zak)

Misc:
    - Fix memory leak in setpwnam() (by yao zhang)


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: [PATCH v2] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Thomas Weißschuh @ 2025-12-16 13:08 UTC (permalink / raw)
  To: Kiran Rangoon; +Cc: util-linux
In-Reply-To: <20251214010108.29535-1-kiranrangoon0@gmail.com>

On 2025-12-13 20:01:08-0500, Kiran Rangoon wrote:
> gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
> for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
> now use signed arithmetic to prevent unsigned wraparound.
> 
> This fixes uuidparse displaying far-future dates for historical UUIDs.
> 
> The regression test has been updated to show actual result instead of hardcoded wrong
> date.

Thanks!

> 
> Example output:
>     $ ./build/uuidparse bf2eb110-d788-1003-aa59-ce1e9e293641
> Before:
>     60041-08-13 16:41:36,271592-04:00
> After:
>     1969-12-31 19:00:00,000000-05:00
> 
> Handling negative timestamps gracefully would require broader changes,
> so I’ve kept this patch focused on preventing pre-1970 wraparound.

IMO we should to this properly. Is this something you want to work on?

> Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
> ---
>  libuuid/src/uuid_time.c       | 15 +++++++++++----
>  tests/expected/uuid/uuidparse |  2 +-
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
> index c7516152b..f0d2c8f36 100644
> --- a/libuuid/src/uuid_time.c
> +++ b/libuuid/src/uuid_time.c
> @@ -60,15 +60,22 @@
>  /* prototype to make compiler happy */
>  time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
>  
> -static uint64_t gregorian_to_unix(uint64_t ts)
> +static int64_t gregorian_to_unix(uint64_t ts)
>  {
> -	return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
> +    const uint64_t offset = 0x01B21DD213814000ULL;
> +
> +    if (ts < offset) {
> +        errno = EOVERFLOW;
> +        return -1;

The callers do not check for errors. Instead this gets converted to the
epoch only by chance.

> +    }
> +
> +    return ts - offset;
>  }
>  
>  static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
>  {
>  	uint32_t high;
> -	uint64_t clock_reg;
> +	int64_t clock_reg;
>  
>  	high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
>  	clock_reg = uuid->time_low | ((uint64_t) high << 32);
> @@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
>  
>  static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
>  {
> -	uint64_t clock_reg;
> +	int64_t clock_reg;
>  
>  	clock_reg = uuid->time_low;
>  	clock_reg <<= 16;
> diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse
> index 9edb05e4e..0f521a760 100644
> --- a/tests/expected/uuid/uuidparse
> +++ b/tests/expected/uuid/uuidparse
> @@ -11,7 +11,7 @@ UUID                                  VARIANT   TYPE       TIME
>  00000000-0000-3000-8000-000000000000  DCE       name-based 
>  00000000-0000-4000-8000-000000000000  DCE       random     
>  00000000-0000-5000-8000-000000000000  DCE       sha1-based 
> -00000000-0000-6000-8000-000000000000  DCE       time-v6    60038-03-11 05:36:10,955161+00:00
> +00000000-0000-6000-8000-000000000000  DCE       time-v6    1970-01-01 00:00:00,000000+00:00

If it is an error, the output should be empty.

>  00000000-0000-0000-d000-000000000000  Microsoft            
>  00000000-0000-1000-d000-000000000000  Microsoft            
>  00000000-0000-2000-d000-000000000000  Microsoft            
> -- 
> 2.47.3

^ permalink raw reply

* Re: [PATCH v2] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Kiran @ 2025-12-16 20:40 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: util-linux
In-Reply-To: <5a20c5ee-b56c-472e-94a2-c7223c281b3e@t-8ch.de>

Yes I could work on this. I'll change pre-Unix-epoch v1/v6 UUID
timestamps to be treated as an error. uuid_time_v1() and
uuid_time_v6() will detect underflow, return failure, and
__uuid_time() will propagate it by returning -1 and setting tv_sec =
tv_usec = -1, unless you have any objections.


On Tue, Dec 16, 2025 at 8:08 AM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>
> On 2025-12-13 20:01:08-0500, Kiran Rangoon wrote:
> > gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
> > for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
> > now use signed arithmetic to prevent unsigned wraparound.
> >
> > This fixes uuidparse displaying far-future dates for historical UUIDs.
> >
> > The regression test has been updated to show actual result instead of hardcoded wrong
> > date.
>
> Thanks!
>
> >
> > Example output:
> >     $ ./build/uuidparse bf2eb110-d788-1003-aa59-ce1e9e293641
> > Before:
> >     60041-08-13 16:41:36,271592-04:00
> > After:
> >     1969-12-31 19:00:00,000000-05:00
> >
> > Handling negative timestamps gracefully would require broader changes,
> > so I’ve kept this patch focused on preventing pre-1970 wraparound.
>
> IMO we should to this properly. Is this something you want to work on?
>
> > Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
> > ---
> >  libuuid/src/uuid_time.c       | 15 +++++++++++----
> >  tests/expected/uuid/uuidparse |  2 +-
> >  2 files changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
> > index c7516152b..f0d2c8f36 100644
> > --- a/libuuid/src/uuid_time.c
> > +++ b/libuuid/src/uuid_time.c
> > @@ -60,15 +60,22 @@
> >  /* prototype to make compiler happy */
> >  time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
> >
> > -static uint64_t gregorian_to_unix(uint64_t ts)
> > +static int64_t gregorian_to_unix(uint64_t ts)
> >  {
> > -     return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
> > +    const uint64_t offset = 0x01B21DD213814000ULL;
> > +
> > +    if (ts < offset) {
> > +        errno = EOVERFLOW;
> > +        return -1;
>
> The callers do not check for errors. Instead this gets converted to the
> epoch only by chance.
>
> > +    }
> > +
> > +    return ts - offset;
> >  }
> >
> >  static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
> >  {
> >       uint32_t high;
> > -     uint64_t clock_reg;
> > +     int64_t clock_reg;
> >
> >       high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
> >       clock_reg = uuid->time_low | ((uint64_t) high << 32);
> > @@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
> >
> >  static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
> >  {
> > -     uint64_t clock_reg;
> > +     int64_t clock_reg;
> >
> >       clock_reg = uuid->time_low;
> >       clock_reg <<= 16;
> > diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse
> > index 9edb05e4e..0f521a760 100644
> > --- a/tests/expected/uuid/uuidparse
> > +++ b/tests/expected/uuid/uuidparse
> > @@ -11,7 +11,7 @@ UUID                                  VARIANT   TYPE       TIME
> >  00000000-0000-3000-8000-000000000000  DCE       name-based
> >  00000000-0000-4000-8000-000000000000  DCE       random
> >  00000000-0000-5000-8000-000000000000  DCE       sha1-based
> > -00000000-0000-6000-8000-000000000000  DCE       time-v6    60038-03-11 05:36:10,955161+00:00
> > +00000000-0000-6000-8000-000000000000  DCE       time-v6    1970-01-01 00:00:00,000000+00:00
>
> If it is an error, the output should be empty.
>
> >  00000000-0000-0000-d000-000000000000  Microsoft
> >  00000000-0000-1000-d000-000000000000  Microsoft
> >  00000000-0000-2000-d000-000000000000  Microsoft
> > --
> > 2.47.3

^ permalink raw reply

* Re: [PATCH v2] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Thomas Weißschuh @ 2025-12-16 23:21 UTC (permalink / raw)
  To: Kiran; +Cc: util-linux
In-Reply-To: <CA+uoJ5sE0uLwidR5_5+BZP3fS=ObYbWHsNQv+k8Na5aWL3ZwDg@mail.gmail.com>

Hi Kiran,

please reply in-line to each individual comment instead of top-posting a
single reply. It keeps the conversation understandable.

On 2025-12-16 15:40:10-0500, Kiran wrote:
> Yes I could work on this. I'll change pre-Unix-epoch v1/v6 UUID
> timestamps to be treated as an error. uuid_time_v1() and
> uuid_time_v6() will detect underflow, return failure, and
> __uuid_time() will propagate it by returning -1 and setting tv_sec =
> tv_usec = -1, unless you have any objections.

Looking at this more closely: __uuid_time() is directly exposed to users
of libuuid as uuid_time(). This means that any change of the function's
contract would break all external users and should be avoided at all
costs. Fortunately it turns out that the timestamps embedded in UUIDs
only use 60 bits. This means that the calculation can be performed in an
int64_t without any risk of over- or underflow. Please try to implement
it that way instead. It might be useful to change the signature of
gregorian_to_unix() to
"static void gregorian_to_unix(uint64_t ts, struct timeval *tv)".
Also please perform each logical step in a dedicated commit.


Thomas

> On Tue, Dec 16, 2025 at 8:08 AM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> >
> > On 2025-12-13 20:01:08-0500, Kiran Rangoon wrote:
> > > gregorian_to_unix now returns -1 and sets errno=EOVERFLOW
> > > for timestamps before the Unix epoch. uuid_time_v1 and uuid_time_v6
> > > now use signed arithmetic to prevent unsigned wraparound.
> > >
> > > This fixes uuidparse displaying far-future dates for historical UUIDs.
> > >
> > > The regression test has been updated to show actual result instead of hardcoded wrong
> > > date.
> >
> > Thanks!
> >
> > >
> > > Example output:
> > >     $ ./build/uuidparse bf2eb110-d788-1003-aa59-ce1e9e293641
> > > Before:
> > >     60041-08-13 16:41:36,271592-04:00
> > > After:
> > >     1969-12-31 19:00:00,000000-05:00
> > >
> > > Handling negative timestamps gracefully would require broader changes,
> > > so I’ve kept this patch focused on preventing pre-1970 wraparound.
> >
> > IMO we should to this properly. Is this something you want to work on?
> >
> > > Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
> > > ---
> > >  libuuid/src/uuid_time.c       | 15 +++++++++++----
> > >  tests/expected/uuid/uuidparse |  2 +-
> > >  2 files changed, 12 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
> > > index c7516152b..f0d2c8f36 100644
> > > --- a/libuuid/src/uuid_time.c
> > > +++ b/libuuid/src/uuid_time.c
> > > @@ -60,15 +60,22 @@
> > >  /* prototype to make compiler happy */
> > >  time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
> > >
> > > -static uint64_t gregorian_to_unix(uint64_t ts)
> > > +static int64_t gregorian_to_unix(uint64_t ts)
> > >  {
> > > -     return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
> > > +    const uint64_t offset = 0x01B21DD213814000ULL;
> > > +
> > > +    if (ts < offset) {
> > > +        errno = EOVERFLOW;
> > > +        return -1;
> >
> > The callers do not check for errors. Instead this gets converted to the
> > epoch only by chance.
> >
> > > +    }
> > > +
> > > +    return ts - offset;
> > >  }
> > >
> > >  static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
> > >  {
> > >       uint32_t high;
> > > -     uint64_t clock_reg;
> > > +     int64_t clock_reg;
> > >
> > >       high = uuid->time_mid | ((uuid->time_hi_and_version & 0xFFF) << 16);
> > >       clock_reg = uuid->time_low | ((uint64_t) high << 32);
> > > @@ -80,7 +87,7 @@ static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)
> > >
> > >  static void uuid_time_v6(const struct uuid *uuid, struct timeval *tv)
> > >  {
> > > -     uint64_t clock_reg;
> > > +     int64_t clock_reg;
> > >
> > >       clock_reg = uuid->time_low;
> > >       clock_reg <<= 16;
> > > diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse
> > > index 9edb05e4e..0f521a760 100644
> > > --- a/tests/expected/uuid/uuidparse
> > > +++ b/tests/expected/uuid/uuidparse
> > > @@ -11,7 +11,7 @@ UUID                                  VARIANT   TYPE       TIME
> > >  00000000-0000-3000-8000-000000000000  DCE       name-based
> > >  00000000-0000-4000-8000-000000000000  DCE       random
> > >  00000000-0000-5000-8000-000000000000  DCE       sha1-based
> > > -00000000-0000-6000-8000-000000000000  DCE       time-v6    60038-03-11 05:36:10,955161+00:00
> > > +00000000-0000-6000-8000-000000000000  DCE       time-v6    1970-01-01 00:00:00,000000+00:00
> >
> > If it is an error, the output should be empty.
> >
> > >  00000000-0000-0000-d000-000000000000  Microsoft
> > >  00000000-0000-1000-d000-000000000000  Microsoft
> > >  00000000-0000-2000-d000-000000000000  Microsoft
> > > --
> > > 2.47.3
> 

^ permalink raw reply

* Re: [PATCH 3/3] blkpr: add read-reservation command
From: Karel Zak @ 2025-12-17 10:53 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: util-linux
In-Reply-To: <20251211160956.1540114-4-stefanha@redhat.com>

On Thu, Dec 11, 2025 at 11:09:56AM -0500, Stefan Hajnoczi wrote:
> 
> diff --git a/meson.build b/meson.build
> index 47b43c2af..b759e992f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -768,6 +768,9 @@ conf.set('HAVE_DECL_PR_REP_CAPACITY', have ? 1 : false)
>  have = cc.has_header_symbol('linux/pr.h', 'IOC_PR_READ_KEYS')
>  conf.set('HAVE_DECL_IOC_PR_READ_KEYS', have ? 1 : false)
>  
> +have = cc.has_header_symbol('linux/pr.h', 'IOC_PR_READ_RESERVATION')
> +conf.set('HAVE_DECL_IOC_PR_READ_RESERVATION', have ? 1 : false)

It seems you do not need to define HAVE_DECL_IOC_PR_READ_RESERVATION
and care about this in meson.build or configure.ac.

> +#if HAVE_DECL_IOC_PR_READ_RESERVATION
> +	{IOC_PR_READ_RESERVATION, "read-reservation",
> +	"  * read-reservation: This command shows the current reservation.\n"},
> +#endif

I think you can use directly

        #ifdef IOC_PR_READ_RESERVATION

        #endif

as IOC_PR_READ_RESERVATION is macro in linux/pr.h

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: [PATCH 1/3] losetup: snip --verbose from bash-completion, and 'v' from options string
From: Karel Zak @ 2025-12-17 11:00 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <20251209150222.50981-1-bensberg@telfort.nl>

On Tue, Dec 09, 2025 at 04:02:20PM +0100, Benno Schulenberg wrote:
>  bash-completion/losetup | 1 -
>  sys-utils/losetup.c     | 2 +-
>  2 files changed, 1 insertion(+), 2 deletions(-)

Submitted as a pull request to https://github.com/util-linux/util-linux/pull/3910
for CI testing.

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: [PATCH v2] libuuid: Fix pre-1970 UUID v1 timestamp wraparound
From: Karel Zak @ 2025-12-17 11:01 UTC (permalink / raw)
  To: Kiran Rangoon; +Cc: util-linux
In-Reply-To: <20251214010108.29535-1-kiranrangoon0@gmail.com>

On Sat, Dec 13, 2025 at 08:01:08PM -0500, Kiran Rangoon wrote:
>  libuuid/src/uuid_time.c       | 15 +++++++++++----
>  tests/expected/uuid/uuidparse |  2 +-
>  2 files changed, 12 insertions(+), 5 deletions(-)

Submitted as a pull request to https://github.com/util-linux/util-linux/pull/3911
for CI testing.

Thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* [PATCH v2 0/3] blkpr: add read-keys and read-reservations commands
From: Stefan Hajnoczi @ 2025-12-17 18:26 UTC (permalink / raw)
  To: util-linux; +Cc: kwolf, hare, Karel Zak, pizhenwei, Stefan Hajnoczi

v2:
- Use #ifdef IOC_PR_... instead of autoconf/meson because it's simpler [Karel]

New <linux/pr.h> ioctls make it possible to fetch the list of registered keys
and the details of the current reservation from a block device. The relevant
Linux commits are:

3e2cb9ee76c27 block: add IOC_PR_READ_RESERVATION ioctl
22a1ffea5f805 block: add IOC_PR_READ_KEYS ioctl

Add the appropriate commands to blkpr. Users can use these for troubleshooting
and cluster management tools may use them to query the state of persistent
reservations during recovery.

Stefan Hajnoczi (3):
  blkpr: prepare for _IOR() ioctls
  blkpr: add read-keys command
  blkpr: add read-reservation command

 sys-utils/blkpr.c      | 106 ++++++++++++++++++++++++++++++++++++++---
 sys-utils/blkpr.8.adoc |   3 +-
 2 files changed, 101 insertions(+), 8 deletions(-)

-- 
2.52.0


^ permalink raw reply

* [PATCH v2 3/3] blkpr: add read-reservation command
From: Stefan Hajnoczi @ 2025-12-17 18:26 UTC (permalink / raw)
  To: util-linux; +Cc: kwolf, hare, Karel Zak, pizhenwei, Stefan Hajnoczi
In-Reply-To: <20251217182607.179232-1-stefanha@redhat.com>

The new IOC_PR_READ_RESERVATION ioctl reports the current reservation on
a device. Add a command so that users can inspect the current
reservation. This is useful both for troubleshooting and for recovery
scenarios.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 sys-utils/blkpr.c      | 60 +++++++++++++++++++++++++++++++++++++-----
 sys-utils/blkpr.8.adoc |  4 +--
 2 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c
index 84e736e9f..e2e67b3f1 100644
--- a/sys-utils/blkpr.c
+++ b/sys-utils/blkpr.c
@@ -73,7 +73,7 @@ static const struct type_string pr_type[] = {
 };
 
 static const struct type_string pr_command[] = {
-	{IOC_PR_REGISTER,      "register",
+	{IOC_PR_REGISTER,         "register",
 	"  * register: This command registers a new reservation if the key argument\n"
 	"    is non-null. If no existing reservation exists oldkey must be zero, if\n"
 	"    an existing reservation should be replaced oldkey must contain the old\n"
@@ -81,34 +81,39 @@ static const struct type_string pr_command[] = {
 	"    reservation passed in oldkey.\n"
 	},
 
-	{IOC_PR_RESERVE,       "reserve",
+	{IOC_PR_RESERVE,          "reserve",
 	"  * reserve: This command reserves the device and thus restricts access for\n"
 	"    other devices based on the type argument.  The key argument must be\n"
 	"    the existing reservation key for the device as acquired by the register,\n"
 	"    preempt, preempt-abort commands.\n"},
 
-	{IOC_PR_RELEASE,       "release",
+	{IOC_PR_RELEASE,          "release",
 	"  * release: This command releases the reservation specified by key and flags\n"
 	"    and thus removes any access restriction implied by it.\n"},
 
-	{IOC_PR_PREEMPT,       "preempt",
+	{IOC_PR_PREEMPT,          "preempt",
 	"  * preempt: This command releases the existing reservation referred to by\n"
 	"    old_key and replaces it with a new reservation of type for the\n"
 	"    reservation key key.\n"},
 
-	{IOC_PR_PREEMPT_ABORT, "preempt-abort",
+	{IOC_PR_PREEMPT_ABORT,    "preempt-abort",
 	"  * preempt-abort: This command works like preempt except that it also aborts\n"
 	"    any outstanding command sent over a connection identified by oldkey.\n"},
 
-	{IOC_PR_CLEAR,         "clear",
+	{IOC_PR_CLEAR,            "clear",
 	"  * clear: This command unregisters both key and any other reservation\n"
 	"    key registered with the device and drops any existing reservation.\n"},
 
 #ifdef IOC_PR_READ_KEYS
-	{IOC_PR_READ_KEYS,     "read-keys",
+	{IOC_PR_READ_KEYS,        "read-keys",
 	"  * read-keys: This command lists reservation keys currently registered\n"
 	"    with the device.\n"},
 #endif
+
+#ifdef IOC_PR_READ_RESERVATION
+	{IOC_PR_READ_RESERVATION, "read-reservation",
+	"  * read-reservation: This command shows the current reservation.\n"},
+#endif
 };
 
 static const struct type_string pr_flag[] = {
@@ -140,6 +145,18 @@ static int parse_type_by_str(const struct type_string *ts, int nmem, char *patte
 	return -1;
 }
 
+static inline const char *type_to_str(const struct type_string *ts, int nmem,
+                                      int type)
+{
+	int i;
+
+	for (i = 0; i < nmem; i++) {
+		if (ts[i].type == type)
+			return ts[i].str;
+	}
+	return "unknown type";
+}
+
 
 #define PRINT_SUPPORTED(XX) \
 	static void print_##XX(FILE *out) \
@@ -192,6 +209,30 @@ out:
 }
 #endif /* IOC_PR_READ_KEYS */
 
+#ifdef IOC_PR_READ_RESERVATION
+static int do_pr_read_reservation(int fd)
+{
+	struct pr_read_reservation pr_rr;
+	const char *type_str;
+	int ret;
+
+	ret = ioctl(fd, IOC_PR_READ_RESERVATION, &pr_rr);
+	if (ret)
+		return ret;
+
+	type_str = type_to_str(pr_type, ARRAY_SIZE(pr_type), pr_rr.type);
+
+	if (pr_rr.key) {
+		printf(_("Key: %#" PRIx64 "\n"), (uint64_t)pr_rr.key);
+		printf(_("Generation: %#x\n"), pr_rr.generation);
+		printf(_("Type: %s\n"), type_str);
+	} else {
+		printf(_("No reservation\n"));
+	}
+	return 0;
+}
+#endif /* IOC_PR_READ_RESERVATION */
+
 static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, int flag)
 {
 	struct pr_registration pr_reg;
@@ -235,6 +276,11 @@ static int do_pr(char *path, uint64_t key, uint64_t oldkey, int op, int type, in
 	case IOC_PR_READ_KEYS:
 		ret = do_pr_read_keys(fd);
 		break;
+#endif
+#ifdef IOC_PR_READ_RESERVATION
+	case IOC_PR_READ_RESERVATION:
+		ret = do_pr_read_reservation(fd);
+		break;
 #endif
 	default:
 		errno = EINVAL;
diff --git a/sys-utils/blkpr.8.adoc b/sys-utils/blkpr.8.adoc
index 3a157af38..630bafb92 100644
--- a/sys-utils/blkpr.8.adoc
+++ b/sys-utils/blkpr.8.adoc
@@ -25,8 +25,8 @@ The _device_ argument is the pathname of the block device.
 
 *-c*, *--command* _command_::
 The command for managing persistent reservations. Supported commands are:
-*register*, *reserve*, *release*, *preempt*, *preempt-abort*, *clear*, and
-*read-keys*.
+*register*, *reserve*, *release*, *preempt*, *preempt-abort*, *clear*,
+*read-keys*, and *read-reservation*.
 
 *-k*, *--key* _key_::
 The key the command should operate on.
-- 
2.52.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox