Introduce a SEG_NOEXPLICIT flag. The flag means that the segment cannot be explicitly created with lvcreate --type. It is used on shared snapshots, to prevent a crash when the user uses "multisnapshot" or "multisnap-snap" segment type. I also added it to legacy snapshots, but it is not needed there (the create routine already converts "snapshots" type to "striped"). Signed-off-by: Mikulas Patocka --- lib/metadata/lv_manip.c | 5 +++++ lib/metadata/segtype.h | 1 + lib/multisnapshot/multisnapshot.c | 4 ++-- lib/snapshot/snapshot.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) Index: LVM2.2.02.53/lib/metadata/segtype.h =================================================================== --- LVM2.2.02.53.orig/lib/metadata/segtype.h 2009-10-13 23:38:52.000000000 +0200 +++ LVM2.2.02.53/lib/metadata/segtype.h 2009-10-13 23:39:38.000000000 +0200 @@ -33,6 +33,7 @@ struct dev_manager; #define SEG_VIRTUAL 0x00000020U #define SEG_CANNOT_BE_ZEROED 0x00000040U #define SEG_MONITORED 0x00000080U +#define SEG_NOEXPLICIT 0x00000100U #define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0) #define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0) Index: LVM2.2.02.53/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.53.orig/lib/multisnapshot/multisnapshot.c 2009-10-13 23:38:52.000000000 +0200 +++ LVM2.2.02.53/lib/multisnapshot/multisnapshot.c 2009-10-13 23:39:38.000000000 +0200 @@ -253,7 +253,7 @@ int init_multiple_segtypes(struct cmd_co segtype->ops = &_multisnapshot_ops; segtype->name = "multisnapshot"; segtype->private = NULL; - segtype->flags = SEG_SNAPSHOT; + segtype->flags = SEG_SNAPSHOT | SEG_NOEXPLICIT; if (!lvm_register_segtype(lib, segtype)) return 0; @@ -268,7 +268,7 @@ int init_multiple_segtypes(struct cmd_co segtype->ops = &_multisnap_snap_ops; segtype->name = "multisnap-snap"; segtype->private = NULL; - segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED; + segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED | SEG_NOEXPLICIT; if (!lvm_register_segtype(lib, segtype)) return 0; Index: LVM2.2.02.53/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.53.orig/lib/snapshot/snapshot.c 2009-10-13 23:38:52.000000000 +0200 +++ LVM2.2.02.53/lib/snapshot/snapshot.c 2009-10-13 23:39:38.000000000 +0200 @@ -305,7 +305,7 @@ struct segment_type *init_segtype(struct segtype->ops = &_snapshot_ops; segtype->name = "snapshot"; segtype->private = NULL; - segtype->flags = SEG_SNAPSHOT; + segtype->flags = SEG_SNAPSHOT | SEG_NOEXPLICIT; #ifdef DMEVENTD if (_get_snapshot_dso_path(cmd, &dso)) Index: LVM2.2.02.53/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.53.orig/lib/metadata/lv_manip.c 2009-10-13 23:39:33.000000000 +0200 +++ LVM2.2.02.53/lib/metadata/lv_manip.c 2009-10-13 23:39:38.000000000 +0200 @@ -3015,6 +3015,11 @@ again: if (!(lp->segtype = get_segtype_from_string(cmd, "multisnap-snap"))) return_0; } + } else { + if (lp->segtype->flags & SEG_NOEXPLICIT) { + log_error("This type of segment cannot be explicitly created"); + return 0; + } } if (lp->snapshot && lv_is_multisnap_origin(org)) {