2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _VOLUME_ID_UTIL_
22 #define _VOLUME_ID_UTIL_
32 /* size of superblock buffer, reiserfs block is at 64k */
33 #define SB_BUFFER_SIZE 0x11000
34 /* size of seek buffer, FAT cluster is 32k max */
35 #define SEEK_BUFFER_SIZE 0x10000
37 /* probe volume for all known filesystems in specific order */
38 #define bswap16(x) (__u16)((((__u16)(x) & 0x00ffu) << 8) | \
39 (((__u16)(x) & 0xff00u) >> 8))
41 #define bswap32(x) (__u32)((((__u32)(x) & 0xff000000u) >> 24) | \
42 (((__u32)(x) & 0x00ff0000u) >> 8) | \
43 (((__u32)(x) & 0x0000ff00u) << 8) | \
44 (((__u32)(x) & 0x000000ffu) << 24))
46 #define bswap64(x) (__u64)((((__u64)(x) & 0xff00000000000000ull) >> 56) | \
47 (((__u64)(x) & 0x00ff000000000000ull) >> 40) | \
48 (((__u64)(x) & 0x0000ff0000000000ull) >> 24) | \
49 (((__u64)(x) & 0x000000ff00000000ull) >> 8) | \
50 (((__u64)(x) & 0x00000000ff000000ull) << 8) | \
51 (((__u64)(x) & 0x0000000000ff0000ull) << 24) | \
52 (((__u64)(x) & 0x000000000000ff00ull) << 40) | \
53 (((__u64)(x) & 0x00000000000000ffull) << 56))
55 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
56 #define le16_to_cpu(x) (x)
57 #define le32_to_cpu(x) (x)
58 #define le64_to_cpu(x) (x)
59 #define be16_to_cpu(x) bswap16(x)
60 #define be32_to_cpu(x) bswap32(x)
61 #elif (__BYTE_ORDER == __BIG_ENDIAN)
62 #define le16_to_cpu(x) bswap16(x)
63 #define le32_to_cpu(x) bswap32(x)
64 #define le64_to_cpu(x) bswap64(x)
65 #define be16_to_cpu(x) (x)
66 #define be32_to_cpu(x) (x)
81 extern void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id);
82 extern void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id);
83 extern void volume_id_set_label_raw(struct volume_id *id, const __u8 *buf, unsigned int count);
84 extern void volume_id_set_label_string(struct volume_id *id, const __u8 *buf, unsigned int count);
85 extern void volume_id_set_label_unicode16(struct volume_id *id, const __u8 *buf, enum endian endianess, unsigned int count);
86 extern void volume_id_set_uuid(struct volume_id *id, const __u8 *buf, enum uuid_format format);
87 extern __u8 *volume_id_get_buffer(struct volume_id *id, __u64 off, unsigned int len);
88 extern void volume_id_free_buffer(struct volume_id *id);
90 #endif /* _VOLUME_ID_UTIL_ */