From f818d9426b58f387a72958a9dcaab216ee5c385e Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 10 Aug 2026 12:05:21 +0200 Subject: [PATCH] Remove libblkid support and build dependency --- HISTORY | 1 + cmdline/scan.c | 4 -- cmdline/unixapp.c | 117 +--------------------------------------------- configure.ac | 15 ------ makesan.sh | 4 +- os/portable.h | 7 +-- 6 files changed, 4 insertions(+), 144 deletions(-) diff --git a/HISTORY b/HISTORY index 0bd9e11e..f3682dc7 100644 --- a/HISTORY +++ b/HISTORY @@ -51,6 +51,7 @@ SnapRAID HISTORY * Added support for filesystems where only specific files fail to report a 64-bit inode number (such as ReFS when 128-bit file IDs cannot be mapped), allowing SnapRAID to continue processing those individual files without inodes. + * Removed the dependency on the 'libblkid' library. 14.10 2026/08 ============= diff --git a/cmdline/scan.c b/cmdline/scan.c index 07329502..b51aec64 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -2128,10 +2128,6 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) } if (done) { log_error(ESOFT, ". Not using inodes to detect move operations.\n"); -#if defined(_linux) && !HAVE_BLKID - log_error(ESOFT, "The 'blkid' library is not linked in SnapRAID!\n"); - log_error(ESOFT, "Try rebuilding it after installing the libblkid-dev or libblkid-devel package.\n"); -#endif } total.count_equal = 0; diff --git a/cmdline/unixapp.c b/cmdline/unixapp.c index e4ae4215..011e3649 100644 --- a/cmdline/unixapp.c +++ b/cmdline/unixapp.c @@ -1192,12 +1192,6 @@ static int devresolve(uint64_t device, char* path, size_t path_size) } #endif -/** - * Cache used by blkid. - */ -#if HAVE_BLKID -static blkid_cache cache = 0; -#endif /****************************************************************************/ /* uuid */ @@ -1302,88 +1296,6 @@ static int devuuid_dev(uint64_t device, char* uuid, size_t uuid_size) } #endif -/** - * Get the UUID using libblkid. - * It uses a cache to work without root permission, resulting in UUID - * not necessarily recent. - * We could call blkid_probe_all() to refresh the UUID, but it would - * require root permission to read the superblocks, and resulting in - * all the disks spinning. - */ -#if HAVE_BLKID -static int devuuid_blkid(uint64_t device, char* uuid, size_t uuid_size) -{ - char* devname; - char* uuidname; - - devname = blkid_devno_to_devname(device); - if (!devname) { - /* LCOV_EXCL_START */ - log_tag("uuid:blkid:%u:%u: blkid_devno_to_devname() failed, %s\n", major(device), minor(device), strerror(errno)); - /* device mapping failed */ - return -1; - /* LCOV_EXCL_STOP */ - } - - uuidname = blkid_get_tag_value(cache, "UUID", devname); - if (!uuidname) { - /* LCOV_EXCL_START */ - log_tag("uuid:blkid:%u:%u: blkid_get_tag_value(UUID,%s) failed, %s\n", major(device), minor(device), devname, strerror(errno)); - /* uuid mapping failed */ - free(devname); - return -1; - /* LCOV_EXCL_STOP */ - } - - pathcpy(uuid, uuid_size, uuidname); - - log_tag("uuid:blkid:%u:%u:%s: found %s\n", major(device), minor(device), uuid, devname); - - free(devname); - free(uuidname); - return 0; -} -#endif - -/** - * Get the LABEL using libblkid. - * It uses a cache to work without root permission, resulting in LABEL - * not necessarily recent. - */ -#if HAVE_BLKID -static int devuuid_label(uint64_t device, char* label, size_t label_size) -{ - char* devname; - char* labelname; - - devname = blkid_devno_to_devname(device); - if (!devname) { - /* LCOV_EXCL_START */ - log_tag("label:blkid:%u:%u: blkid_devno_to_devname() failed, %s\n", major(device), minor(device), strerror(errno)); - /* device mapping failed */ - return -1; - /* LCOV_EXCL_STOP */ - } - - labelname = blkid_get_tag_value(cache, "LABEL", devname); - if (!labelname) { - /* LCOV_EXCL_START */ - log_tag("label:blkid:%u:%u: blkid_get_tag_value(LABEL,%s) failed, %s\n", major(device), minor(device), devname, strerror(errno)); - free(devname); - /* label mapping failed */ - return -1; - /* LCOV_EXCL_STOP */ - } - - pathcpy(label, label_size, labelname); - - log_tag("label:blkid:%u:%u:%s: found %s\n", major(device), minor(device), label, devname); - - free(devname); - free(labelname); - return 0; -} -#endif /** * Get the LABEL using the generic Linux FS_IOC_GETFSLABEL ioctl. @@ -1692,12 +1604,6 @@ int devuuid(uint64_t device_id, const char* device_path, char* uuid, size_t uuid log_tag("uuid:by-uuid:%u:%u: by-uuid not supported\n", major(device_id), minor(device_id)); #endif -#if HAVE_BLKID - if (devuuid_blkid(device_id, uuid, uuid_size) == 0) - return 0; -#else - log_tag("uuid:blkid:%u:%u: blkid support not compiled in\n", major(device_id), minor(device_id)); -#endif log_tag("uuid:notfound:%u:%u:\n", major(device_id), minor(device_id)); @@ -2031,14 +1937,7 @@ int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_har if (fslabel) { fslabel[0] = 0; #if HAVE_LINUX_DEVICE - if (devlabel_ioctl(path, fslabel, fslabel_size) != 0) -#endif -#if HAVE_BLKID - { - struct stat fst; - if (stat(path, &fst) == 0) - devuuid_label(fst.st_dev, fslabel, fslabel_size); - } + devlabel_ioctl(path, fslabel, fslabel_size); #else (void)fslabel_size; #endif @@ -3953,26 +3852,12 @@ int ambient_temperature(void) void app_init(void) { -#if HAVE_BLKID - int ret; - ret = blkid_get_cache(&cache, NULL); - if (ret != 0) { - /* LCOV_EXCL_START */ - log_fatal(EEXTERNAL, "WARNING Failed to get blkid cache\n"); - /* LCOV_EXCL_STOP */ - } -#endif - /* set LC_ALL=C to make smartctl ignoring the locale when printing info */ setenv("LC_ALL", "C", 1); } void app_done(void) { -#if HAVE_BLKID - if (cache != 0) - blkid_put_cache(cache); -#endif } void app_default_conf(char* conf, size_t conf_size, const char* argv0) diff --git a/configure.ac b/configure.ac index 88459839..ed5bd5de 100644 --- a/configure.ac +++ b/configure.ac @@ -200,21 +200,6 @@ AS_IF([test "x$is_windows" = "xyes"], [ ]) AM_CONDITIONAL([HAVE_PTHREAD], [test "x$have_pthreads" = "xyes"]) -dnl Checks for libblkid -AC_ARG_WITH([blkid], - AS_HELP_STRING([--without-blkid], [Ignore presence of blkid and disable it])) -AS_IF([test "x$with_blkid" != "xno"], - [AC_SEARCH_LIBS([blkid_probe_all], [blkid], [have_blkid=yes], [have_blkid=no])], - [have_blkid=no]) -AS_IF([test "x$have_blkid" = "xyes"], - [ - AC_CHECK_HEADERS([blkid/blkid.h]) - AC_CHECK_FUNCS([blkid_devno_to_devname blkid_get_tag_value]) - ], - [AS_IF([test "x$with_blkid" = "xyes"], - [AC_MSG_ERROR([blkid requested but not found]) - ]) -]) dnl Checks for compiler AC_CHECK_CC_OPT([-Wall], CFLAGS="$CFLAGS -Wall", []) diff --git a/makesan.sh b/makesan.sh index 7a3efad8..c76de702 100755 --- a/makesan.sh +++ b/makesan.sh @@ -9,9 +9,7 @@ COMPILER=clang # Options for configure # --disable-asm # Inline assembly is not supported by the Sanitizers -# --without-blkid -# External libraries are not supported by the Sanitizers -OPTIONS="--disable-asm --without-blkid" +OPTIONS="--disable-asm" # Source directory SOURCE=`pwd` diff --git a/os/portable.h b/os/portable.h index bd96b64e..a426dfd0 100644 --- a/os/portable.h +++ b/os/portable.h @@ -132,12 +132,6 @@ #include #endif -#if HAVE_BLKID_BLKID_H -#include -#if HAVE_BLKID_DEVNO_TO_DEVNAME && HAVE_BLKID_GET_TAG_VALUE -#define HAVE_BLKID 1 -#endif -#endif /** * Includes some standard headers. @@ -313,3 +307,4 @@ #endif #endif +