blob: ed0fd0aa422840e679c6851520e1e8c8662f92c1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#ifndef UTIL_LINUX_PARTX_H
#define UTIL_LINUX_PARTX_H
#include <sys/ioctl.h>
#include <linux/blkpg.h>
static inline int partx_del_partition(int fd, unsigned int partno)
{
struct blkpg_ioctl_arg a;
struct blkpg_partition p;
p.pno = partno;
p.start = 0;
p.length = 0;
p.devname[0] = 0;
p.volname[0] = 0;
a.op = BLKPG_DEL_PARTITION;
a.flags = 0;
a.datalen = sizeof(p);
a.data = &p;
return ioctl(fd, BLKPG, &a);
}
static inline int partx_add_partition(int fd, int partno,
uint64_t start, uint64_t size)
{
struct blkpg_ioctl_arg a;
struct blkpg_partition p;
p.pno = partno;
p.start = start << 9;
p.length = size << 9;
p.devname[0] = 0;
p.volname[0] = 0;
a.op = BLKPG_ADD_PARTITION;
a.flags = 0;
a.datalen = sizeof(p);
a.data = &p;
return ioctl(fd, BLKPG, &a);
}
#endif /* UTIL_LINUX_PARTX_H */
|