diff --git a/kernel/sy_old/mars_light.c b/kernel/sy_old/mars_light.c index d32c156a..ebd4f36d 100644 --- a/kernel/sy_old/mars_light.c +++ b/kernel/sy_old/mars_light.c @@ -3604,6 +3604,8 @@ static int check_deleted(void *buf, struct mars_dent *dent) enum { // root element: this must have index 0 CL_ROOT, + // global ID + CL_UUID, // global userspace CL_GLOBAL_USERSPACE, CL_GLOBAL_USERSPACE_ITEMS, @@ -3655,6 +3657,15 @@ static const struct light_class light_classes[] = { [CL_ROOT] = { }, + /* UUID, indentifying the whole cluster. + */ + [CL_UUID] = { + .cl_name = "uuid", + .cl_len = 4, + .cl_type = 'l', + .cl_father = CL_ROOT, + }, + /* Subdirectory for global userspace items... */ [CL_GLOBAL_USERSPACE] = { diff --git a/userspace/marsadm b/userspace/marsadm index 8383cec8..15cee431 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -680,6 +680,19 @@ sub is_module_loaded { sub _create_cluster { my ($cmd) = @_; system("mkdir $mars") unless -d $mars; + my $old_uuid = get_link("$mars/uuid", 2); + if ($cmd eq "create-cluster") { + ldie "cluster was already created with uuid='$old_uuid'\n" if $old_uuid && !$force; + my $uuid = `echo -n \$(hostname) \$(date)`; + set_link($uuid, "$mars/uuid"); + finish_links(); # opportunity for errors => don't continue + } elsif (!$old_uuid && !$force) { + if ($user_version == 0.1) { + my $uuid = `echo -n \$(hostname) \$(date)`; + set_link($uuid, "$mars/uuid"); + } + ldie "cluster has no uuid\n" if $user_version > 0.1; + } system("mkdir $mars/ips") unless -d "$mars/ips"; system("mkdir $mars/userspace") unless -d "$mars/userspace"; system("mkdir $mars/defaults") unless -d "$mars/defaults";