master xplshn/aruu / shared / diskutil.h
 1/* See LICENSE file for copyright and license details. */
 2#ifndef ARUU_DISKUTIL_H
 3#define ARUU_DISKUTIL_H
 4
 5#include <stdint.h>
 6#include <stddef.h>
 7
 8struct BlockDev {
 9	int fd;
10	uint64_t size; /* size in bytes */
11	size_t sec_size; /* sector size */
12};
13
14struct BlockDevInfo {
15	char name[32];
16	char type[16]; /* disk, part, loop */
17	uint64_t size;
18	int major;
19	int minor;
20	char mountpoint[256];
21	char fstype[32];
22	struct BlockDevInfo *parts;
23	struct BlockDevInfo *next;
24};
25
26int blockdev_open(struct BlockDev *dev, const char *path, int writable);
27int blockdev_read(struct BlockDev *dev, uint64_t sector, void *buf, size_t sector_count);
28int blockdev_write(struct BlockDev *dev, uint64_t sector, const void *buf, size_t sector_count);
29void blockdev_close(struct BlockDev *dev);
30
31struct BlockDevInfo *blockdev_get_list(void);
32void blockdev_free_list(struct BlockDevInfo *list);
33
34#endif