From 998c2712ce4d19015d65a81fb6c3bd99150f7f1b Mon Sep 17 00:00:00 2001 From: jbouchard Date: Wed, 8 Sep 2021 15:48:02 -0400 Subject: [PATCH 1/2] add the delete + apply table call --- src/context.rs | 7 +++++++ src/partition.rs | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/context.rs b/src/context.rs index 481cabd..5ccae21 100644 --- a/src/context.rs +++ b/src/context.rs @@ -356,6 +356,13 @@ impl Context { v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), } } + + pub fn apply_table(&self, table: &Table) -> Result<()> { + match unsafe { fdisk_sys::fdisk_apply_table(self.ptr, table.ptr) } { + 0 => Ok(()), + v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), + } + } } impl Drop for Context { diff --git a/src/partition.rs b/src/partition.rs index deead6e..aa97ee0 100644 --- a/src/partition.rs +++ b/src/partition.rs @@ -290,4 +290,14 @@ impl Context { v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), } } + + /// Delete the specified partition + /// # Arguments + /// * `patno` - partition number (0 is the first partition) + pub fn delete_partition(&self, no: usize) -> Result<()> { + match unsafe { fdisk_sys::fdisk_delete_partition(self.ptr, no) } { + 0 => Ok(()), + v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), + } + } } From ff3d6337d195675db139388e8726f6c1448cb0fb Mon Sep 17 00:00:00 2001 From: jbouchard Date: Wed, 8 Sep 2021 16:39:56 -0400 Subject: [PATCH 2/2] drop aplly_table --- src/context.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/context.rs b/src/context.rs index 5ccae21..481cabd 100644 --- a/src/context.rs +++ b/src/context.rs @@ -356,13 +356,6 @@ impl Context { v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), } } - - pub fn apply_table(&self, table: &Table) -> Result<()> { - match unsafe { fdisk_sys::fdisk_apply_table(self.ptr, table.ptr) } { - 0 => Ok(()), - v => Err(nix::Error::from_errno(nix::errno::from_i32(-v)).into()), - } - } } impl Drop for Context {