diff options
author | Karel Zak | 2017-07-13 13:46:52 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-14 11:34:55 +0200 |
commit | 87d04a3339252c023bf9025c38c0ec7d3f5ee817 (patch) | |
tree | de5bd61cc11b44980edcf90f086f5bb207c6bf79 /disk-utils | |
parent | libfdisk: add comment (diff) | |
download | kernel-qcow2-util-linux-87d04a3339252c023bf9025c38c0ec7d3f5ee817.tar.gz kernel-qcow2-util-linux-87d04a3339252c023bf9025c38c0ec7d3f5ee817.tar.xz kernel-qcow2-util-linux-87d04a3339252c023bf9025c38c0ec7d3f5ee817.zip |
partx: move partx.h to include/
Let's make the ioctls usable also for libfdisk.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/Makemodule.am | 16 | ||||
-rw-r--r-- | disk-utils/partx.h | 62 |
2 files changed, 4 insertions, 74 deletions
diff --git a/disk-utils/Makemodule.am b/disk-utils/Makemodule.am index 49bfe8e18..bea0ed6a6 100644 --- a/disk-utils/Makemodule.am +++ b/disk-utils/Makemodule.am @@ -212,24 +212,16 @@ dist_man_MANS += \ disk-utils/resizepart.8 \ disk-utils/partx.8 -addpart_SOURCES = \ - disk-utils/addpart.c \ - disk-utils/partx.h +addpart_SOURCES = disk-utils/addpart.c addpart_LDADD = $(LDADD) libcommon.la -delpart_SOURCES = \ - disk-utils/delpart.c \ - disk-utils/partx.h +delpart_SOURCES = disk-utils/delpart.c delpart_LDADD = $(LDADD) libcommon.la -resizepart_SOURCES = \ - disk-utils/resizepart.c \ - disk-utils/partx.h +resizepart_SOURCES = disk-utils/resizepart.c resizepart_LDADD = $(LDADD) libcommon.la -partx_SOURCES = \ - disk-utils/partx.c \ - disk-utils/partx.h +partx_SOURCES = disk-utils/partx.c partx_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir) -I$(ul_libsmartcols_incdir) partx_LDADD = $(LDADD) libblkid.la libcommon.la libsmartcols.la diff --git a/disk-utils/partx.h b/disk-utils/partx.h deleted file mode 100644 index 96206bd7c..000000000 --- a/disk-utils/partx.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef UTIL_LINUX_PARTX_H -#define UTIL_LINUX_PARTX_H - -#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 - - -#define INIT_BLKPG_PARTITION(_partno, _start, _size) { \ - .pno = (_partno), \ - .start = (_start) << 9, \ - .length = (_size) << 9, \ - .devname[0] = 0, \ - .volname[0] = 0 \ -} - -#define INIT_BLKPG_ARG(_action, _part) { \ - .op = (_action), \ - .flags = 0, \ - .datalen = sizeof(*(_part)), \ - .data = (_part) \ -} - - -static inline int partx_del_partition(int fd, unsigned int partno) -{ - struct blkpg_partition p = INIT_BLKPG_PARTITION(partno, 0, 0); - struct blkpg_ioctl_arg a = INIT_BLKPG_ARG(BLKPG_DEL_PARTITION, &p); - - return ioctl(fd, BLKPG, &a); -} - -static inline int partx_add_partition(int fd, int partno, - uint64_t start, uint64_t size) -{ - struct blkpg_partition p = INIT_BLKPG_PARTITION(partno, start, size); - struct blkpg_ioctl_arg a = INIT_BLKPG_ARG(BLKPG_ADD_PARTITION, &p); - - return ioctl(fd, BLKPG, &a); -} - -static inline int partx_resize_partition(int fd, int partno, - uint64_t start, uint64_t size) -{ - struct blkpg_partition p = INIT_BLKPG_PARTITION(partno, start, size); - struct blkpg_ioctl_arg a = INIT_BLKPG_ARG(BLKPG_RESIZE_PARTITION, &p); - - return ioctl(fd, BLKPG, &a); -} - -#endif /* UTIL_LINUX_PARTX_H */ |