diff options
-rw-r--r-- | drivers/md/dm-table.c | 6 | ||||
-rw-r--r-- | include/linux/device-mapper.h | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 2ec3482e942a..9917141729ef 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -774,6 +774,12 @@ int dm_table_add_target(struct dm_table *t, const char *type, t->singleton = 1; } + if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) { + DMERR("%s: target type %s may not be included in read-only tables", + dm_device_name(t->md), type); + return -EINVAL; + } + tgt->table = t; tgt->begin = start; tgt->len = len; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 294e78a7fccd..cc58e2d7c032 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -166,6 +166,13 @@ struct target_type { #define DM_TARGET_SINGLETON 0x00000001 #define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON) +/* + * Indicates that a target does not support read-only devices. + */ +#define DM_TARGET_ALWAYS_WRITEABLE 0x00000002 +#define dm_target_always_writeable(type) \ + ((type)->features & DM_TARGET_ALWAYS_WRITEABLE) + struct dm_target { struct dm_table *table; struct target_type *type; |