summaryrefslogtreecommitdiffstats
path: root/partx/partx.h
diff options
context:
space:
mode:
authorDavidlohr Bueso2010-12-09 21:54:17 +0100
committerKarel Zak2010-12-09 21:54:17 +0100
commitc4ecaf21d59671ac7ec0bd26bd2c346c98c7771c (patch)
treecd89a4e8048653d693b7d9f4a1507479d1ad7314 /partx/partx.h
parentmount: be more explicit about --move in mount.8 (diff)
downloadkernel-qcow2-util-linux-c4ecaf21d59671ac7ec0bd26bd2c346c98c7771c.tar.gz
kernel-qcow2-util-linux-c4ecaf21d59671ac7ec0bd26bd2c346c98c7771c.tar.xz
kernel-qcow2-util-linux-c4ecaf21d59671ac7ec0bd26bd2c346c98c7771c.zip
partx: complete rewrite
Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'partx/partx.h')
-rw-r--r--partx/partx.h70
1 files changed, 41 insertions, 29 deletions
diff --git a/partx/partx.h b/partx/partx.h
index 8702f2593..b40fa8fbd 100644
--- a/partx/partx.h
+++ b/partx/partx.h
@@ -1,32 +1,44 @@
-#ifndef PARTX_H_INCLUDED
-#define PARTX_H_INCLUDED
-
-/*
- * For each partition type there is a routine that takes
- * a block device and a range, and returns the list of
- * slices found there in the supplied array SP that can
- * hold NS entries. The return value is the number of
- * entries stored, or -1 if the appropriate type is not
- * present.
- */
-
-
-/* units: 512 byte sectors */
-struct slice {
- unsigned int start;
- unsigned int size;
-};
-
-typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
-
-extern ptreader read_dos_pt, read_bsd_pt, read_solaris_pt, read_unixware_pt, read_gpt_pt;
-extern ptreader read_sun_pt, read_mac_pt;
-
-unsigned char *getblock(int fd, unsigned int secnr);
+#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, 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
-four2int(unsigned char *p) {
- return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
+static inline int partx_add_partition(int fd, int partno,
+ unsigned long start, unsigned long 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 /* PARTX_H_INCLUDED */
+#endif /* UTIL_LINUX_PARTX_H */