From 4bd72069fd42ea9ba6231dcccd0a159de832eb63 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 8 Feb 2006 19:24:29 +0000 Subject: [PATCH] - add "blockdev --rmpart N " and "blockdev --rmparts " --- util-linux-2.13-rmparts.patch | 105 ++++++++++++++++++++++++++++++++++ util-linux.spec | 8 ++- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 util-linux-2.13-rmparts.patch diff --git a/util-linux-2.13-rmparts.patch b/util-linux-2.13-rmparts.patch new file mode 100644 index 0000000..128337d --- /dev/null +++ b/util-linux-2.13-rmparts.patch @@ -0,0 +1,105 @@ +--- util-linux-2.13-pre6/disk-utils/blockdev.c.rmparts 2006-02-08 14:10:48.000000000 -0500 ++++ util-linux-2.13-pre6/disk-utils/blockdev.c 2006-02-08 14:19:31.000000000 -0500 +@@ -29,6 +29,28 @@ + #define BLKGETSIZE64 _IOR(0x12,114,size_t) + #endif + ++#ifndef BLKPG ++#define BLKPG _IO(0x12,105) ++#define BLKPG_DEL_PARTITION 2 ++#define BLKPG_DEVNAMELTH 64 ++#define BLKPG_VOLNAMELTH 64 ++ ++struct blkpg_partition { ++ long long start; ++ long long length; ++ long long pno; ++ char devname[BLKPG_DEVNAMELTH]; ++ char volname[BLKPG_VOLNAMELTH]; ++}; ++ ++struct blkpg_ioctl_arg { ++ int op; ++ int flags; ++ int datalen; ++ void *data; ++}; ++#endif ++ + /* Maybe could be included */ + #ifndef HDIO_GETGEO + #define HDIO_GETGEO 0x0301 +@@ -93,6 +115,10 @@ + { "--rereadpt", "BLKRRPART", BLKRRPART, ARGNONE, 0, NULL, + N_("reread partition table") }, + #endif ++#ifdef BLKPG ++ { "--rmpart", "BLKPG", BLKPG, ARGINTAP, 0, "PARTNO", N_("disable partition") }, ++ { "--rmparts", "BLKPG", BLKPG, ARGNONE, 0, NULL, N_("disable all partitions") }, ++#endif + }; + + #define SIZE(a) (sizeof(a)/sizeof((a)[0])) +@@ -144,6 +170,35 @@ + return 0; + } + ++#ifdef BLKPG ++static int ++disable_partition(int fd, int partno) { ++ struct blkpg_partition part = { ++ .pno = partno, ++ }; ++ struct blkpg_ioctl_arg io = { ++ .op = BLKPG_DEL_PARTITION, ++ .datalen = sizeof(part), ++ .data = &part, ++ }; ++ int res; ++ ++ res = ioctl(fd, BLKPG, &io); ++ if (res < 0) ++ return 0; ++ return 1; ++} ++ ++static int ++disable_partitions(int fd) { ++ int p, res = 0; ++ ++ for (p = 1; p <= 256; p++) ++ res += disable_partition(fd, p); ++ return res ? 0 : -1; ++} ++#endif ++ + void do_commands(int fd, char **argv, int d); + void report_header(void); + void report_device(char *device, int quiet); +@@ -259,6 +314,12 @@ + switch(bdcms[j].argtype) { + default: + case ARGNONE: ++#ifdef BLKPG ++ if (bdcms[j].ioc == BLKPG) { ++ res = disable_partitions(fd); ++ break; ++ } ++#endif + res = ioctl(fd, bdcms[j].ioc, 0); + break; + case ARGINTA: +@@ -276,6 +337,13 @@ + bdcms[j].name); + usage(); + } ++#ifdef BLKPG ++ if (bdcms[j].ioc == BLKPG) { ++ iarg = atoi(argv[++i]); ++ res = disable_partition(fd, iarg) ? 0 : -1; ++ break; ++ } ++#endif + iarg = atoi(argv[++i]); + res = ioctl(fd, bdcms[j].ioc, &iarg); + break; diff --git a/util-linux.spec b/util-linux.spec index 27835ed..2cd966c 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -25,7 +25,7 @@ BuildRoot: %{_tmppath}/%{name}-root Summary: A collection of basic system utilities. Name: util-linux Version: 2.13 -Release: 0.14.1 +Release: 0.15 License: distributable Group: System Environment/Base @@ -167,6 +167,8 @@ Patch220: util-linux-2.12p-cal-wide.patch Patch221: util-linux-2.12p-col-EILSEQ.patch # 174111 - mount allows loopback devices to be mounted more than once to the same mount point Patch222: util-linux-2.13-mount-twiceloop.patch +# nobug - add --rmpart N and --rmparts +Patch223: util-linux-2.13-rmparts.patch # When adding patches, please make sure that it is easy to find out what bug # the # patch fixes. @@ -241,6 +243,7 @@ cp %{SOURCE8} %{SOURCE9} . %patch220 -p1 %patch221 -p1 %patch222 -p1 +%patch223 -p1 %build unset LINGUAS || : @@ -624,6 +627,9 @@ fi /sbin/losetup %changelog +* Wed Feb 8 2006 Peter Jones 2.13-0.15 +- add "blockdev --rmpart N " and "blockdev --rmparts " + * Tue Feb 07 2006 Jesse Keating - 2.13-0.14.1 - rebuilt for new gcc4.1 snapshot and glibc changes