1/* See LICENSE file for copyright and license details. */
2#ifndef ARUU_DISKUTIL_H
3#define ARUU_DISKUTIL_H
4
5#include "paths.h"
6
7#include <stddef.h>
8#include <stdint.h>
9
10struct BlockDev {
11 int fd;
12 uint64_t size;
13 size_t sec_size;
14};
15
16struct BlockDevInfo {
17 char name[32];
18 char path[128];
19 char type[16];
20 uint64_t size;
21 int major;
22 int minor;
23 char mountpoint[256];
24 char fstype[32];
25 struct BlockDevInfo *parts;
26 struct BlockDevInfo *next;
27};
28
29int blockdev_open(struct BlockDev *dev, const char *path, int writable);
30int blockdev_read(struct BlockDev *dev, uint64_t sector, void *buf, size_t sector_count);
31int blockdev_write(struct BlockDev *dev, uint64_t sector, const void *buf, size_t sector_count);
32void blockdev_close(struct BlockDev *dev);
33
34int blockdev_detect_fs(
35 struct BlockDev *dev,
36 char *type,
37 size_t type_sz,
38 char *label,
39 size_t label_sz,
40 char *uuid,
41 size_t uuid_sz
42);
43
44struct BlockDevInfo *blockdev_get_list(void);
45void blockdev_free_list(struct BlockDevInfo *list);
46
47#endif