diff --git a/filesystems/libblkid/Makefile b/filesystems/libblkid/Makefile index 077bc2158912..3367ae62ac6b 100644 --- a/filesystems/libblkid/Makefile +++ b/filesystems/libblkid/Makefile @@ -1,34 +1,34 @@ PORTNAME= libblkid DISTVERSIONPREFIX= v DISTVERSION= 2.41.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= filesystems MAINTAINER= arrowd@FreeBSD.org COMMENT= Library to identify block devices (disks) as to their content WWW= https://github.com/util-linux/util-linux LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/Documentation/licenses/COPYING.BSD-3-Clause USES= bison meson pkgconfig tar:xz USE_GITHUB= yes GH_ACCOUNT= util-linux GH_PROJECT= util-linux USE_LDCONFIG= yes # disable all Meson features because the project has gazillion of them and we only need few MESON_ARGS= --auto-features=disabled \ -Dallow-32bit-time=true \ -Db_lundef=false \ -Dbuild-libblkid=enabled \ -Dbuild-libsmartcols=disabled \ -Dprogram-tests=false # dependency of libblkid OPTIONS_DEFINE= MANPAGES OPTIONS_DEFAULT= MANPAGES OPTIONS_SUB= yes MANPAGES_BUILD_DEPENDS= asciidoctor:textproc/rubygem-asciidoctor .include diff --git a/filesystems/libblkid/files/patch-libblkid_src_devname.c b/filesystems/libblkid/files/patch-libblkid_src_devname.c new file mode 100644 index 000000000000..cf1040ef3f52 --- /dev/null +++ b/filesystems/libblkid/files/patch-libblkid_src_devname.c @@ -0,0 +1,30 @@ +--- libblkid/src/devname.c.orig 2025-06-24 07:55:28 UTC ++++ libblkid/src/devname.c +@@ -224,7 +224,11 @@ static void probe_one(blkid_cache cache, const char *p + + if (stat(device, &st) == 0 && + (S_ISBLK(st.st_mode) || +- (S_ISCHR(st.st_mode) && !strncmp(ptname, "ubi", 3))) && ++ (S_ISCHR(st.st_mode) ++#ifdef __linux__ ++ && !strncmp(ptname, "ubi", 3) ++#endif ++ )) && + st.st_rdev == devno) { + devname = strdup(device); + goto get_dev; +@@ -251,8 +255,12 @@ set_pri: + dev->bid_pri = BLKID_PRI_DM; + if (is_dm_leaf(ptname)) + dev->bid_pri += 5; +- } else if (!strncmp(ptname, "md", 2)) +- dev->bid_pri = BLKID_PRI_MD; ++ } else { ++#ifdef __linux__ ++ if (!strncmp(ptname, "md", 2)) ++ dev->bid_pri = BLKID_PRI_MD; ++#endif ++ } + if (removable) + dev->bid_flags |= BLKID_BID_FL_REMOVABLE; + } diff --git a/filesystems/libblkid/files/patch-libblkid_src_probe.c b/filesystems/libblkid/files/patch-libblkid_src_probe.c new file mode 100644 index 000000000000..aecc99b2b03b --- /dev/null +++ b/filesystems/libblkid/files/patch-libblkid_src_probe.c @@ -0,0 +1,49 @@ +--- libblkid/src/probe.c.orig 2025-06-24 07:55:28 UTC ++++ libblkid/src/probe.c +@@ -594,7 +594,18 @@ static struct blkid_bufinfo *read_buffer(blkid_probe p + DBG(LOWPROBE, ul_debug("\tread: off=%"PRIu64" len=%"PRIu64"", + real_off, len)); + +- ret = read(pr->fd, bf->data, len); ++ /* on FreeBSD, devices are unbuffered so we need to align to full I/O blocks by ourselves */ ++ if (len % pr->io_size) { ++ unsigned rawlen = len + (pr->io_size - len % pr->io_size); ++ char buf[rawlen]; ++ ret = read(pr->fd, buf, rawlen); ++ if (ret < 0 || ret < len) ++ return NULL; ++ memcpy(bf->data, buf, len); ++ ret = len; ++ } else { ++ ret = read(pr->fd, bf->data, len); ++ } + if (ret != (ssize_t) len) { + DBG(LOWPROBE, ul_debug("\tread failed: %m")); + remove_buffer(bf); +@@ -718,7 +729,7 @@ const unsigned char *blkid_probe_get_buffer(blkid_prob + struct blkid_bufinfo *bf = NULL; + uint64_t real_off, bias, len_align; + +- bias = off % pr->io_size; ++ bias = off % /* pr->io_size */ 4096; + off -= bias; + len += bias; + +@@ -1106,6 +1117,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + goto err; + } + } else if (S_ISCHR(sb.st_mode)) { ++#ifdef __linux__ + char buf[PATH_MAX]; + + if (!sysfs_chrdev_devno_to_devname(sb.st_rdev, buf, sizeof(buf)) +@@ -1114,6 +1126,9 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + errno = EINVAL; + goto err; + } ++#else ++ /* no-op, FreeBSD maps block devices as character */ ++#endif + devsiz = 1; /* UBI devices are char... */ + } else if (S_ISREG(sb.st_mode)) + devsiz = sb.st_size; /* regular file */ diff --git a/filesystems/libblkid/files/patch-misc-utils_blkid.c b/filesystems/libblkid/files/patch-misc-utils_blkid.c new file mode 100644 index 000000000000..6fe581bc1c13 --- /dev/null +++ b/filesystems/libblkid/files/patch-misc-utils_blkid.c @@ -0,0 +1,18 @@ +--- misc-utils/blkid.c.orig 2025-06-24 07:55:28 UTC ++++ misc-utils/blkid.c +@@ -876,6 +876,7 @@ int main(int argc, char **argv) + else if (S_ISREG(sb.st_mode)) + ; + else if (S_ISCHR(sb.st_mode)) { ++#ifdef __linux__ + char buf[PATH_MAX]; + + if (!sysfs_chrdev_devno_to_devname( +@@ -883,6 +884,7 @@ int main(int argc, char **argv) + continue; + if (strncmp(buf, "ubi", 3) != 0) + continue; ++#endif + } else + continue; +