From 6e6a182ebdaa6f1bbdb17852cc2f27f5e06477f8 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 9 Dec 2010 21:56:22 +0100 Subject: [PATCH] delpart: code consolidation Signed-off-by: Karel Zak --- partx/delpart.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/partx/delpart.c b/partx/delpart.c index 9dca7467..940cfd7d 100644 --- a/partx/delpart.c +++ b/partx/delpart.c @@ -1,18 +1,12 @@ -/* very primitive wrapper around the `delete partition' ioctl */ #include -#include #include -#include -#ifdef HAVE_LINUX_COMPILER_H -#include -#endif -#include +#include + +#include "partx.h" int main(int argc, char **argv){ int fd; - struct blkpg_ioctl_arg a; - struct blkpg_partition p; if (argc != 3) { fprintf(stderr, @@ -24,20 +18,10 @@ main(int argc, char **argv){ perror(argv[1]); exit(1); } - p.pno = atoi(argv[2]); - 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; - if (ioctl(fd, BLKPG, &a) == -1) { + if (partx_del_partition(fd, atoi(argv[2])) == -1) { perror("BLKPG"); exit(1); } - return 0; } -- 2.39.5