diff options
| author | Khem Raj <raj.khem@gmail.com> | 2023-07-07 14:33:51 -0700 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2023-07-07 14:35:29 -0700 |
| commit | b79b2514b3cd6b8fea673689c9e77827de200b5d (patch) | |
| tree | 0b4e48c0badf7654145f6a1f13523d1801dfe5e6 | |
| parent | f2cecc26c9f0c0cf3d1f461c2eebad700aa0a994 (diff) | |
| download | meta-openembedded-b79b2514b3cd6b8fea673689c9e77827de200b5d.tar.gz | |
thin-provisioning-tools: Fix build on musl.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 93 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools/0001-Replace-LFS-functions.patch b/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools/0001-Replace-LFS-functions.patch new file mode 100644 index 0000000000..a9f1c8601d --- /dev/null +++ b/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools/0001-Replace-LFS-functions.patch | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | From 289105253fbf342fd22cbcde2ccc1127f732ab09 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Fri, 7 Jul 2023 14:21:17 -0700 | ||
| 4 | Subject: [PATCH] Replace LFS functions | ||
| 5 | |||
| 6 | The original functions are able to consume 64bit off_t now a days | ||
| 7 | therefore *64 equivalents can be replaced, as a side it fixes build with | ||
| 8 | musl. | ||
| 9 | |||
| 10 | Upstream-Status: Submitted [https://github.com/jthornber/thin-provisioning-tools/pull/267] | ||
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 12 | --- | ||
| 13 | src/file_utils.rs | 10 +++++----- | ||
| 14 | src/io_engine/base.rs | 4 ++-- | ||
| 15 | src/thin/trim.rs | 2 +- | ||
| 16 | 3 files changed, 8 insertions(+), 8 deletions(-) | ||
| 17 | |||
| 18 | diff --git a/src/file_utils.rs b/src/file_utils.rs | ||
| 19 | index 0ca3c0f..d2b3ee9 100644 | ||
| 20 | --- a/src/file_utils.rs | ||
| 21 | +++ b/src/file_utils.rs | ||
| 22 | @@ -11,18 +11,18 @@ fn test_bit(mode: u32, flag: u32) -> bool { | ||
| 23 | (mode & libc::S_IFMT) == flag | ||
| 24 | } | ||
| 25 | |||
| 26 | -fn is_file_or_blk_(info: &libc::stat64) -> bool { | ||
| 27 | +fn is_file_or_blk_(info: &libc::stat) -> bool { | ||
| 28 | test_bit(info.st_mode, libc::S_IFBLK) || test_bit(info.st_mode, libc::S_IFREG) | ||
| 29 | } | ||
| 30 | |||
| 31 | // wrapper of libc::stat64 | ||
| 32 | -fn libc_stat64(path: &Path) -> io::Result<libc::stat64> { | ||
| 33 | +fn libc_stat64(path: &Path) -> io::Result<libc::stat> { | ||
| 34 | let c_path = std::ffi::CString::new(path.as_os_str().as_bytes()) | ||
| 35 | .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; | ||
| 36 | |||
| 37 | unsafe { | ||
| 38 | - let mut st: libc::stat64 = std::mem::zeroed(); | ||
| 39 | - let r = libc::stat64(c_path.as_ptr(), &mut st); | ||
| 40 | + let mut st: libc::stat = std::mem::zeroed(); | ||
| 41 | + let r = libc::stat(c_path.as_ptr(), &mut st); | ||
| 42 | if r == 0 { | ||
| 43 | Ok(st) | ||
| 44 | } else { | ||
| 45 | @@ -56,7 +56,7 @@ fn get_device_size<P: AsRef<Path>>(path: P) -> io::Result<u64> { | ||
| 46 | let fd = file.as_raw_fd(); | ||
| 47 | let mut cap = 0u64; | ||
| 48 | unsafe { | ||
| 49 | - if libc::ioctl(fd, BLKGETSIZE64 as libc::c_ulong, &mut cap) == 0 { | ||
| 50 | + if libc::ioctl(fd, BLKGETSIZE64 as libc::c_int, &mut cap) == 0 { | ||
| 51 | Ok(cap) | ||
| 52 | } else { | ||
| 53 | Err(io::Error::last_os_error()) | ||
| 54 | diff --git a/src/io_engine/base.rs b/src/io_engine/base.rs | ||
| 55 | index 725ebf7..db6209f 100644 | ||
| 56 | --- a/src/io_engine/base.rs | ||
| 57 | +++ b/src/io_engine/base.rs | ||
| 58 | @@ -115,7 +115,7 @@ pub trait VectoredIo { | ||
| 59 | |||
| 60 | fn read_vectored_at(file: &File, bufs: &mut [libc::iovec], pos: u64) -> io::Result<usize> { | ||
| 61 | let ptr = bufs.as_ptr(); | ||
| 62 | - let ret = match unsafe { libc::preadv64(file.as_raw_fd(), ptr, bufs.len() as i32, pos as i64) } | ||
| 63 | + let ret = match unsafe { libc::preadv(file.as_raw_fd(), ptr, bufs.len() as i32, pos as i64) } | ||
| 64 | { | ||
| 65 | -1 => return Err(io::Error::last_os_error()), | ||
| 66 | n => n, | ||
| 67 | @@ -125,7 +125,7 @@ fn read_vectored_at(file: &File, bufs: &mut [libc::iovec], pos: u64) -> io::Resu | ||
| 68 | |||
| 69 | fn write_vectored_at(file: &File, bufs: &[libc::iovec], pos: u64) -> io::Result<usize> { | ||
| 70 | let ptr = bufs.as_ptr(); | ||
| 71 | - let ret = match unsafe { libc::pwritev64(file.as_raw_fd(), ptr, bufs.len() as i32, pos as i64) } | ||
| 72 | + let ret = match unsafe { libc::pwritev(file.as_raw_fd(), ptr, bufs.len() as i32, pos as i64) } | ||
| 73 | { | ||
| 74 | -1 => return Err(io::Error::last_os_error()), | ||
| 75 | n => n, | ||
| 76 | diff --git a/src/thin/trim.rs b/src/thin/trim.rs | ||
| 77 | index 3d938ca..91a53dd 100644 | ||
| 78 | --- a/src/thin/trim.rs | ||
| 79 | +++ b/src/thin/trim.rs | ||
| 80 | @@ -135,7 +135,7 @@ impl<'a> Iterator for RangeIterator<'a> { | ||
| 81 | const BLKDISCARD: u32 = 0x1277; | ||
| 82 | fn ioctl_blkdiscard(fd: i32, range: &[u64; 2]) -> std::io::Result<()> { | ||
| 83 | unsafe { | ||
| 84 | - if libc::ioctl(fd, BLKDISCARD as libc::c_ulong, range) == 0 { | ||
| 85 | + if libc::ioctl(fd, BLKDISCARD as libc::c_int, range) == 0 { | ||
| 86 | Ok(()) | ||
| 87 | } else { | ||
| 88 | Err(std::io::Error::last_os_error()) | ||
| 89 | -- | ||
| 90 | 2.41.0 | ||
| 91 | |||
diff --git a/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.0.4.bb b/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.0.4.bb index 5a73024289..e79f62ff6e 100644 --- a/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.0.4.bb +++ b/meta-oe/recipes-support/thin-provisioning-tools/thin-provisioning-tools_1.0.4.bb | |||
| @@ -10,6 +10,8 @@ S = "${WORKDIR}/git" | |||
| 10 | SRC_URI = " \ | 10 | SRC_URI = " \ |
| 11 | git://github.com/jthornber/thin-provisioning-tools;branch=main;protocol=https \ | 11 | git://github.com/jthornber/thin-provisioning-tools;branch=main;protocol=https \ |
| 12 | " | 12 | " |
| 13 | SRC_URI:append:libc-musl = " file://0001-Replace-LFS-functions.patch" | ||
| 14 | |||
| 13 | SRCREV = "3baa3fa3a3e4f714e6170a4152b186f0fa1d76e1" | 15 | SRCREV = "3baa3fa3a3e4f714e6170a4152b186f0fa1d76e1" |
| 14 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)" | 16 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)" |
| 15 | 17 | ||
