diff options
author | Karel Zak | 2012-08-13 22:10:14 +0200 |
---|---|---|
committer | Karel Zak | 2012-08-13 22:10:14 +0200 |
commit | 8863a802eb9282d436cfb30ce69fb07f5ffb47b3 (patch) | |
tree | 3c39f653dff8dab4b361ed411e1cc28ad4d3ea4a /disk-utils/partx.h | |
parent | lib/sysfs; add sysfs_partno_to_devno() (diff) | |
download | kernel-qcow2-util-linux-8863a802eb9282d436cfb30ce69fb07f5ffb47b3.tar.gz kernel-qcow2-util-linux-8863a802eb9282d436cfb30ce69fb07f5ffb47b3.tar.xz kernel-qcow2-util-linux-8863a802eb9282d436cfb30ce69fb07f5ffb47b3.zip |
resizepart: add new command
This is a simple wrapper for BLKPG_RESIZE_PARTITION (since kernel 3.6).
Co-Author: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/partx.h')
-rw-r--r-- | disk-utils/partx.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/disk-utils/partx.h b/disk-utils/partx.h index ed0fd0aa4..254cd85cc 100644 --- a/disk-utils/partx.h +++ b/disk-utils/partx.h @@ -4,6 +4,18 @@ #include <sys/ioctl.h> #include <linux/blkpg.h> +#ifndef BLKPG_ADD_PARTITION +# define BLKPG_ADD_PARTITION 1 +#endif + +#ifndef BLKPG_DEL_PARTITION +# define BLKPG_DEL_PARTITION 2 +#endif + +#ifndef BLKPG_RESIZE_PARTITION +# define BLKPG_RESIZE_PARTITION 3 /* since Linux 3.6 */ +#endif + static inline int partx_del_partition(int fd, unsigned int partno) { struct blkpg_ioctl_arg a; @@ -41,4 +53,23 @@ static inline int partx_add_partition(int fd, int partno, return ioctl(fd, BLKPG, &a); } +static inline int partx_resize_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_RESIZE_PARTITION; + a.flags = 0; + a.datalen = sizeof(p); + a.data = &p; + + return ioctl(fd, BLKPG, &a); +} + #endif /* UTIL_LINUX_PARTX_H */ |