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_
34 /* size of superblock buffer, reiserfs block is at 64k */
35 #define SB_BUFFER_SIZE 0x11000
36 /* size of seek buffer, FAT cluster is 32k max */
37 #define SEEK_BUFFER_SIZE 0x10000
39 /* probe volume for all known filesystems in specific order */
40 #define bswap16(x) (__u16)((((__u16)(x) & 0x00ffu) << 8) | \
41 (((__u16)(x) & 0xff00u) >> 8))
43 #define bswap32(x) (__u32)((((__u32)(x) & 0xff000000u) >> 24) | \
44 (((__u32)(x) & 0x00ff0000u) >> 8) | \
45 (((__u32)(x) & 0x0000ff00u) << 8) | \
46 (((__u32)(x) & 0x000000ffu) << 24))
48 #define bswap64(x) (__u64)((((__u64)(x) & 0xff00000000000000ull) >> 56) | \
49 (((__u64)(x) & 0x00ff000000000000ull) >> 40) | \
50 (((__u64)(x) & 0x0000ff0000000000ull) >> 24) | \
51 (((__u64)(x) & 0x000000ff00000000ull) >> 8) | \
52 (((__u64)(x) & 0x00000000ff000000ull) << 8) | \
53 (((__u64)(x) & 0x0000000000ff0000ull) << 24) | \
54 (((__u64)(x) & 0x000000000000ff00ull) << 40) | \
55 (((__u64)(x) & 0x00000000000000ffull) << 56))
58 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
59 #define le16_to_cpu(x) (x)
60 #define le32_to_cpu(x) (x)
61 #define le64_to_cpu(x) (x)
62 #define be16_to_cpu(x) bswap16(x)
63 #define be32_to_cpu(x) bswap32(x)
64 #define cpu_to_le32(x) (x)
65 #define cpu_to_be32(x) bswap32(x)
66 #elif (__BYTE_ORDER == __BIG_ENDIAN)
67 #define le16_to_cpu(x) bswap16(x)
68 #define le32_to_cpu(x) bswap32(x)
69 #define le64_to_cpu(x) bswap64(x)
70 #define be16_to_cpu(x) (x)
71 #define be32_to_cpu(x) (x)
72 #define cpu_to_le32(x) bswap32(x)
73 #define cpu_to_be32(x) (x)
75 #endif /* __BYTE_ORDER */
90 extern void volume_id_set_unicode16(char *str, unsigned int len, const __u8 *buf, enum endian endianess, unsigned int count);
91 extern void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id);
92 extern void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id);
93 extern void volume_id_set_label_raw(struct volume_id *id, const __u8 *buf, unsigned int count);
94 extern void volume_id_set_label_string(struct volume_id *id, const __u8 *buf, unsigned int count);
95 extern void volume_id_set_label_unicode16(struct volume_id *id, const __u8 *buf, enum endian endianess, unsigned int count);
96 extern void volume_id_set_uuid(struct volume_id *id, const __u8 *buf, enum uuid_format format);
97 extern __u8 *volume_id_get_buffer(struct volume_id *id, __u64 off, unsigned int len);
98 extern void volume_id_free_buffer(struct volume_id *id);
100 #endif /* _VOLUME_ID_UTIL_ */