Skip to content

Commit

Permalink
calls: Update params in umount2()
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Aug 3, 2024
1 parent bdac622 commit 4368f2e
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 24 deletions.
3 changes: 1 addition & 2 deletions examples/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ fn main() {
let data = std::ptr::null_mut();
let ret = unsafe { nc::mount(src_dir, target_dir, fs_type, mount_flags, data) };
assert!(ret.is_ok());
let flags = 0;
let ret = unsafe { nc::umount2(target_dir, flags) };
let ret = unsafe { nc::umount2(target_dir, nc::UMOUNT_NOFOLLOW) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
assert!(ret.is_ok());
Expand Down
5 changes: 3 additions & 2 deletions src/calls/umount2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-aarch64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8729,15 +8729,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-arm/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9783,15 +9783,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-loongarch64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7956,15 +7956,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-mips/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9915,15 +9915,16 @@ pub unsafe fn umount<P: AsRef<Path>>(name: P) -> Result<(), Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-mips64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9468,15 +9468,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-ppc64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9834,15 +9834,16 @@ pub unsafe fn umount<P: AsRef<Path>>(name: P) -> Result<(), Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-riscv64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8690,15 +8690,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-s390x/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9516,15 +9516,16 @@ pub unsafe fn umount<P: AsRef<Path>>(name: P) -> Result<(), Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-x86/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9772,15 +9772,16 @@ pub unsafe fn umount<P: AsRef<Path>>(name: P) -> Result<(), Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux-x86_64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9554,15 +9554,16 @@ pub unsafe fn umask(mode: mode_t) -> Result<mode_t, Errno> {
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let flags = 0;
/// let flags = nc::UMOUNT_NOFOLLOW;
/// let ret = unsafe { nc::umount2(target_dir, flags) };
/// assert!(ret.is_err());
/// assert_eq!(ret, Err(nc::EPERM));
///
/// let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
/// assert!(ret.is_ok());
/// ```
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: i32) -> Result<(), Errno> {
pub unsafe fn umount2<P: AsRef<Path>>(name: P, flags: u32) -> Result<(), Errno> {
// NOTE(Shaohua): type of flags is defined as i32 in linux kernel.
let name = CString::new(name.as_ref());
let name_ptr = name.as_ptr() as usize;
let flags = flags as usize;
Expand Down

0 comments on commit 4368f2e

Please sign in to comment.