From ce95875445c67808caa5d4fb0e6f80dbdaef0cb7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 May 2024 21:22:57 +0200 Subject: Adding upstream version 2.40.1. Signed-off-by: Daniel Baumann --- libblkid/src/config.c | 14 ++++---- libblkid/src/superblocks/bcache.c | 5 --- libblkid/src/topology/ioctl.c | 76 ++++++++++++++------------------------- 3 files changed, 34 insertions(+), 61 deletions(-) (limited to 'libblkid/src') diff --git a/libblkid/src/config.c b/libblkid/src/config.c index 7b8b04f..66c1864 100644 --- a/libblkid/src/config.c +++ b/libblkid/src/config.c @@ -153,6 +153,8 @@ struct blkid_config *blkid_read_config(const char *filename) #else /* !HAVE_LIBECONF */ static econf_file *file = NULL; + char *line = NULL; + bool uevent = false; econf_err error; if (filename) { @@ -187,7 +189,6 @@ struct blkid_config *blkid_read_config(const char *filename) } } - bool uevent = false; if ((error = econf_getBoolValue(file, NULL, "SEND_UEVENT", &uevent))) { if (error != ECONF_NOKEY) { DBG(CONFIG, ul_debug("couldn't fetch SEND_UEVENT corrently: %s", econf_errString(error))); @@ -209,7 +210,6 @@ struct blkid_config *blkid_read_config(const char *filename) } } - char *line = NULL; if ((error = econf_getStringValue(file, NULL, "EVALUATE", &line))) { conf->nevals = 0; if (error != ECONF_NOKEY) { @@ -219,7 +219,7 @@ struct blkid_config *blkid_read_config(const char *filename) DBG(CONFIG, ul_debug("key CACHE_FILE not found, using built-in default ")); } } else { - if (*line && parse_evaluate(conf, line) == -1) + if (line && *line && parse_evaluate(conf, line) == -1) goto err; } @@ -238,8 +238,8 @@ dflt: if (f) fclose(f); #else - econf_free (file); - free (line); + econf_free(file); + free(line); #endif return conf; err: @@ -248,8 +248,8 @@ err: #ifndef HAVE_LIBECONF fclose(f); #else - econf_free (file); - free (line); + econf_free(file); + free(line); #endif return NULL; } diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c index 47d9060..8ad2dc0 100644 --- a/libblkid/src/superblocks/bcache.c +++ b/libblkid/src/superblocks/bcache.c @@ -164,8 +164,6 @@ struct bcachefs_super_block { #define BCACHEFS_SECTOR_SIZE 512U /* maximum superblock size shift */ #define BCACHEFS_SB_MAX_SIZE_SHIFT 0x10U -/* maximum superblock size */ -#define BCACHEFS_SB_MAX_SIZE (1U << BCACHEFS_SB_MAX_SIZE_SHIFT) /* fields offset within super block */ #define BCACHEFS_SB_FIELDS_OFF offsetof(struct bcachefs_super_block, _start) /* tag value for members field */ @@ -360,9 +358,6 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag) sb_size = BCACHEFS_SB_FIELDS_OFF + BYTES(bcs); - if (sb_size > BCACHEFS_SB_MAX_SIZE) - return BLKID_PROBE_NONE; - if (bcs->layout.sb_max_size_bits > BCACHEFS_SB_MAX_SIZE_SHIFT) return BLKID_PROBE_NONE; diff --git a/libblkid/src/topology/ioctl.c b/libblkid/src/topology/ioctl.c index 3560a2f..7b15c9e 100644 --- a/libblkid/src/topology/ioctl.c +++ b/libblkid/src/topology/ioctl.c @@ -18,60 +18,38 @@ #include "topology.h" -/* - * ioctl topology values - */ -static const struct topology_val { - - long ioc; - - /* functions to set probing result */ - int (*set_ulong)(blkid_probe, unsigned long); - int (*set_int)(blkid_probe, int); - int (*set_u64)(blkid_probe, uint64_t); - -} topology_vals[] = { - { BLKALIGNOFF, NULL, blkid_topology_set_alignment_offset }, - { BLKIOMIN, blkid_topology_set_minimum_io_size }, - { BLKIOOPT, blkid_topology_set_optimal_io_size }, - { BLKPBSZGET, blkid_topology_set_physical_sector_size }, - { BLKGETDISKSEQ, .set_u64 = blkid_topology_set_diskseq }, - /* we read BLKSSZGET in topology.c */ -}; - static int probe_ioctl_tp(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__))) { - size_t i; - - for (i = 0; i < ARRAY_SIZE(topology_vals); i++) { - const struct topology_val *val = &topology_vals[i]; - int rc = 1; - union { - unsigned long ul; - int i; - uint64_t u64; - } data; - - if (ioctl(pr->fd, val->ioc, &data) == -1) - goto nothing; - - if (val->set_int) - rc = val->set_int(pr, data.i); - else if (val->set_ulong) - rc = val->set_ulong(pr, data.ul); - else - rc = val->set_u64(pr, data.u64); - - if (rc) - goto err; - } + uint64_t u64; + int s32; + + if (ioctl(pr->fd, BLKALIGNOFF, &s32) == -1) + return 1; + if (blkid_topology_set_alignment_offset(pr, s32)) + return -1; + + if (ioctl(pr->fd, BLKIOMIN, &s32) == -1) + return 1; + if (blkid_topology_set_minimum_io_size(pr, s32)) + return -1; + + if (ioctl(pr->fd, BLKIOOPT, &s32) == -1) + return 1; + if (blkid_topology_set_optimal_io_size(pr, s32)) + return -1; + + if (ioctl(pr->fd, BLKPBSZGET, &s32) == -1) + return 1; + if (blkid_topology_set_physical_sector_size(pr, s32)) + return -1; + + if (ioctl(pr->fd, BLKGETDISKSEQ, &u64) == -1) + return 1; + if (blkid_topology_set_physical_sector_size(pr, u64)) + return -1; return 0; -nothing: - return 1; -err: - return -1; } const struct blkid_idinfo ioctl_tp_idinfo = -- cgit v1.2.3