1 /* $NetBSD: uuid.h,v 1.1.1.1 2008/12/22 00:18:43 haad Exp $ */ 2 3 /* 4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 6 * 7 * This file is part of LVM2. 8 * 9 * This copyrighted material is made available to anyone wishing to use, 10 * modify, copy, or redistribute it subject to the terms and conditions 11 * of the GNU Lesser General Public License v.2.1. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software Foundation, 15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 */ 17 18 #ifndef _LVM_UUID_H 19 #define _LVM_UUID_H 20 21 #define ID_LEN 32 22 #define ID_LEN_S "32" 23 24 struct id { 25 int8_t uuid[ID_LEN]; 26 }; 27 28 /* 29 * Unique logical volume identifier 30 * With format1 this is VG uuid + LV uuid + '\0' + padding 31 */ 32 union lvid { 33 struct id id[2]; 34 char s[2 * sizeof(struct id) + 1 + 7]; 35 }; 36 37 int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num); 38 int lvnum_from_lvid(union lvid *lvid); 39 int lvid_in_restricted_range(union lvid *lvid); 40 41 void uuid_from_num(char *uuid, uint32_t num); 42 43 int lvid_create(union lvid *lvid, struct id *vgid); 44 int id_create(struct id *id); 45 int id_valid(struct id *id); 46 int id_equal(const struct id *lhs, const struct id *rhs); 47 48 /* 49 * Fills 'buffer' with a more human readable form 50 * of the uuid. 51 */ 52 int id_write_format(const struct id *id, char *buffer, size_t size); 53 54 /* 55 * Reads a formatted uuid. 56 */ 57 int id_read_format(struct id *id, const char *buffer); 58 59 #endif 60