1/* $NetBSD$ */ 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 24struct 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 */ 32union lvid { 33 struct id id[2]; 34 char s[2 * sizeof(struct id) + 1 + 7]; 35}; 36 37int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num); 38int lvnum_from_lvid(union lvid *lvid); 39int lvid_in_restricted_range(union lvid *lvid); 40 41void uuid_from_num(char *uuid, uint32_t num); 42 43int lvid_create(union lvid *lvid, struct id *vgid); 44int id_create(struct id *id); 45int id_valid(struct id *id); 46int 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 */ 52int id_write_format(const struct id *id, char *buffer, size_t size); 53 54/* 55 * Reads a formatted uuid. 56 */ 57int id_read_format(struct id *id, const char *buffer); 58 59#endif 60