Package: uuid-runtime Version: 1.41.6-1 Severity: wishlist Hi,
Although, it is not very useful really [1], uuidgen could generate lvm uuids. >From lvm2 source I take borrowed next code which generate a uuid, perhaps a >'-l' switch in uuidgen could generate uuid This file generate a executable who returns a valid lvm uuid ( I don't have knowledge enough to integrate in uuid-runtime code ): #include <assert.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <ctype.h> #include <stdio.h> #include <string.h> #include <stdlib.h> /* All code borrowed from lvm2 source */ #define ID_LEN 32 struct id { int8_t uuid[ID_LEN]; }; static const char _c[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#"; int read_urandom(void *buf, size_t len); int read_urandom(void *buf, size_t len) { int fd; /* FIXME: we should stat here, and handle other cases */ /* FIXME: use common _io() routine's open/read/close */ if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { printf ("fallo open, read_urandom: /dev/urandom"); return 0; } if (read(fd, buf, len) != (ssize_t) len) { printf("fallo read, read_urandom: /dev/urandom"); close(fd); return 0; } close(fd); return 1; } int id_create(struct id *id) { unsigned i; size_t len = sizeof(id->uuid); memset(id->uuid, 0, len); if (!read_urandom(&id->uuid, len)) { return 0; } /* * Skip out the last 2 chars in randomized creation for LVM1 * backwards compatibility. */ for (i = 0; i < len; i++) id->uuid[i] = _c[id->uuid[i] % (sizeof(_c) - 3)]; return 1; } int id_write_format(const struct id *id, char *buffer, size_t size) { int i, tot; static unsigned group_size[] = { 6, 4, 4, 4, 4, 4, 6 }; assert(ID_LEN == 32); /* split into groups separated by dashes */ if (size < (32 + 6 + 1)) { printf ("Couldn't write uuid, buffer too small."); return 0; } for (i = 0, tot = 0; i < 7; i++) { memcpy(buffer, id->uuid + tot, group_size[i]); buffer += group_size[i]; tot += group_size[i]; *buffer++ = '-'; } *--buffer = '\0'; return 1; } int main () { struct id id; char *uuid = malloc (50*sizeof (char)); id_create (&id); id_write_format (&id,uuid,39); printf ("%s\n",uuid); } Thank you very much [1] http://www.nabble.com/Anyone-know-the-LVM-UUID-Format--td16906548.html "Nobody has ever provided me with a satisfactory reason why an option for that would be useful. It's the pair, VG + LV that matters, not the LV on its own. " -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (990, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.29-1-686 (SMP w/2 CPU cores) Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages uuid-runtime depends on: ii libc6 2.9-15 GNU C Library: Shared libraries ii libuuid1 1.41.6-1 Universally Unique ID library ii passwd 1:4.1.4.1-1 change and administer password and uuid-runtime recommends no packages. uuid-runtime suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org