diff --git a/0001-use-u16-for-ioctl-request-and-convert-it-to-required.patch b/0001-use-u16-for-ioctl-request-and-convert-it-to-required.patch new file mode 100644 index 0000000..a05911e --- /dev/null +++ b/0001-use-u16-for-ioctl-request-and-convert-it-to-required.patch @@ -0,0 +1,69 @@ +From 88a23e80d0f6b39fb1f2888ada3dc484b662e261 Mon Sep 17 00:00:00 2001 +From: Josh Stone +Date: Fri, 1 Dec 2017 00:18:52 +0100 +Subject: [PATCH] use u16 for ioctl() request and convert it to required type + +Fixes: https://github.com/mdaffin/loopdev/issues/6 +Signed-off-by: Igor Gnatenko +--- + src/lib.rs | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/src/lib.rs b/src/lib.rs +index 4448392..8a37b0a 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -27,10 +27,10 @@ use std::path::{Path, PathBuf}; + use libc::{c_int, ioctl, uint8_t, uint32_t, uint64_t}; + use std::default::Default; + +-static LOOP_SET_FD: u64 = 0x4C00; +-static LOOP_CLR_FD: u64 = 0x4C01; +-static LOOP_SET_STATUS64: u64 = 0x4C04; +-static LOOP_CTL_GET_FREE: u64 = 0x4C82; ++static LOOP_SET_FD: u16 = 0x4C00; ++static LOOP_CLR_FD: u16 = 0x4C01; ++static LOOP_SET_STATUS64: u16 = 0x4C04; ++static LOOP_CTL_GET_FREE: u16 = 0x4C82; + + const LOOP_CONTROL: &'static str = "/dev/loop-control"; + const LOOP_PREFIX: &'static str = "/dev/loop"; +@@ -62,7 +62,7 @@ impl LoopControl { + pub fn next_free(&self) -> io::Result { + let result; + unsafe { +- result = ioctl(self.dev_file.as_raw_fd() as c_int, LOOP_CTL_GET_FREE); ++ result = ioctl(self.dev_file.as_raw_fd() as c_int, LOOP_CTL_GET_FREE.into()); + } + if result < 0 { + Err(io::Error::last_os_error()) +@@ -104,7 +104,7 @@ impl LoopDevice { + // Attach the file + unsafe { + if ioctl(self.device.as_raw_fd() as c_int, +- LOOP_SET_FD, ++ LOOP_SET_FD.into(), + bf.as_raw_fd() as c_int) < 0 { + return Err(io::Error::last_os_error()); + } +@@ -115,7 +115,7 @@ impl LoopDevice { + info.lo_offset = offset; + unsafe { + if ioctl(self.device.as_raw_fd() as c_int, +- LOOP_SET_STATUS64, ++ LOOP_SET_STATUS64.into(), + &mut info) < 0 { + try!(self.detach()); + return Err(io::Error::last_os_error()); +@@ -143,7 +143,7 @@ impl LoopDevice { + /// ``` + pub fn detach(&self) -> io::Result<()> { + unsafe { +- if ioctl(self.device.as_raw_fd() as c_int, LOOP_CLR_FD, 0) < 0 { ++ if ioctl(self.device.as_raw_fd() as c_int, LOOP_CLR_FD.into(), 0) < 0 { + return Err(io::Error::last_os_error()); + } + } +-- +2.15.1 + diff --git a/rust-loopdev.spec b/rust-loopdev.spec index 7351734..f201baa 100644 --- a/rust-loopdev.spec +++ b/rust-loopdev.spec @@ -16,6 +16,8 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{ # Initial patched metadata # * Bump errno to 0.2, https://github.com/mdaffin/loopdev/pull/5 Patch0: loopdev-0.1.2-fix-metadata.diff +# https://github.com/mdaffin/loopdev/pull/7 +Patch1: 0001-use-u16-for-ioctl-request-and-convert-it-to-required.patch ExclusiveArch: %{rust_arches}