diff options
| author | Lexi Winter <ivy@FreeBSD.org> | 2025-10-05 09:19:31 +0100 |
|---|---|---|
| committer | Lexi Winter <ivy@FreeBSD.org> | 2025-10-05 09:19:31 +0100 |
| commit | f85f2b2d6e5b7ed869376eb4b180c3a74a5c5da9 (patch) | |
| tree | ad799ccacfb459b809b02b9c115ed4befb93b4c1 /filesystems/libblkid/files/patch-libblkid_src_probe.c | |
| parent | 0b1510fe1f98f82da6f3481cb6c58957022d9211 (diff) | |
| parent | b057c68280a2f2a7b3d1fbac36f7b034e1fdf593 (diff) | |
Merge remote-tracking branch 'freebsd/main' into lf/main
Diffstat (limited to 'filesystems/libblkid/files/patch-libblkid_src_probe.c')
| -rw-r--r-- | filesystems/libblkid/files/patch-libblkid_src_probe.c | 49 |
1 files changed, 49 insertions, 0 deletions
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 */ |
