libblkid-tiny: use separated buffer for each block device read
[project/fstools.git] / libblkid-tiny / libblkid-tiny.h
1 /*
2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14 #ifndef _LIBBLKID_TINY_H
15 #define _LIBBLKID_TINY_H
16
17 #include <libubox/list.h>
18
19 struct blkid_struct_probe;
20
21 /*
22 * Filesystem / Raid magic strings
23 */
24 struct blkid_idmag
25 {
26 const char *magic; /* magic string */
27 unsigned int len; /* length of magic */
28
29 long kboff; /* kilobyte offset of superblock */
30 unsigned int sboff; /* byte offset within superblock */
31 };
32
33 /*
34 * Filesystem / Raid description
35 */
36 struct blkid_idinfo
37 {
38 const char *name; /* fs, raid or partition table name */
39 int usage; /* BLKID_USAGE_* flag */
40 int flags; /* BLKID_IDINFO_* flags */
41 int minsz; /* minimal device size */
42
43 /* probe function */
44 int (*probefunc)(struct blkid_struct_probe *pr, const struct blkid_idmag *mag);
45
46 struct blkid_idmag magics[]; /* NULL or array with magic strings */
47 };
48
49 /* Smaller version of the struct provided in blkidP.h */
50 struct blkid_struct_probe
51 {
52 const struct blkid_idinfo *id;
53 struct list_head list;
54
55 int fd;
56 int err;
57 char dev[32];
58 char uuid[64];
59 char label[256];
60 char version[64];
61
62 struct list_head buffers; /* list of buffers */
63 };
64
65 struct blkid_struct_probe *blkid_new_probe(void);
66 void blkid_free_probe(struct blkid_struct_probe *pr);
67
68 extern int probe_block(char *block, struct blkid_struct_probe *pr);
69 extern int mkblkdev(void);
70
71 #endif /* _LIBBLKID_TINY_H */