Skip to content

Commit

Permalink
Merge pull request #845 from bmr-cymru/bmr-private-devices
Browse files Browse the repository at this point in the history
Make internal devices private by default
  • Loading branch information
mulkieran authored Apr 3, 2023
2 parents 30bb9dd + e4c7089 commit f1e7b7d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cachedev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ impl CacheDev {
}

let table = CacheDev::gen_default_table(&meta, &cache, &origin, cache_block_size);
let dev_info = device_create(dm, name, uuid, &table, DmOptions::default())?;
let dev_info = device_create(dm, name, uuid, &table, DmOptions::private())?;

Ok(CacheDev {
dev_info: Box::new(dev_info),
Expand Down Expand Up @@ -607,7 +607,7 @@ impl CacheDev {
device_match(dm, &dev, uuid)?;
dev
} else {
let dev_info = device_create(dm, name, uuid, &table, DmOptions::default())?;
let dev_info = device_create(dm, name, uuid, &table, DmOptions::private())?;
CacheDev {
dev_info: Box::new(dev_info),
meta_dev: meta,
Expand Down
9 changes: 9 additions & 0 deletions src/core/dm_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ impl DmOptions {
pub fn udev_flags(&self) -> DmUdevFlags {
self.udev_flags
}

/// Set default udev flags for a private (internal) device.
pub fn private() -> DmOptions {
DmOptions::default().set_udev_flags(
DmUdevFlags::DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG
| DmUdevFlags::DM_UDEV_DISABLE_DISK_RULES_FLAG
| DmUdevFlags::DM_UDEV_DISABLE_OTHER_RULES_FLAG,
)
}
}
2 changes: 1 addition & 1 deletion src/lineardev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl LinearDev {
device_match(dm, &dev, uuid)?;
dev
} else {
let dev_info = device_create(dm, name, uuid, &table, DmOptions::default())?;
let dev_info = device_create(dm, name, uuid, &table, DmOptions::private())?;
LinearDev {
dev_info: Box::new(dev_info),
table,
Expand Down
4 changes: 2 additions & 2 deletions src/thinpooldev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl ThinPoolDev {

let table =
ThinPoolDev::gen_table(&meta, &data, data_block_size, low_water_mark, feature_args);
let dev_info = device_create(dm, name, uuid, &table, DmOptions::default())?;
let dev_info = device_create(dm, name, uuid, &table, DmOptions::private())?;

Ok(ThinPoolDev {
dev_info: Box::new(dev_info),
Expand Down Expand Up @@ -512,7 +512,7 @@ impl ThinPoolDev {
device_match(dm, &dev, uuid)?;
dev
} else {
let dev_info = device_create(dm, name, uuid, &table, DmOptions::default())?;
let dev_info = device_create(dm, name, uuid, &table, DmOptions::private())?;
ThinPoolDev {
dev_info: Box::new(dev_info),
meta_dev: meta,
Expand Down

0 comments on commit f1e7b7d

Please sign in to comment.