Skip to content

Commit

Permalink
feat(csi/xfs): allow extra mkfs.xfs args
Browse files Browse the repository at this point in the history
Allows supporting older kernel versions when formatting the volumes,
example: "-m bigtime=0,inobtcount=0"

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
tiagolobocastro committed Mar 28, 2024
1 parent 51e592e commit 6291e49
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions control-plane/csi-driver/src/bin/node/filesystem_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pub(crate) trait FileSystemOps: Send + Sync {
#[async_trait]
impl FileSystemOps for Ext4Fs {
async fn create(&self, device: &str) -> Result<(), Error> {
let binary = format!("mkfs.{}", "ext4");
let output = Command::new(&binary)
let binary = "mkfs.ext4";
let output = Command::new(binary)
.arg(device)
.output()
.await
Expand Down Expand Up @@ -209,8 +209,16 @@ impl FileSystemOps for Ext4Fs {
#[async_trait]
impl FileSystemOps for XFs {
async fn create(&self, device: &str) -> Result<(), Error> {
let binary = format!("mkfs.{}", "xfs");
let output = Command::new(&binary)
let binary = "mkfs.xfs";
let args = match std::env::var("MKFS_XFS_ARGS") {
Ok(args) => args
.split_whitespace()
.map(str::to_string)
.collect::<Vec<_>>(),
_ => vec![],
};
let output = Command::new(binary)
.args(args)
.arg(device)
.output()
.await
Expand Down Expand Up @@ -297,8 +305,8 @@ impl FileSystemOps for XFs {
#[async_trait]
impl FileSystemOps for BtrFs {
async fn create(&self, device: &str) -> Result<(), Error> {
let binary = format!("mkfs.{}", "btrfs");
let output = Command::new(&binary)
let binary = "mkfs.btrfs";
let output = Command::new(binary)
.arg(device)
.output()
.await
Expand Down Expand Up @@ -393,7 +401,7 @@ impl FileSystemOps for BtrFs {
}

// Acknowledge the output from Command.
fn ack_command_output(output: Output, binary: String) -> Result<(), Error> {
fn ack_command_output(output: Output, binary: &str) -> Result<(), Error> {
trace!(
"Output from {} command: {}, status code: {:?}",
binary,
Expand Down

0 comments on commit 6291e49

Please sign in to comment.