diff options
author | Karel Zak | 2006-12-07 00:25:54 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:54 +0100 |
commit | 1d4ad1decc539c9729b592e6050460d6487c95f4 (patch) | |
tree | c158c5f5baf15ea4bab5c05b2f6e2bdaca332c29 /partx/partx.c | |
parent | Imported from util-linux-2.11o tarball. (diff) | |
download | kernel-qcow2-util-linux-1d4ad1decc539c9729b592e6050460d6487c95f4.tar.gz kernel-qcow2-util-linux-1d4ad1decc539c9729b592e6050460d6487c95f4.tar.xz kernel-qcow2-util-linux-1d4ad1decc539c9729b592e6050460d6487c95f4.zip |
Imported from util-linux-2.11q tarball.
Diffstat (limited to 'partx/partx.c')
-rw-r--r-- | partx/partx.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/partx/partx.c b/partx/partx.c index 212f651b6..f56c2d57e 100644 --- a/partx/partx.c +++ b/partx/partx.c @@ -9,7 +9,7 @@ * * Call: * partx [-{l|a|d}] [--type TYPE] [--nr M-N] [partition] wholedisk - * where TYPE is {dos|bsd|solaris|unixware}. + * where TYPE is {dos|bsd|solaris|unixware|gpt}. * * Read wholedisk and add all partitions: * partx -a wholedisk @@ -35,12 +35,14 @@ #include <stdlib.h> #include <string.h> #include <getopt.h> +#include <unistd.h> #include <sys/ioctl.h> #include <linux/hdreg.h> /* HDIO_GETGEO */ #include <linux/blkpg.h> #define BLKGETSIZE _IO(0x12,96) /* return device size */ #include "partx.h" +#include "crc32.h" static void errmerge(int err, int m, char *msg1, char *msg2); #define SIZE(a) (sizeof(a)/sizeof((a)[0])) @@ -58,7 +60,9 @@ struct pt { } pts[MAXTYPES]; int ptct; -addpts(char *t, ptreader f) { +static void +addpts(char *t, ptreader f) +{ if (ptct >= MAXTYPES) { fprintf(stderr, "addpts: too many types\n"); exit(1); @@ -68,20 +72,27 @@ addpts(char *t, ptreader f) { ptct++; } -initpts(){ +static void +initpts(void) +{ + addpts("gpt", read_gpt_pt); addpts("dos", read_dos_pt); addpts("bsd", read_bsd_pt); addpts("solaris", read_solaris_pt); addpts("unixware", read_unixware_pt); } -static char short_opts[] = "ladvn:t:"; +static char short_opts[] = "ladgvn:t:"; static const struct option long_opts[] = { + { "gpt", no_argument, NULL, 'g' }, { "type", required_argument, NULL, 't' }, { "nr", required_argument, NULL, 'n' }, { NULL, 0, NULL, 0 } }; +/* Used in gpt.c */ +int force_gpt=0; + int main(int argc, char **argv){ int fd, fd2, c, i, j, k, n; @@ -98,6 +109,7 @@ main(int argc, char **argv){ int ret = 0; initpts(); + init_crc32(); lower = upper = 0; type = device = diskdevice = NULL; @@ -110,6 +122,8 @@ main(int argc, char **argv){ what = ADD; break; case 'd': what = DELETE; break; + case 'g': + force_gpt=1; break; case 'n': p = optarg; lower = atoi(p); @@ -256,8 +270,8 @@ main(int argc, char **argv){ slices[j].start, slices[j].start+slices[j].size-1, slices[j].size, - ((512 * (long long) slices[j].size) - / 1000000)); + (int)((512 * (long long) slices[j].size) + / 1000000)); } if (n > 0 && what == ADD) { /* test for overlap, as in the case of an |