module/removable: 'ignore' is now applied to partitions too

This means you can now do either

  ignore: [/dev/sda]

to ignore all partitions on /dev/sda, or

  ignore: [/dev/sda1]

to ignore only the first partition on /dev/sda.
This commit is contained in:
Daniel Eklöf 2020-06-21 10:24:52 +02:00
parent 5d17f1eb57
commit 87a8054ae2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -229,6 +229,7 @@ static struct partition *
add_partition(struct module *mod, struct block_device *block,
struct udev_device *dev)
{
struct private *m = mod->private;
const char *_size = udev_device_get_sysattr_value(dev, "size");
uint64_t size = 0;
if (_size != NULL)
@ -241,6 +242,16 @@ add_partition(struct module *mod, struct block_device *block,
}
#endif
const char *devname = udev_device_get_property_value(dev, "DEVNAME");
if (devname != NULL) {
tll_foreach(m->ignore, it) {
if (strcmp(it->item, devname) == 0) {
LOG_DBG("ignoring %s because it is on the ignore list", devname);
return NULL;
}
}
}
const char *label = udev_device_get_property_value(dev, "ID_FS_LABEL");
if (label == NULL)
label = udev_device_get_property_value(dev, "ID_LABEL");