Home | History | Annotate | Line # | Download | only in gpt
gpt_uuid.h revision 1.3.2.4
      1  1.3.2.2     snj /*-
      2  1.3.2.2     snj  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      3  1.3.2.2     snj  * All rights reserved.
      4  1.3.2.2     snj  *
      5  1.3.2.2     snj  * This code is derived from software contributed to The NetBSD Foundation
      6  1.3.2.2     snj  * by Christos Zoulas.
      7  1.3.2.2     snj  *
      8  1.3.2.2     snj  * Redistribution and use in source and binary forms, with or without
      9  1.3.2.2     snj  * modification, are permitted provided that the following conditions
     10  1.3.2.2     snj  * are met:
     11  1.3.2.2     snj  * 1. Redistributions of source code must retain the above copyright
     12  1.3.2.2     snj  *    notice, this list of conditions and the following disclaimer.
     13  1.3.2.2     snj  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.3.2.2     snj  *    notice, this list of conditions and the following disclaimer in the
     15  1.3.2.2     snj  *    documentation and/or other materials provided with the distribution.
     16  1.3.2.2     snj  *
     17  1.3.2.2     snj  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18  1.3.2.2     snj  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  1.3.2.2     snj  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  1.3.2.2     snj  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21  1.3.2.2     snj  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  1.3.2.2     snj  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  1.3.2.2     snj  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.3.2.2     snj  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  1.3.2.2     snj  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  1.3.2.2     snj  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  1.3.2.2     snj  * POSSIBILITY OF SUCH DAMAGE.
     28  1.3.2.2     snj  */
     29  1.3.2.2     snj #ifndef _GPT_UUID_H
     30  1.3.2.2     snj #define _GPT_UUID_H
     31  1.3.2.2     snj 
     32  1.3.2.2     snj #include <string.h>
     33  1.3.2.2     snj #include <inttypes.h>
     34  1.3.2.2     snj #ifndef HAVE_NBTOOL_CONFIG_H
     35  1.3.2.2     snj #include <sys/disklabel_gpt.h>
     36  1.3.2.2     snj #else
     37  1.3.2.2     snj #include <nbinclude/sys/disklabel_gpt.h>
     38  1.3.2.2     snj #endif
     39  1.3.2.2     snj 
     40  1.3.2.2     snj /*
     41  1.3.2.2     snj  * We define our own uuid type so that we don't have to mess around
     42  1.3.2.2     snj  * with different uuid implementation (linux+macosx which use an
     43  1.3.2.2     snj  * array, and {Free,Net}BSD who use a struct. We just need minimal
     44  1.3.2.2     snj  * support anyway
     45  1.3.2.2     snj  */
     46  1.3.2.2     snj 
     47  1.3.2.2     snj // Must match the array in gpt_uuid.c
     48  1.3.2.2     snj typedef enum {
     49  1.3.2.4  martin 	GPT_TYPE_INVALID = -1,
     50  1.3.2.2     snj 	GPT_TYPE_APPLE_HFS = 0,
     51  1.3.2.3  martin 	GPT_TYPE_APPLE_UFS,
     52  1.3.2.2     snj 	GPT_TYPE_BIOS,
     53  1.3.2.2     snj 	GPT_TYPE_EFI,
     54  1.3.2.2     snj 	GPT_TYPE_FREEBSD,
     55  1.3.2.2     snj 	GPT_TYPE_FREEBSD_SWAP,
     56  1.3.2.2     snj 	GPT_TYPE_FREEBSD_UFS,
     57  1.3.2.2     snj 	GPT_TYPE_FREEBSD_VINUM,
     58  1.3.2.2     snj 	GPT_TYPE_FREEBSD_ZFS,
     59  1.3.2.2     snj 	GPT_TYPE_LINUX_DATA,
     60  1.3.2.2     snj 	GPT_TYPE_LINUX_SWAP,
     61  1.3.2.3  martin 	GPT_TYPE_LINUX_RAID,
     62  1.3.2.3  martin 	GPT_TYPE_LINUX_LVM,
     63  1.3.2.2     snj 	GPT_TYPE_MS_BASIC_DATA,
     64  1.3.2.2     snj 	GPT_TYPE_MS_RESERVED,
     65  1.3.2.2     snj 	GPT_TYPE_NETBSD_CCD,
     66  1.3.2.2     snj 	GPT_TYPE_NETBSD_CGD,
     67  1.3.2.2     snj 	GPT_TYPE_NETBSD_FFS,
     68  1.3.2.2     snj 	GPT_TYPE_NETBSD_LFS,
     69  1.3.2.2     snj 	GPT_TYPE_NETBSD_RAIDFRAME,
     70  1.3.2.2     snj 	GPT_TYPE_NETBSD_SWAP
     71  1.3.2.2     snj } gpt_type_t;
     72  1.3.2.2     snj 
     73  1.3.2.2     snj typedef uint8_t gpt_uuid_t[16];
     74  1.3.2.2     snj extern const gpt_uuid_t gpt_uuid_nil;
     75  1.3.2.2     snj 
     76  1.3.2.2     snj __BEGIN_DECLS
     77  1.3.2.2     snj static inline int
     78  1.3.2.2     snj gpt_uuid_is_nil(const gpt_uuid_t u) {
     79  1.3.2.2     snj 	return memcmp(u, gpt_uuid_nil, sizeof(gpt_uuid_t)) == 0;
     80  1.3.2.2     snj }
     81  1.3.2.2     snj 
     82  1.3.2.2     snj static inline int
     83  1.3.2.2     snj gpt_uuid_equal(const gpt_uuid_t u1, const gpt_uuid_t u2) {
     84  1.3.2.2     snj 	return memcmp(u1, u2, sizeof(gpt_uuid_t)) == 0;
     85  1.3.2.2     snj }
     86  1.3.2.2     snj 
     87  1.3.2.2     snj static inline void
     88  1.3.2.2     snj gpt_uuid_copy(gpt_uuid_t u1, const gpt_uuid_t u2) {
     89  1.3.2.2     snj 	memcpy(u1, u2, sizeof(gpt_uuid_t));
     90  1.3.2.2     snj }
     91  1.3.2.2     snj 
     92  1.3.2.2     snj int gpt_uuid_snprintf(char *, size_t, const char *, const gpt_uuid_t);
     93  1.3.2.2     snj 
     94  1.3.2.2     snj void gpt_uuid_create(gpt_type_t, gpt_uuid_t, uint16_t *, size_t);
     95  1.3.2.2     snj 
     96  1.3.2.2     snj int gpt_uuid_parse(const char *, gpt_uuid_t);
     97  1.3.2.2     snj 
     98  1.3.2.4  martin struct gpt;
     99  1.3.2.4  martin int gpt_uuid_generate(struct gpt *, gpt_uuid_t);
    100  1.3.2.4  martin 
    101  1.3.2.4  martin void gpt_uuid_help(const char *);
    102  1.3.2.2     snj 
    103  1.3.2.2     snj __END_DECLS
    104  1.3.2.2     snj 
    105  1.3.2.2     snj #endif /* _GPT_UUID_T */
    106