diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 291fb7f..0000000 --- a/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -util-linux-ng-2.17.1-rc1.tar.bz2 -floppy-0.16.tar.bz2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ad747b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +util-linux-ng-2.17.2.tar.bz2 +floppy-0.16.tar.bz2 diff --git a/Makefile b/Makefile deleted file mode 100644 index c5d5fa9..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: util-linux-ng -# $Id: Makefile,v 1.1 2007/08/17 21:07:02 wtogami Exp $ -NAME := util-linux-ng -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/mount.tmpfs b/mount.tmpfs index e37f735..5495c9d 100644 --- a/mount.tmpfs +++ b/mount.tmpfs @@ -18,11 +18,34 @@ case $1 in ;; esac -if ! echo "$@" | grep -q -E '(fs|def|root)?context='; then - con=$(ls --scontext -d "$2" | cut -f 1 -d ' ') - if [ -n "$con" ] && [ "$con" != "?" ] && [ "$con" != "unlabeled" ]; then - exec /bin/mount "$@" -o "rootcontext=\"$con\"" -i -t tmpfs +restricted=1 + +if [ $UID -eq 0 ] && [ $UID -eq $EUID ]; then + restricted=0 +fi + +# mount(8) in restricted mode (for non-root users) does not allow to use any +# mount options, types or so on command line. We have to call mount(8) with +# mountpoint only. All necessary options have to be defined in /etc/fstab. +# +# https://bugzilla.redhat.com/show_bug.cgi?id=615719 +# +if [ $restricted -eq 1 ]; then + exec /bin/mount -i "$2" +fi + +# Remount with context mount options is unsupported +# http://bugzilla.redhat.com/show_bug.cgi?id=563267 +# +if ! echo "$@" | grep -q -E '\-o.*remount'; then + + if ! echo "$@" | grep -q -E '(fs|def|root)?context='; then + con=$(ls --scontext -d "$2" | cut -f 1 -d ' ') + if [ -n "$con" ] && [ "$con" != "?" ] && [ "$con" != "unlabeled" ]; then + exec /bin/mount "$@" -o "rootcontext=\"$con\"" -i -t tmpfs + fi fi + fi exec /bin/mount "$@" -i -t tmpfs diff --git a/sources b/sources index 95d2f4f..1a4e496 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -2fb632d41d4bb47b02a41ced45e4649f util-linux-ng-2.17.1-rc1.tar.bz2 +4635725a3eef1c57090bac8ea5e082e6 util-linux-ng-2.17.2.tar.bz2 7eeb9a6f7a258174bf0fa80f1370788d floppy-0.16.tar.bz2 diff --git a/util-linux-ng-2.13-login-lastlog.patch b/util-linux-ng-2.13-login-lastlog.patch index 548b99d..aa07388 100644 --- a/util-linux-ng-2.13-login-lastlog.patch +++ b/util-linux-ng-2.13-login-lastlog.patch @@ -1,8 +1,10 @@ -Index: util-linux-ng-2.14.2-rc1/login-utils/login.c -=================================================================== ---- util-linux-ng-2.14.2-rc1.orig/login-utils/login.c -+++ util-linux-ng-2.14.2-rc1/login-utils/login.c -@@ -1415,7 +1415,7 @@ dolastlog(int quiet) { +--- + login-utils/login.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- util-linux-ng-2.17.2.orig/login-utils/login.c ++++ util-linux-ng-2.17.2/login-utils/login.c +@@ -1431,7 +1431,7 @@ dolastlog(int quiet) { struct lastlog ll; int fd; diff --git a/util-linux-ng-2.15-ipcs-32bit.patch b/util-linux-ng-2.15-ipcs-32bit.patch index c3860f1..bb188b3 100644 --- a/util-linux-ng-2.15-ipcs-32bit.patch +++ b/util-linux-ng-2.15-ipcs-32bit.patch @@ -1,7 +1,10 @@ -diff -up util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c.kzak util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c ---- util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c.kzak 2009-03-25 13:19:08.000000000 +0100 -+++ util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c 2009-06-04 15:22:48.000000000 +0200 -@@ -243,6 +243,26 @@ print_perms (int id, struct ipc_perm *ip +--- + sys-utils/ipcs.c | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +--- util-linux-ng-2.17.2.orig/sys-utils/ipcs.c ++++ util-linux-ng-2.17.2/sys-utils/ipcs.c +@@ -239,6 +239,26 @@ print_perms (int id, struct ipc_perm *ip printf(" %-10d\n", ipcp->gid); } @@ -28,7 +31,7 @@ diff -up util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c.kzak util-linux-ng-2.15.1-rc1 void do_shm (char format) { -@@ -266,12 +286,12 @@ void do_shm (char format) +@@ -262,12 +282,12 @@ void do_shm (char format) return; /* glibc 2.1.3 and all earlier libc's have ints as fields of struct shminfo; glibc 2.1.91 has unsigned long; ach */ diff --git a/util-linux-ng-2.16-blkid-cachefile.patch b/util-linux-ng-2.16-blkid-cachefile.patch index 5cff6d7..19d0225 100644 --- a/util-linux-ng-2.16-blkid-cachefile.patch +++ b/util-linux-ng-2.16-blkid-cachefile.patch @@ -1,6 +1,12 @@ -diff -up util-linux-ng-2.17-git5e51568/misc-utils/blkid.8.kzak util-linux-ng-2.17-git5e51568/misc-utils/blkid.8 ---- util-linux-ng-2.17-git5e51568/misc-utils/blkid.8.kzak 2009-10-16 22:50:03.000000000 +0200 -+++ util-linux-ng-2.17-git5e51568/misc-utils/blkid.8 2009-10-19 14:31:10.000000000 +0200 +--- + misc-utils/blkid.8 | 4 ++-- + misc-utils/blkid.c | 2 +- + shlibs/blkid/libblkid.3 | 6 +++--- + shlibs/blkid/src/blkidP.h | 2 +- + 4 files changed, 7 insertions(+), 7 deletions(-) + +--- util-linux-ng-2.17.2.orig/misc-utils/blkid.8 ++++ util-linux-ng-2.17.2/misc-utils/blkid.8 @@ -67,7 +67,7 @@ more devices. Read from .I cachefile @@ -19,10 +25,9 @@ diff -up util-linux-ng-2.17-git5e51568/misc-utils/blkid.8.kzak util-linux-ng-2.1 If you don't want to save the cache to the default file, specify .IR /dev/null. If not specified it will be the same file as that given by the -diff -up util-linux-ng-2.17-git5e51568/misc-utils/blkid.c.kzak util-linux-ng-2.17-git5e51568/misc-utils/blkid.c ---- util-linux-ng-2.17-git5e51568/misc-utils/blkid.c.kzak 2009-10-16 22:50:03.000000000 +0200 -+++ util-linux-ng-2.17-git5e51568/misc-utils/blkid.c 2009-10-19 14:31:10.000000000 +0200 -@@ -62,7 +62,7 @@ static void usage(int error) +--- util-linux-ng-2.17.2.orig/misc-utils/blkid.c ++++ util-linux-ng-2.17.2/misc-utils/blkid.c +@@ -58,7 +58,7 @@ static void usage(int error) " [-t ] [-w ] [dev ...]\n\n" " %1$s -p [-O ] [-S ] [-o format] [dev ...]\n\n" "Options:\n" @@ -31,9 +36,8 @@ diff -up util-linux-ng-2.17-git5e51568/misc-utils/blkid.c.kzak util-linux-ng-2.1 " -h print this usage message and exit\n" " -g garbage collect the blkid cache\n" " -o output format; can be one of:\n" -diff -up util-linux-ng-2.17-git5e51568/shlibs/blkid/libblkid.3.kzak util-linux-ng-2.17-git5e51568/shlibs/blkid/libblkid.3 ---- util-linux-ng-2.17-git5e51568/shlibs/blkid/libblkid.3.kzak 2009-10-16 22:50:03.000000000 +0200 -+++ util-linux-ng-2.17-git5e51568/shlibs/blkid/libblkid.3 2009-10-19 14:31:10.000000000 +0200 +--- util-linux-ng-2.17.2.orig/shlibs/blkid/libblkid.3 ++++ util-linux-ng-2.17.2/shlibs/blkid/libblkid.3 @@ -24,7 +24,7 @@ A common use is to allow use of LABEL= a specific block device names into configuration files. .P @@ -61,10 +65,9 @@ diff -up util-linux-ng-2.17-git5e51568/shlibs/blkid/libblkid.3.kzak util-linux-n caches data extracted from each recognized block device .TP .I /etc/blkid.conf -diff -up util-linux-ng-2.17-git5e51568/shlibs/blkid/src/blkidP.h.kzak util-linux-ng-2.17-git5e51568/shlibs/blkid/src/blkidP.h ---- util-linux-ng-2.17-git5e51568/shlibs/blkid/src/blkidP.h.kzak 2009-10-16 22:50:03.000000000 +0200 -+++ util-linux-ng-2.17-git5e51568/shlibs/blkid/src/blkidP.h 2009-10-19 14:32:03.000000000 +0200 -@@ -267,7 +267,7 @@ extern char *blkid_strconcat(const char +--- util-linux-ng-2.17.2.orig/shlibs/blkid/src/blkidP.h ++++ util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h +@@ -268,7 +268,7 @@ extern char *blkid_strconcat(const char extern int blkid_fstatat(DIR *dir, const char *dirname, const char *filename, struct stat *st, int nofollow); diff --git a/util-linux-ng-2.17-agetty-clocal.patch b/util-linux-ng-2.17-agetty-clocal.patch new file mode 100644 index 0000000..9429a23 --- /dev/null +++ b/util-linux-ng-2.17-agetty-clocal.patch @@ -0,0 +1,30 @@ +From 9fcaa8826c180273829cf03e5fe34e08daef721f Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 12 Jul 2010 11:57:55 +0200 +Subject: [PATCH] aggety: don't wipe CLOCAL flag + +gettey should not clear the flag. It seems that the flag is +automatically enabled for serial consoles tht don't use CD signal. + +Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=598631 +Signed-off-by: Karel Zak +--- + login-utils/agetty.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/login-utils/agetty.c b/login-utils/agetty.c +index 39a1fd3..0cb00db 100644 +--- a/login-utils/agetty.c ++++ b/login-utils/agetty.c +@@ -706,7 +706,7 @@ termio_init(tp, speed, op) + /* flush input and output queues, important for modems! */ + (void) tcflush(0, TCIOFLUSH); + +- tp->c_cflag = CS8 | HUPCL | CREAD; ++ tp->c_cflag = CS8 | HUPCL | CREAD | (tp->c_cflag & CLOCAL); + cfsetispeed(tp, speed); + cfsetospeed(tp, speed); + if (op->flags & F_LOCAL) { +-- +1.6.6.1 + diff --git a/util-linux-ng-2.17-blkid-cdrom.patch b/util-linux-ng-2.17-blkid-cdrom.patch new file mode 100644 index 0000000..847bd07 --- /dev/null +++ b/util-linux-ng-2.17-blkid-cdrom.patch @@ -0,0 +1,104 @@ + +based on upstream patch: + + commit 55113b15afe5f61fc917c22a9d8d47f89b37c757 + Author: M.S.Colclough + Date: Wed Mar 31 18:11:00 2010 +0200 + + libblkid: avoid probing CDs for RAID + + RAID probing of CD/DVD can yield errors because of well-known problem + in reading the end of the disk with some disk/drive combinations. + Borrow CD detection method from udev and skip the RAID tests for + these devices. + + [kzak@redhat.com: - check for linux/cdrom.h in ./configure + - add #ifdef around the ioctl call + - call the ioctl for block devices only] + + Signed-off-by: Mark Colclough + Signed-off-by: Karel Zak + + +--- + shlibs/blkid/src/blkidP.h | 2 ++ + shlibs/blkid/src/probe.c | 14 ++++++++++++++ + shlibs/blkid/src/superblocks/superblocks.c | 5 +++++ + 3 files changed, 21 insertions(+) + +--- util-linux-ng-2.17.2.orig/shlibs/blkid/src/blkidP.h ++++ util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h +@@ -209,6 +209,7 @@ struct blkid_struct_probe + /* flags */ + #define BLKID_PRIVATE_FD (1 << 1) /* see blkid_new_probe_from_filename() */ + #define BLKID_TINY_DEV (1 << 2) /* <= 1.47MiB (floppy or so) */ ++#define BLKID_CDROM_DEV (1 << 3) /* is a CD/DVD drive */ + + /* + * Evaluation methods (for blkid_eval_* API) +@@ -363,6 +364,7 @@ extern void blkid_free_dev(blkid_dev dev + + /* probe.c */ + extern int blkid_probe_is_tiny(blkid_probe pr); ++extern int blkid_probe_is_cdrom(blkid_probe pr); + extern unsigned char *blkid_probe_get_buffer(blkid_probe pr, + blkid_loff_t off, blkid_loff_t len); + +--- util-linux-ng-2.17.2.orig/shlibs/blkid/src/probe.c ++++ util-linux-ng-2.17.2/shlibs/blkid/src/probe.c +@@ -77,6 +77,7 @@ + #include + #include + #include ++#include + #ifdef HAVE_SYS_STAT_H + #include + #endif +@@ -545,6 +546,14 @@ int blkid_probe_is_tiny(blkid_probe pr) + return pr && (pr->flags & BLKID_TINY_DEV); + } + ++/* ++ * CDROMs may fail when probed for RAID (last sector problem) ++ */ ++int blkid_probe_is_cdrom(blkid_probe pr) ++{ ++ return pr && (pr->flags & BLKID_CDROM_DEV); ++} ++ + /** + * blkid_probe_set_device: + * @pr: probe +@@ -570,6 +579,7 @@ int blkid_probe_set_device(blkid_probe p + + pr->flags &= ~BLKID_PRIVATE_FD; + pr->flags &= ~BLKID_TINY_DEV; ++ pr->flags &= ~BLKID_CDROM_DEV; + pr->fd = fd; + pr->off = off; + pr->size = 0; +@@ -615,6 +625,10 @@ int blkid_probe_set_device(blkid_probe p + if (pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode)) + pr->flags |= BLKID_TINY_DEV; + ++#ifdef CDROM_GET_CAPABILITY ++ if (S_ISBLK(pr->mode) && ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) ++ pr->flags |= BLKID_CDROM_DEV; ++#endif + return 0; + err: + DBG(DEBUG_LOWPROBE, +--- util-linux-ng-2.17.2.orig/shlibs/blkid/src/superblocks/superblocks.c ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.c +@@ -342,6 +342,11 @@ static int superblocks_probe(blkid_probe + blkid_probe_is_tiny(pr)) + continue; + ++ /* don't probe for RAIDs, swap or journal on floppies or CD/DVDs */ ++ if ((id->usage & (BLKID_USAGE_RAID | BLKID_USAGE_OTHER)) && ++ (blkid_probe_is_tiny(pr) || blkid_probe_is_cdrom(pr))) ++ continue; ++ + DBG(DEBUG_LOWPROBE, printf("[%d] %s:\n", i, id->name)); + + /* try to detect by magic string */ diff --git a/util-linux-ng-2.17-blkid-raid.patch b/util-linux-ng-2.17-blkid-raid.patch new file mode 100644 index 0000000..8d601b8 --- /dev/null +++ b/util-linux-ng-2.17-blkid-raid.patch @@ -0,0 +1,1512 @@ +diff -up util-linux-ng-2.17.2/misc-utils/blkid.c.kzak util-linux-ng-2.17.2/misc-utils/blkid.c +--- util-linux-ng-2.17.2/misc-utils/blkid.c.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/misc-utils/blkid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -423,33 +423,34 @@ static int lowprobe_device(blkid_probe p + + if (fstat(fd, &st)) + goto done; +- /* +- * partitions probing +- */ +- blkid_probe_enable_superblocks(pr, 0); /* enabled by default ;-( */ + + blkid_probe_enable_partitions(pr, 1); +- rc = blkid_do_fullprobe(pr); +- blkid_probe_enable_partitions(pr, 0); + +- if (rc < 0) +- goto done; /* -1 = error, 1 = nothing, 0 = succes */ +- +- /* +- * Don't probe for FS/RAIDs on small devices +- */ +- if (rc || S_ISCHR(st.st_mode) || +- blkid_probe_get_size(pr) > 1024 * 1440) { ++ if (!S_ISCHR(st.st_mode) && blkid_probe_get_size(pr) <= 1024 * 1440) { + /* +- * filesystems/RAIDs probing ++ * check if the small disk is partitioned, if yes then ++ * don't probe for filesystems. + */ +- blkid_probe_enable_superblocks(pr, 1); ++ blkid_probe_enable_superblocks(pr, 0); + +- rc = blkid_do_safeprobe(pr); ++ rc = blkid_do_fullprobe(pr); + if (rc < 0) +- goto done; ++ goto done; /* -1 = error, 1 = nothing, 0 = succes */ ++ ++ if (blkid_probe_lookup_value(pr, "PTTYPE", NULL, NULL) == 0) ++ /* partition table detected */ ++ goto print_vals; ++ ++ /* small whole-disk is unpartitioned, probe for filesystems only */ ++ blkid_probe_enable_partitions(pr, 0); + } + ++ blkid_probe_enable_superblocks(pr, 1); ++ ++ rc = blkid_do_safeprobe(pr); ++ if (rc < 0) ++ goto done; ++print_vals: + nvals = blkid_probe_numof_values(pr); + + if (output & OUTPUT_DEVICE_ONLY) { +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h.kzak util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h +--- util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/blkidP.h 2011-01-12 14:54:53.000000000 +0100 +@@ -192,10 +192,12 @@ struct blkid_struct_probe + blkid_loff_t size; /* end of data on the device */ + + dev_t devno; /* device number (st.st_rdev) */ ++ dev_t disk_devno; /* devno of the whole-disk or 0 */ + unsigned int blkssz; /* sector size (BLKSSZGET ioctl) */ + mode_t mode; /* struct stat.sb_mode */ + + int flags; /* private libray flags */ ++ int prob_flags; /* always zeroized by blkid_do_*() */ + + struct list_head buffers; /* list of buffers */ + +@@ -206,10 +208,12 @@ struct blkid_struct_probe + int nvals; /* number of assigned vals */ + }; + +-/* flags */ ++/* private flags */ + #define BLKID_PRIVATE_FD (1 << 1) /* see blkid_new_probe_from_filename() */ + #define BLKID_TINY_DEV (1 << 2) /* <= 1.47MiB (floppy or so) */ + #define BLKID_CDROM_DEV (1 << 3) /* is a CD/DVD drive */ ++/* private probing flags */ ++#define BLKID_PARTS_IGNORE_PT (1 << 1) /* ignore partition table */ + + /* + * Evaluation methods (for blkid_eval_* API) +@@ -363,6 +367,8 @@ extern blkid_dev blkid_new_dev(void); + extern void blkid_free_dev(blkid_dev dev); + + /* probe.c */ ++extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr); ++extern int blkid_probe_is_wholedisk(blkid_probe pr); + extern int blkid_probe_is_tiny(blkid_probe pr); + extern int blkid_probe_is_cdrom(blkid_probe pr); + extern unsigned char *blkid_probe_get_buffer(blkid_probe pr, +@@ -383,6 +389,9 @@ extern int blkid_probe_set_dimension(blk + + extern blkid_partlist blkid_probe_get_partlist(blkid_probe pr); + ++extern int blkid_probe_is_covered_by_pt(blkid_probe pr, ++ blkid_loff_t offset, blkid_loff_t size); ++ + extern void blkid_probe_chain_reset_vals(blkid_probe pr, struct blkid_chain *chn); + extern int blkid_probe_chain_copy_vals(blkid_probe pr, struct blkid_chain *chn, + struct blkid_prval *vals, int nvals); +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/partitions/partitions.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/partitions/partitions.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/partitions/partitions.c.kzak 2010-03-22 09:05:43.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/partitions/partitions.c 2011-01-12 14:57:34.000000000 +0100 +@@ -566,6 +566,9 @@ static int partitions_probe(blkid_probe + if (chn->binary) + partitions_init_data(pr, chn); + ++ if (pr->prob_flags & BLKID_PARTS_IGNORE_PT) ++ return 1; ++ + DBG(DEBUG_LOWPROBE, + printf("--> starting probing loop [PARTS idx=%d]\n", + chn->idx)); +@@ -652,6 +655,95 @@ int blkid_partitions_do_subprobe(blkid_p + return rc; + } + ++/* ++ * This function is compatible with blkid_probe_get_partitions(), but the ++ * result is not stored in @pr and all probing is independent on the ++ * status of @pr. It's possible to call this function from arbitrary ++ * place without a care about @pr. ++ */ ++static blkid_partlist blkid_probe_get_independent_partlist(blkid_probe pr) ++{ ++ ++ blkid_partlist ls = NULL, org_ls = NULL; ++ struct blkid_chain *chn = &pr->chains[BLKID_CHAIN_PARTS]; ++ struct blkid_prval vals[BLKID_NVALS_PARTS]; ++ int nvals = BLKID_NVALS_PARTS; ++ int idx; ++ ++ /* save old results */ ++ nvals = blkid_probe_chain_copy_vals(pr, chn, vals, nvals); ++ idx = chn->idx; ++ if (chn->data) { ++ org_ls = chn->data; ++ chn->data = NULL; ++ } ++ ++ ls = blkid_probe_get_partitions(pr); ++ ++ /* restore original results */ ++ chn->data = org_ls; ++ chn->idx = idx; ++ ++ blkid_probe_chain_reset_vals(pr, chn); ++ blkid_probe_append_vals(pr, vals, nvals); ++ ++ return ls; ++} ++ ++/* ++ * Returns 1 if the device is whole-disk and the area specified by @offset and ++ * @size is covered by any partition. ++ */ ++int blkid_probe_is_covered_by_pt(blkid_probe pr, ++ blkid_loff_t offset, blkid_loff_t size) ++{ ++ blkid_partlist ls = NULL; ++ blkid_loff_t start, end; ++ int nparts, i, rc = 0; ++ ++ DBG(DEBUG_LOWPROBE, printf( ++ "=> checking if off=%jd size=%jd covered by PT\n", ++ offset, size)); ++ ++ ls = blkid_probe_get_independent_partlist(pr); ++ if (!ls) ++ goto done; ++ ++ nparts = blkid_partlist_numof_partitions(ls); ++ if (!nparts) ++ goto done; ++ ++ end = (offset + size) >> 9; ++ start = offset >> 9; ++ ++ /* check if the partition table fits into the device */ ++ for (i = 0; i < nparts; i++) { ++ blkid_partition par = &ls->parts[i]; ++ ++ if (par->start + par->size > (pr->size >> 9)) { ++ DBG(DEBUG_LOWPROBE, printf("partition #%d overflows " ++ "device (off=%lu size=%lu)\n", ++ par->partno, par->start, par->size)); ++ goto done; ++ } ++ } ++ ++ /* check if the requested area is covered by PT */ ++ for (i = 0; i < nparts; i++) { ++ blkid_partition par = &ls->parts[i]; ++ ++ if (start >= par->start && end <= par->start + par->size) { ++ rc = 1; ++ break; ++ } ++ } ++done: ++ partitions_free_data(pr, (void *)ls); ++ ++ DBG(DEBUG_LOWPROBE, printf("<= %s covered by PT\n", rc ? "IS" : "NOT")); ++ return rc; ++} ++ + /** + * blkid_known_pttype: + * @pttype: partiton name +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/probe.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/probe.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/probe.c.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/probe.c 2011-01-12 14:54:53.000000000 +0100 +@@ -288,21 +288,33 @@ struct blkid_chain *blkid_probe_get_chai + + void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn) + { +- int rc; ++ int rc, org_prob_flags; ++ struct blkid_chain *org_chn; + + if (!pr || !chn) + return NULL; + ++ /* save the current setting -- the binary API has to be completely ++ * independent on the current probing status ++ */ ++ org_chn = pr->cur_chain; ++ org_prob_flags = pr->prob_flags; ++ + pr->cur_chain = chn; ++ pr->prob_flags = 0; + chn->binary = TRUE; + blkid_probe_chain_reset_position(chn); + + rc = chn->driver->probe(pr, chn); + + chn->binary = FALSE; +- pr->cur_chain = NULL; + blkid_probe_chain_reset_position(chn); + ++ /* restore the original setting ++ */ ++ pr->cur_chain = org_chn; ++ pr->prob_flags = org_prob_flags; ++ + if (rc != 0) + return NULL; + +@@ -629,6 +641,13 @@ int blkid_probe_set_device(blkid_probe p + if (S_ISBLK(pr->mode) && ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) + pr->flags |= BLKID_CDROM_DEV; + #endif ++ ++ DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%jd, size=%jd\n", ++ pr->off, pr->size)); ++ DBG(DEBUG_LOWPROBE, printf("whole-disk: %s, regfile: %s\n", ++ blkid_probe_is_wholedisk(pr) ?"YES" : "NO", ++ S_ISREG(pr->mode) ? "YES" : "NO")); ++ + return 0; + err: + DBG(DEBUG_LOWPROBE, +@@ -674,6 +693,22 @@ int blkid_probe_set_dimension(blkid_prob + return 0; + } + ++static inline void blkid_probe_start(blkid_probe pr) ++{ ++ if (pr) { ++ pr->cur_chain = NULL; ++ pr->prob_flags = 0; ++ } ++} ++ ++static inline void blkid_probe_end(blkid_probe pr) ++{ ++ if (pr) { ++ pr->cur_chain = NULL; ++ pr->prob_flags = 0; ++ } ++} ++ + /** + * blkid_do_probe: + * @pr: prober +@@ -725,9 +760,10 @@ int blkid_do_probe(blkid_probe pr) + do { + struct blkid_chain *chn = pr->cur_chain; + +- if (!chn) ++ if (!chn) { ++ blkid_probe_start(pr); + chn = pr->cur_chain = &pr->chains[0]; +- ++ } + /* we go to the next chain only when the previous probing + * result was nothing (rc == 1) and when the current chain is + * disabled or we are at end of the current chain (chain->idx + +@@ -742,8 +778,10 @@ int blkid_do_probe(blkid_probe pr) + + if (idx < BLKID_NCHAINS) + chn = pr->cur_chain = &pr->chains[idx]; +- else ++ else { ++ blkid_probe_end(pr); + return 1; /* all chains already probed */ ++ } + } + + chn->binary = FALSE; /* for sure... */ +@@ -775,7 +813,9 @@ int blkid_do_probe(blkid_probe pr) + * + * Note about suberblocks chain -- the function does not check for filesystems + * when a RAID signature is detected. The function also does not check for +- * collision between RAIDs. The first detected RAID is returned. ++ * collision between RAIDs. The first detected RAID is returned. The function ++ * checks for collision between partition table and RAID signature -- it's ++ * recommended to enable partitions chain together with superblocks chain. + * + * Returns: 0 on success, 1 if nothing is detected, -2 if ambivalen result is + * detected and -1 on case of error. +@@ -787,6 +827,8 @@ int blkid_do_safeprobe(blkid_probe pr) + if (!pr) + return -1; + ++ blkid_probe_start(pr); ++ + for (i = 0; i < BLKID_NCHAINS; i++) { + struct blkid_chain *chn; + +@@ -814,7 +856,7 @@ int blkid_do_safeprobe(blkid_probe pr) + } + + done: +- pr->cur_chain = NULL; ++ blkid_probe_end(pr); + if (rc < 0) + return rc; + return count ? 0 : 1; +@@ -839,6 +881,8 @@ int blkid_do_fullprobe(blkid_probe pr) + if (!pr) + return -1; + ++ blkid_probe_start(pr); ++ + for (i = 0; i < BLKID_NCHAINS; i++) { + int rc; + struct blkid_chain *chn; +@@ -867,7 +911,7 @@ int blkid_do_fullprobe(blkid_probe pr) + } + + done: +- pr->cur_chain = NULL; ++ blkid_probe_end(pr); + if (rc < 0) + return rc; + return count ? 0 : 1; +@@ -988,6 +1032,48 @@ dev_t blkid_probe_get_devno(blkid_probe + } + + /** ++ * blkid_probe_get_wholedisk_devno: ++ * @pr: probe ++ * ++ * Returns: device number of the wholedisk, or 0 for regilar files. ++ */ ++dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr) ++{ ++ if (!pr->disk_devno) { ++ dev_t devno, disk_devno = 0; ++ ++ devno = blkid_probe_get_devno(pr); ++ if (!devno) ++ return 0; ++ ++ if (blkid_devno_to_wholedisk(devno, NULL, 0, &disk_devno) == 0) ++ pr->disk_devno = disk_devno; ++ } ++ return pr->disk_devno; ++} ++ ++/** ++ * blkid_probe_is_wholedisk: ++ * @pr: probe ++ * ++ * Returns: 1 if the device is whole-disk or 0. ++ */ ++int blkid_probe_is_wholedisk(blkid_probe pr) ++{ ++ dev_t devno, disk_devno; ++ ++ devno = blkid_probe_get_devno(pr); ++ if (!devno) ++ return 0; ++ ++ disk_devno = blkid_probe_get_wholedisk_devno(pr); ++ if (!disk_devno) ++ return 0; ++ ++ return devno == disk_devno; ++} ++ ++/** + * blkid_probe_get_size: + * @pr: probe + * +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/adaptec_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/adaptec_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/adaptec_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/adaptec_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -81,6 +81,9 @@ static int probe_adraid(blkid_probe pr, + if (pr->size < 0x10000) + return -1; + ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; ++ + off = ((pr->size / 0x200)-1) * 0x200; + ad = (struct adaptec_metadata *) + blkid_probe_get_buffer(pr, +@@ -94,7 +97,9 @@ static int probe_adraid(blkid_probe pr, + return -1; + if (blkid_probe_sprintf_version(pr, "%u", ad->resver) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(ad->b0idcode), ++ (unsigned char *) &ad->b0idcode)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ddf_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ddf_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ddf_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ddf_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -18,12 +18,57 @@ + /* http://www.snia.org/standards/home */ + #define DDF_GUID_LENGTH 24 + #define DDF_REV_LENGTH 8 ++#define DDF_MAGIC 0xDE11DE11 ++ + + struct ddf_header { +- uint8_t signature[4]; ++ uint32_t signature; + uint32_t crc; + uint8_t guid[DDF_GUID_LENGTH]; +- uint8_t ddf_rev[DDF_REV_LENGTH]; ++ char ddf_rev[8]; /* 01.02.00 */ ++ uint32_t seq; /* starts at '1' */ ++ uint32_t timestamp; ++ uint8_t openflag; ++ uint8_t foreignflag; ++ uint8_t enforcegroups; ++ uint8_t pad0; /* 0xff */ ++ uint8_t pad1[12]; /* 12 * 0xff */ ++ /* 64 bytes so far */ ++ uint8_t header_ext[32]; /* reserved: fill with 0xff */ ++ uint64_t primary_lba; ++ uint64_t secondary_lba; ++ uint8_t type; ++ uint8_t pad2[3]; /* 0xff */ ++ uint32_t workspace_len; /* sectors for vendor space - ++ * at least 32768(sectors) */ ++ uint64_t workspace_lba; ++ uint16_t max_pd_entries; /* one of 15, 63, 255, 1023, 4095 */ ++ uint16_t max_vd_entries; /* 2^(4,6,8,10,12)-1 : i.e. as above */ ++ uint16_t max_partitions; /* i.e. max num of configuration ++ record entries per disk */ ++ uint16_t config_record_len; /* 1 +ROUNDUP(max_primary_element_entries ++ *12/512) */ ++ uint16_t max_primary_element_entries; /* 16, 64, 256, 1024, or 4096 */ ++ uint8_t pad3[54]; /* 0xff */ ++ /* 192 bytes so far */ ++ uint32_t controller_section_offset; ++ uint32_t controller_section_length; ++ uint32_t phys_section_offset; ++ uint32_t phys_section_length; ++ uint32_t virt_section_offset; ++ uint32_t virt_section_length; ++ uint32_t config_section_offset; ++ uint32_t config_section_length; ++ uint32_t data_section_offset; ++ uint32_t data_section_length; ++ uint32_t bbm_section_offset; ++ uint32_t bbm_section_length; ++ uint32_t diag_space_offset; ++ uint32_t diag_space_length; ++ uint32_t vendor_offset; ++ uint32_t vendor_length; ++ /* 256 bytes so far */ ++ uint8_t pad4[256]; /* 0xff */ + } __attribute__((packed)); + + static int probe_ddf(blkid_probe pr, const struct blkid_idmag *mag) +@@ -32,12 +77,13 @@ static int probe_ddf(blkid_probe pr, con + int i; + struct ddf_header *ddf = NULL; + char version[DDF_REV_LENGTH + 1]; ++ uint64_t off, lba; + + if (pr->size < 0x30000) + return -1; + + for (i = 0; i < ARRAY_SIZE(hdrs); i++) { +- uint64_t off = ((pr->size / 0x200) - hdrs[i]) * 0x200; ++ off = ((pr->size / 0x200) - hdrs[i]) * 0x200; + + ddf = (struct ddf_header *) blkid_probe_get_buffer(pr, + off, +@@ -45,8 +91,8 @@ static int probe_ddf(blkid_probe pr, con + if (!ddf) + return -1; + +- if (memcmp(ddf->signature, "\x11\xde\x11\xde", 4) == 0 || +- memcmp(ddf->signature, "\xde\x11\xde\x11", 4) == 0) ++ if (ddf->signature == cpu_to_be32(DDF_MAGIC) || ++ ddf->signature == cpu_to_le32(DDF_MAGIC)) + break; + ddf = NULL; + } +@@ -54,6 +100,20 @@ static int probe_ddf(blkid_probe pr, con + if (!ddf) + return -1; + ++ lba = ddf->signature == cpu_to_be32(DDF_MAGIC) ? ++ be64_to_cpu(ddf->primary_lba) : ++ le64_to_cpu(ddf->primary_lba); ++ ++ if (lba > 0) { ++ /* check primary header */ ++ unsigned char *buf; ++ ++ buf = blkid_probe_get_buffer(pr, ++ lba << 9, sizeof(ddf->signature)); ++ if (!buf || memcmp(buf, &ddf->signature, 4)) ++ return -1; ++ } ++ + blkid_probe_strncpy_uuid(pr, ddf->guid, sizeof(ddf->guid)); + + memcpy(version, ddf->ddf_rev, sizeof(ddf->ddf_rev)); +@@ -61,6 +121,10 @@ static int probe_ddf(blkid_probe pr, con + + if (blkid_probe_set_version(pr, version) != 0) + return -1; ++ if (blkid_probe_set_magic(pr, off, ++ sizeof(ddf->signature), ++ (unsigned char *) &ddf->signature)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/drbd.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/drbd.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/drbd.c.kzak 2010-03-22 09:13:48.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/drbd.c 2011-01-12 14:54:53.000000000 +0100 +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + #include "superblocks.h" + +@@ -75,9 +76,9 @@ static int probe_drbd(blkid_probe pr, co + return -1; + + md = (struct md_on_disk_08 *) +- blkid_probe_get_buffer(pr, +- off, +- sizeof(struct md_on_disk_08)); ++ blkid_probe_get_buffer(pr, ++ off, ++ sizeof(struct md_on_disk_08)); + if (!md) + return -1; + +@@ -94,6 +95,12 @@ static int probe_drbd(blkid_probe pr, co + + blkid_probe_set_version(pr, "v08"); + ++ if (blkid_probe_set_magic(pr, ++ off + offsetof(struct md_on_disk_08, magic), ++ sizeof(md->magic), ++ (unsigned char *) &md->magic)) ++ return -1; ++ + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/highpoint_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/highpoint_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/highpoint_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/highpoint_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -30,6 +30,8 @@ static int probe_highpoint45x(blkid_prob + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 11) * 0x200; + hpt = (struct hpt45x_metadata *) +@@ -41,9 +43,20 @@ static int probe_highpoint45x(blkid_prob + magic = le32_to_cpu(hpt->magic); + if (magic != HPT45X_MAGIC_OK && magic != HPT45X_MAGIC_BAD) + return -1; ++ if (blkid_probe_set_magic(pr, off, sizeof(hpt->magic), ++ (unsigned char *) &hpt->magic)) ++ return -1; + return 0; + } + ++static int probe_highpoint37x(blkid_probe pr, const struct blkid_idmag *mag) ++{ ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; ++ return 0; ++} ++ ++ + const struct blkid_idinfo highpoint45x_idinfo = { + .name = "hpt45x_raid_member", + .usage = BLKID_USAGE_RAID, +@@ -54,6 +67,7 @@ const struct blkid_idinfo highpoint45x_i + const struct blkid_idinfo highpoint37x_idinfo = { + .name = "hpt37x_raid_member", + .usage = BLKID_USAGE_RAID, ++ .probefunc = probe_highpoint37x, + .magics = { + /* + * Superblok offset: 4608 bytes (9 sectors) +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/isw_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/isw_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/isw_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/isw_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -33,6 +33,8 @@ static int probe_iswraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 2) * 0x200; + isw = (struct isw_metadata *) +@@ -46,7 +48,9 @@ static int probe_iswraid(blkid_probe pr, + if (blkid_probe_sprintf_version(pr, "%6s", + &isw->sig[sizeof(ISW_SIGNATURE)-1]) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(isw->sig), ++ (unsigned char *) isw->sig)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/jmicron_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/jmicron_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/jmicron_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/jmicron_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -32,6 +32,8 @@ static int probe_jmraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 1) * 0x200; + jm = (struct jm_metadata *) +@@ -45,7 +47,9 @@ static int probe_jmraid(blkid_probe pr, + if (blkid_probe_sprintf_version(pr, "%u.%u", + jm->major_version, jm->minor_version) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(jm->signature), ++ (unsigned char *) jm->signature)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/linux_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/linux_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/linux_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/linux_raid.c 2011-01-12 15:05:11.000000000 +0100 +@@ -34,27 +34,82 @@ struct mdp0_super_block { + uint32_t set_uuid3; + }; + ++/* ++ * Version-1, little-endian. ++ */ + struct mdp1_super_block { +- uint32_t magic; +- uint32_t major_version; +- uint32_t feature_map; +- uint32_t pad0; +- uint8_t set_uuid[16]; +- uint8_t set_name[32]; ++ /* constant array information - 128 bytes */ ++ uint32_t magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ ++ uint32_t major_version; /* 1 */ ++ uint32_t feature_map; /* 0 for now */ ++ uint32_t pad0; /* always set to 0 when writing */ ++ ++ uint8_t set_uuid[16]; /* user-space generated. */ ++ unsigned char set_name[32]; /* set and interpreted by user-space */ ++ ++ uint64_t ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ ++ uint32_t level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ ++ uint32_t layout; /* only for raid5 currently */ ++ uint64_t size; /* used size of component devices, in 512byte sectors */ ++ ++ uint32_t chunksize; /* in 512byte sectors */ ++ uint32_t raid_disks; ++ uint32_t bitmap_offset; /* sectors after start of superblock that bitmap starts ++ * NOTE: signed, so bitmap can be before superblock ++ * only meaningful of feature_map[0] is set. ++ */ ++ ++ /* These are only valid with feature bit '4' */ ++ uint32_t new_level; /* new level we are reshaping to */ ++ uint64_t reshape_position; /* next address in array-space for reshape */ ++ uint32_t delta_disks; /* change in number of raid_disks */ ++ uint32_t new_layout; /* new layout */ ++ uint32_t new_chunk; /* new chunk size (bytes) */ ++ uint8_t pad1[128-124]; /* set to 0 when written */ ++ ++ /* constant this-device information - 64 bytes */ ++ uint64_t data_offset; /* sector start of data, often 0 */ ++ uint64_t data_size; /* sectors in this device that can be used for data */ ++ uint64_t super_offset; /* sector start of this superblock */ ++ uint64_t recovery_offset;/* sectors before this offset (from data_offset) have been recovered */ ++ uint32_t dev_number; /* permanent identifier of this device - not role in raid */ ++ uint32_t cnt_corrected_read; /* number of read errors that were corrected by re-writing */ ++ uint8_t device_uuid[16]; /* user-space setable, ignored by kernel */ ++ uint8_t devflags; /* per-device flags. Only one defined...*/ ++ uint8_t pad2[64-57]; /* set to 0 when writing */ ++ ++ /* array state information - 64 bytes */ ++ uint64_t utime; /* 40 bits second, 24 btes microseconds */ ++ uint64_t events; /* incremented when superblock updated */ ++ uint64_t resync_offset; /* data before this offset (from data_offset) known to be in sync */ ++ uint32_t sb_csum; /* checksum upto dev_roles[max_dev] */ ++ uint32_t max_dev; /* size of dev_roles[] array to consider */ ++ uint8_t pad3[64-32]; /* set to 0 when writing */ ++ ++ /* device state information. Indexed by dev_number. ++ * 2 bytes per device ++ * Note there are no per-device state flags. State information is rolled ++ * into the 'roles' value. If a device is spare or faulty, then it doesn't ++ * have a meaningful role. ++ */ ++ uint16_t dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ + }; + ++ + #define MD_RESERVED_BYTES 0x10000 + #define MD_SB_MAGIC 0xa92b4efc + +-static int probe_raid0(blkid_probe pr, off_t off) ++static int probe_raid0(blkid_probe pr, blkid_loff_t off) + { + struct mdp0_super_block *mdp0; + union { + uint32_t ints[4]; + uint8_t bytes[16]; + } uuid; ++ uint32_t ma, mi, pa; ++ uint64_t size; + +- if (pr->size < 0x10000) ++ if (pr->size < MD_RESERVED_BYTES) + return -1; + mdp0 = (struct mdp0_super_block *) + blkid_probe_get_buffer(pr, +@@ -72,11 +127,10 @@ static int probe_raid0(blkid_probe pr, o + uuid.ints[2] = swab32(mdp0->set_uuid2); + uuid.ints[3] = swab32(mdp0->set_uuid3); + } +- if (blkid_probe_sprintf_version(pr, "%u.%u.%u", +- le32_to_cpu(mdp0->major_version), +- le32_to_cpu(mdp0->minor_version), +- le32_to_cpu(mdp0->patch_version)) != 0) +- return -1; ++ ma = le32_to_cpu(mdp0->major_version); ++ mi = le32_to_cpu(mdp0->minor_version); ++ pa = le32_to_cpu(mdp0->patch_version); ++ size = le32_to_cpu(mdp0->size); + + } else if (be32_to_cpu(mdp0->md_magic) == MD_SB_MAGIC) { + uuid.ints[0] = mdp0->set_uuid0; +@@ -85,17 +139,46 @@ static int probe_raid0(blkid_probe pr, o + uuid.ints[2] = mdp0->set_uuid2; + uuid.ints[3] = mdp0->set_uuid3; + } +- if (blkid_probe_sprintf_version(pr, "%u.%u.%u", +- be32_to_cpu(mdp0->major_version), +- be32_to_cpu(mdp0->minor_version), +- be32_to_cpu(mdp0->patch_version)) != 0) +- return -1; ++ ma = be32_to_cpu(mdp0->major_version); ++ mi = be32_to_cpu(mdp0->minor_version); ++ pa = be32_to_cpu(mdp0->patch_version); ++ size = be32_to_cpu(mdp0->size); + } else +- return -1; ++ return 1; ++ ++ size <<= 10; /* convert KiB to bytes */ + ++ if (pr->size < size + MD_RESERVED_BYTES) ++ /* device is too small */ ++ return 1; ++ ++ if (off < size) ++ /* no space before superblock */ ++ return 1; ++ ++ /* ++ * Check for collisions between RAID and partition table ++ * ++ * For example the superblock is at the end of the last partition, it's ++ * the same possition as at the end of the disk... ++ */ ++ if ((S_ISREG(pr->mode) || blkid_probe_is_wholedisk(pr)) && ++ blkid_probe_is_covered_by_pt(pr, ++ off - size, /* min. start */ ++ size + MD_RESERVED_BYTES)) { /* min. length */ ++ ++ /* ignore this superblock, it's within any partition and ++ * we are working with whole-disk now */ ++ return 1; ++ } ++ ++ if (blkid_probe_sprintf_version(pr, "%u.%u.%u", ma, mi, pa) != 0) ++ return -1; + if (blkid_probe_set_uuid(pr, (unsigned char *) uuid.bytes) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(mdp0->md_magic), ++ (unsigned char *) &mdp0->md_magic)) ++ return -1; + return 0; + } + +@@ -113,12 +196,19 @@ static int probe_raid1(blkid_probe pr, o + return -1; + if (le32_to_cpu(mdp1->major_version) != 1) + return -1; ++ if (le64_to_cpu(mdp1->super_offset) != off >> 9) ++ return -1; + if (blkid_probe_set_uuid(pr, (unsigned char *) mdp1->set_uuid) != 0) + return -1; ++ if (blkid_probe_set_uuid_as(pr, ++ (unsigned char *) mdp1->device_uuid, "UUID_SUB") != 0) ++ return -1; + if (blkid_probe_set_label(pr, mdp1->set_name, + sizeof(mdp1->set_name)) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(mdp1->magic), ++ (unsigned char *) &mdp1->magic)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/lsi_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/lsi_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/lsi_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/lsi_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -30,6 +30,8 @@ static int probe_lsiraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 1) * 0x200; + lsi = (struct lsi_metadata *) +@@ -41,7 +43,9 @@ static int probe_lsiraid(blkid_probe pr, + + if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(lsi->sig), ++ (unsigned char *) lsi->sig)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/nvidia_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/nvidia_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/nvidia_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/nvidia_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -32,6 +32,8 @@ static int probe_nvraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 2) * 0x200; + nv = (struct nv_metadata *) +@@ -43,10 +45,11 @@ static int probe_nvraid(blkid_probe pr, + + if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0) + return -1; +- + if (blkid_probe_sprintf_version(pr, "%u", le16_to_cpu(nv->version)) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, off, sizeof(nv->vendor), ++ (unsigned char *) nv->vendor)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/promise_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/promise_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/promise_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/promise_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -33,6 +33,8 @@ static int probe_pdcraid(blkid_probe pr, + + if (pr->size < 0x40000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + for (i = 0; sectors[i] != 0; i++) { + uint64_t off; +@@ -47,8 +49,13 @@ static int probe_pdcraid(blkid_probe pr, + return -1; + + if (memcmp(pdc->sig, PDC_SIGNATURE, +- sizeof(PDC_SIGNATURE) - 1) == 0) ++ sizeof(PDC_SIGNATURE) - 1) == 0) { ++ ++ if (blkid_probe_set_magic(pr, off, sizeof(pdc->sig), ++ (unsigned char *) pdc->sig)) ++ return -1; + return 0; ++ } + } + return -1; + } +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/silicon_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/silicon_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/silicon_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/silicon_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + + #include "superblocks.h" + +@@ -47,6 +48,8 @@ static int probe_silraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200) - 1) * 0x200; + +@@ -63,7 +66,11 @@ static int probe_silraid(blkid_probe pr, + le16_to_cpu(sil->major_ver), + le16_to_cpu(sil->minor_ver)) != 0) + return -1; +- ++ if (blkid_probe_set_magic(pr, ++ off + offsetof(struct silicon_metadata, magic), ++ sizeof(sil->magic), ++ (unsigned char *) &sil->magic)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.c.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.c 2011-01-12 14:54:53.000000000 +0100 +@@ -375,8 +375,10 @@ static int superblocks_probe(blkid_probe + /* final check by probing function */ + if (id->probefunc) { + DBG(DEBUG_LOWPROBE, printf("\tcall probefunc()\n")); +- if (id->probefunc(pr, mag) != 0) ++ if (id->probefunc(pr, mag) != 0) { ++ blkid_probe_chain_reset_vals(pr, chn); + continue; ++ } + } + + /* all cheks passed */ +@@ -385,15 +387,11 @@ static int superblocks_probe(blkid_probe + (unsigned char *) id->name, + strlen(id->name) + 1); + +- if (chn->flags & BLKID_SUBLKS_USAGE) +- blkid_probe_set_usage(pr, id->usage); ++ blkid_probe_set_usage(pr, id->usage); + +- if (hasmag && (chn->flags & BLKID_SUBLKS_MAGIC)) { +- blkid_probe_set_value(pr, "SBMAGIC", +- (unsigned char *) mag->magic, mag->len); +- blkid_probe_sprintf_value(pr, "SBMAGIC_OFFSET", +- "%llu", off); +- } ++ if (hasmag) ++ blkid_probe_set_magic(pr, off, mag->len, ++ (unsigned char *) mag->magic); + + DBG(DEBUG_LOWPROBE, + printf("<-- leaving probing loop (type=%s) [SUBLKS idx=%d]\n", +@@ -435,20 +433,24 @@ static int superblocks_safeprobe(blkid_p + /* floppy or so -- returns the first result. */ + return 0; + +- if (!count) { +- /* save the first result */ +- nvals = blkid_probe_chain_copy_vals(pr, chn, vals, nvals); +- idx = chn->idx; +- } + count++; + + if (idinfos[chn->idx]->usage & (BLKID_USAGE_RAID | BLKID_USAGE_CRYPTO)) + break; ++ + if (!(idinfos[chn->idx]->flags & BLKID_IDINFO_TOLERANT)) + intol++; ++ ++ if (count == 1) { ++ /* save the first result */ ++ nvals = blkid_probe_chain_copy_vals(pr, chn, vals, nvals); ++ idx = chn->idx; ++ } + } ++ + if (rc < 0) + return rc; /* error */ ++ + if (count > 1 && intol) { + DBG(DEBUG_LOWPROBE, + printf("ERROR: superblocks chain: " +@@ -459,14 +461,40 @@ static int superblocks_safeprobe(blkid_p + if (!count) + return 1; /* nothing detected */ + +- /* restore the first result */ +- blkid_probe_chain_reset_vals(pr, chn); +- blkid_probe_append_vals(pr, vals, nvals); +- chn->idx = idx; ++ if (idx != -1) { ++ /* restore the first result */ ++ blkid_probe_chain_reset_vals(pr, chn); ++ blkid_probe_append_vals(pr, vals, nvals); ++ chn->idx = idx; ++ } ++ ++ /* ++ * The RAID device could be partitioned. The problem are RAID1 devices ++ * where the partition table is visible from underlaying devices. We ++ * have to ignore such partition tables. ++ */ ++ if (chn->idx >= 0 && idinfos[chn->idx]->usage & BLKID_USAGE_RAID) ++ pr->prob_flags |= BLKID_PARTS_IGNORE_PT; + + return 0; + } + ++int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset, ++ size_t len, unsigned char *magic) ++{ ++ int rc = 0; ++ struct blkid_chain *chn = blkid_probe_get_chain(pr); ++ ++ if (chn->flags & BLKID_SUBLKS_MAGIC) { ++ if (magic && len) ++ rc = blkid_probe_set_value(pr, "SBMAGIC", magic, len); ++ if (!rc && offset) ++ rc = blkid_probe_sprintf_value(pr, "SBMAGIC_OFFSET", ++ "%llu", offset); ++ } ++ return rc; ++} ++ + int blkid_probe_set_version(blkid_probe pr, const char *version) + { + struct blkid_chain *chn = blkid_probe_get_chain(pr); +@@ -494,8 +522,12 @@ int blkid_probe_sprintf_version(blkid_pr + + static int blkid_probe_set_usage(blkid_probe pr, int usage) + { ++ struct blkid_chain *chn = blkid_probe_get_chain(pr); + char *u = NULL; + ++ if (!(chn->flags & BLKID_SUBLKS_USAGE)) ++ return 0; ++ + if (usage & BLKID_USAGE_FILESYSTEM) + u = "filesystem"; + else if (usage & BLKID_USAGE_RAID) +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.h.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.h +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.h.kzak 2010-03-22 09:05:43.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/superblocks.h 2011-01-12 14:54:53.000000000 +0100 +@@ -68,6 +68,8 @@ extern const struct blkid_idinfo drbd_id + /* + * superblock functions + */ ++extern int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset, ++ size_t len, unsigned char *magic); + extern int blkid_probe_set_version(blkid_probe pr, const char *version); + extern int blkid_probe_sprintf_version(blkid_probe pr, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/sysv.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/sysv.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/sysv.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/sysv.c 2011-01-12 14:54:53.000000000 +0100 +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + + #include "superblocks.h" + +@@ -107,7 +108,18 @@ static int probe_sysv(blkid_probe pr, co + + if (sb->s_magic == cpu_to_le32(0xfd187e20) || + sb->s_magic == cpu_to_be32(0xfd187e20)) { +- blkid_probe_set_label(pr, sb->s_fname, sizeof(sb->s_fname)); ++ ++ if (blkid_probe_set_label(pr, sb->s_fname, ++ sizeof(sb->s_fname))) ++ return -1; ++ ++ if (blkid_probe_set_magic(pr, ++ off + offsetof(struct sysv_super_block, ++ s_magic), ++ sizeof(sb->s_magic), ++ (unsigned char *) &sb->s_magic)) ++ return -1; ++ + return 0; + } + } +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ufs.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ufs.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ufs.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/ufs.c 2011-01-12 14:54:53.000000000 +0100 +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + + #include "superblocks.h" + +@@ -205,6 +206,13 @@ found: + } else + blkid_probe_set_version(pr, "1"); + ++ if (blkid_probe_set_magic(pr, ++ (offsets[i] * 1024) + ++ offsetof(struct ufs_super_block, fs_magic), ++ sizeof(ufs->fs_magic), ++ (unsigned char *) &ufs->fs_magic)) ++ return -1; ++ + return 0; + } + +diff -up util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/via_raid.c.kzak util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/via_raid.c +--- util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/via_raid.c.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/shlibs/blkid/src/superblocks/via_raid.c 2011-01-12 14:54:53.000000000 +0100 +@@ -52,6 +52,8 @@ static int probe_viaraid(blkid_probe pr, + + if (pr->size < 0x10000) + return -1; ++ if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) ++ return -1; + + off = ((pr->size / 0x200)-1) * 0x200; + +@@ -69,6 +71,10 @@ static int probe_viaraid(blkid_probe pr, + return -1; + if (blkid_probe_sprintf_version(pr, "%u", v->version_number) != 0) + return -1; ++ if (blkid_probe_set_magic(pr, off, ++ sizeof(v->signature), ++ (unsigned char *) &v->signature)) ++ return -1; + return 0; + } + +diff -up util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-part.kzak util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-part +--- util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-part.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-part 2011-01-12 14:54:53.000000000 +0100 +@@ -0,0 +1,58 @@ ++Create partitions ++Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel ++ ++Changes will remain in memory only, until you decide to write them. ++After that, of course, the previous content won't be recoverable. ++ ++Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) ++ ++WARNING: DOS-compatible mode is deprecated. It's strongly recommended to ++ switch off the mode (command 'c') and change display units to ++ sectors (command 'u'). ++ ++Command (m for help): DOS Compatibility flag is not set ++ ++Command (m for help): Changing display/entry units to sectors ++ ++Command (m for help): Command action ++ e extended ++ p primary partition (1-4) ++Partition number (1-4): First sector (2048-104447, default 2048): Using default value 2048 ++Last sector, +sectors or +size{K,M,G} (2048-104447, default 104447): ++Command (m for help): Command action ++ e extended ++ p primary partition (1-4) ++Partition number (1-4): First sector (53248-104447, default 53248): Using default value 53248 ++Last sector, +sectors or +size{K,M,G} (53248-104447, default 104447): Using default value 104447 ++ ++Command (m for help): ++Disk /dev/sdb: 53 MB, 53477376 bytes ++32 heads, 32 sectors/track, 102 cylinders, total 104448 sectors ++Units = sectors of 1 * 512 = 512 bytes ++Sector size (logical/physical): 512 bytes / 512 bytes ++I/O size (minimum/optimal): 512 bytes / 32768 bytes ++ ++ ++ Device Boot Start End Blocks Id System ++/dev/sdb1 2048 53247 25600 83 Linux ++/dev/sdb2 53248 104447 25600 83 Linux ++ ++Command (m for help): The partition table has been altered! ++ ++Calling ioctl() to re-read partition table. ++Syncing disks. ++Create RAID1 device ++Probe whole-disk ++ID_PART_TABLE_TYPE=dos ++Probe first RAID member ++ID_FS_TYPE=linux_raid_member ++ID_FS_USAGE=raid ++ ++ ++ID_FS_VERSION=0.90.0 ++Probe second RAID member ++ID_FS_TYPE=linux_raid_member ++ID_FS_USAGE=raid ++ ++ ++ID_FS_VERSION=0.90.0 +diff -up util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-whole.kzak util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-whole +--- util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-whole.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/tests/expected/blkid/md-raid1-whole 2011-01-12 14:54:53.000000000 +0100 +@@ -0,0 +1,58 @@ ++Initialize devices ++Create RAID device ++Create partitions on RAID device ++Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel ++ ++Changes will remain in memory only, until you decide to write them. ++After that, of course, the previous content won't be recoverable. ++ ++Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) ++ ++WARNING: DOS-compatible mode is deprecated. It's strongly recommended to ++ switch off the mode (command 'c') and change display units to ++ sectors (command 'u'). ++ ++Command (m for help): DOS Compatibility flag is not set ++ ++Command (m for help): Changing display/entry units to sectors ++ ++Command (m for help): Command action ++ e extended ++ p primary partition (1-4) ++Partition number (1-4): First sector (2048-102271, default 2048): Using default value 2048 ++Last sector, +sectors or +size{K,M,G} (2048-102271, default 102271): ++Command (m for help): Command action ++ e extended ++ p primary partition (1-4) ++Partition number (1-4): First sector (22528-102271, default 22528): Using default value 22528 ++Last sector, +sectors or +size{K,M,G} (22528-102271, default 102271): ++Command (m for help): ++Disk /dev/md8: 52 MB, 52363264 bytes ++2 heads, 4 sectors/track, 12784 cylinders, total 102272 sectors ++Units = sectors of 1 * 512 = 512 bytes ++Sector size (logical/physical): 512 bytes / 512 bytes ++I/O size (minimum/optimal): 512 bytes / 512 bytes ++ ++ ++ Device Boot Start End Blocks Id System ++/dev/md8p1 2048 22527 10240 83 Linux ++/dev/md8p2 22528 43007 10240 83 Linux ++ ++Command (m for help): The partition table has been altered! ++ ++Calling ioctl() to re-read partition table. ++Syncing disks. ++Probe first RAID member ++ID_FS_TYPE=linux_raid_member ++ID_FS_USAGE=raid ++ ++ ++ID_FS_VERSION=0.90.0 ++Probe second RAID member ++ID_FS_TYPE=linux_raid_member ++ID_FS_USAGE=raid ++ ++ ++ID_FS_VERSION=0.90.0 ++Stop RAID device ++Deinitialize devices +diff -up util-linux-ng-2.17.2/tests/functions.sh.kzak util-linux-ng-2.17.2/tests/functions.sh +--- util-linux-ng-2.17.2/tests/functions.sh.kzak 2010-03-18 23:11:23.000000000 +0100 ++++ util-linux-ng-2.17.2/tests/functions.sh 2011-01-12 14:54:53.000000000 +0100 +@@ -256,7 +256,7 @@ function ts_image_init { + + function ts_device_init { + local img=$(ts_image_init $1 $2) +- local dev=$($TS_CMD_LOSETUP -s -f "$img") ++ local dev=$($TS_CMD_LOSETUP --show -f "$img") + + if [ -z "$dev" ]; then + ts_device_deinit $dev +diff -up util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-part.kzak util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-part +--- util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-part.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-part 2011-01-12 14:54:53.000000000 +0100 +@@ -0,0 +1,92 @@ ++#!/bin/bash ++ ++# ++# Copyright (C) 2010 Karel Zak ++# ++# This file is part of util-linux-ng. ++# ++# This file is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This file is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++ ++TS_TOPDIR="$(dirname $0)/../.." ++TS_DESC="MD raid1 (last partition)" ++ ++. $TS_TOPDIR/functions.sh ++ts_init "$*" ++ts_skip_nonroot ++ ++modprobe --dry-run --quiet scsi_debug ++[ "$?" == 0 ] || ts_skip "missing scsi_debug module" ++[ -x /sbin/mdadm ] || ts_skip "missing mdadm" ++ ++rmmod scsi_debug &> /dev/null ++modprobe scsi_debug dev_size_mb=51 sector_size=512 ++[ "$?" == 0 ] || ts_die "Cannot init device" ++ ++sleep 3 ++ ++DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}') ++[ "x${DEVNAME}" == "x" ] && ts_die "Cannot found device" ++ ++DEVICE="/dev/${DEVNAME}" ++ ++ts_log "Create partitions" ++$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 < /dev/null ++/sbin/mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ ++ --raid-devices=2 ${DEVICE}1 ${DEVICE}2 >> $TS_OUTPUT 2>&1 ++ ++sleep 3 ++ ++ts_log "Probe whole-disk" ++$TS_CMD_BLKID -p -o udev ${DEVICE} 2>&1 | sort >> $TS_OUTPUT ++ ++ts_log "Probe first RAID member" ++$TS_CMD_BLKID -p -o udev ${DEVICE}1 2>&1 | sort >> $TS_OUTPUT ++ ++ts_log "Probe second RAID member" ++$TS_CMD_BLKID -p -o udev ${DEVICE}2 2>&1 | sort >> $TS_OUTPUT ++ ++/sbin/mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 ++ ++sleep 3 ++rmmod scsi_debug ++ ++# remove disk ID and generated UUIDs ++sed -i -e 's/Disk identifier:.*//g' $TS_OUTPUT ++sed -i -e 's/Building a new.*//g' $TS_OUTPUT ++sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT ++ ++ts_finalize +diff -up util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-whole.kzak util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-whole +--- util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-whole.kzak 2011-01-12 14:54:53.000000000 +0100 ++++ util-linux-ng-2.17.2/tests/ts/blkid/md-raid1-whole 2011-01-12 14:54:53.000000000 +0100 +@@ -0,0 +1,88 @@ ++#!/bin/bash ++ ++# ++# Copyright (C) 2010 Karel Zak ++# ++# This file is part of util-linux-ng. ++# ++# This file is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This file is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++ ++TS_TOPDIR="$(dirname $0)/../.." ++TS_DESC="MD raid1 (whole-disks)" ++ ++. $TS_TOPDIR/functions.sh ++ts_init "$*" ++ts_skip_nonroot ++[ -x /sbin/mdadm ] || ts_skip "missing mdadm" ++ ++set -o pipefail ++ ++ts_log "Initialize devices" ++IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}" ++ ++DEVICE1=$(ts_device_init 50 ${IMGNAME}1.img) ++[ "$?" == 0 ] || ts_die "Cannot init device1" ++ ++DEVICE2=$(ts_device_init 50 ${IMGNAME}2.img) ++[ "$?" == 0 ] || ts_die "Cannot init device2" $DEVICE1 ++ ++MD_DEVNAME=md8 ++MD_DEVICE=/dev/${MD_DEVNAME} ++ ++/sbin/mdadm -q -S ${MD_DEVICE} &> /dev/null ++ ++ts_log "Create RAID device" ++/sbin/mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ ++ --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>&1 ++ ++ts_log "Create partitions on RAID device" ++$TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>&1 <&1 | sort >> $TS_OUTPUT ++ ++ts_log "Probe second RAID member" ++$TS_CMD_BLKID -p -o udev $DEVICE1 2>&1 | sort >> $TS_OUTPUT ++ ++ts_log "Stop RAID device" ++/sbin/mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 ++ ++sleep 3 ++ ++ts_log "Deinitialize devices" ++ts_device_deinit $DEVICE1 ++ts_device_deinit $DEVICE2 ++ ++# remove disk ID and generated UUIDs ++sed -i -e 's/Disk identifier:.*//g' $TS_OUTPUT ++sed -i -e 's/Building a new.*//g' $TS_OUTPUT ++sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT ++ ++ts_finalize diff --git a/util-linux-ng-2.17-blkid-usec.patch b/util-linux-ng-2.17-blkid-usec.patch new file mode 100644 index 0000000..8070d51 --- /dev/null +++ b/util-linux-ng-2.17-blkid-usec.patch @@ -0,0 +1,221 @@ + +This is backport from upstream, this version of the patch requires glibc and +kernel >= 2.5.48. The stat.st_mtim availability is not checked to avoid changes +to ./configure script. It should be fine for Fedora/RHEL. --kzak 18-Mar-2010 + + +commit message from the original patch: + +commit 6c2f2b9d62b196296e827f8bb7336a39e80695a9 +Author: Karel Zak +Date: Wed Mar 17 14:49:14 2010 +0100 + + libblkid: add microsecond resolution for cache entries + + The libblkid library uses stat.st_mtine to detect changes on the + device. The last update time of of the device in the cache is stored + as TIME= tag in the /etc/blkid.tab file. + + Linux since 2.5.48 supports nanosecond resolution and more precise + time is available in the stat.st_mtim timespec struct. + + This patch add microsecond precision to TIME= tag in the cache file, + old format: + + TIME="" + + the new format: + + TIME="." + + This change is backwardly compatible. + + Now, the blkid_verify() function checks stat.st_mtime and + stat.st_mtim.tv_nsec/1000. + + Test: + + # e2label /dev/sdb1 AAAA + + old version: + + # blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1 + /dev/sdb1: LABEL="AAAA" + /dev/sdb1: LABEL="AAAA" + + new version: + + # blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1 + /dev/sdb1: LABEL="AAAA" + /dev/sdb1: LABEL="BBBB" + + Signed-off-by: Karel Zak + + +diff -up util-linux-ng-2.17.1/shlibs/blkid/src/blkidP.h.kzak util-linux-ng-2.17.1/shlibs/blkid/src/blkidP.h +--- util-linux-ng-2.17.1/shlibs/blkid/src/blkidP.h.kzak 2010-03-18 14:48:12.000000000 +0100 ++++ util-linux-ng-2.17.1/shlibs/blkid/src/blkidP.h 2010-03-18 15:01:36.000000000 +0100 +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -28,6 +29,9 @@ + #include "blkid.h" + #include "list.h" + ++/* enable microsecond resolution for the cache */ ++#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 ++ + /* + * This describes the attributes of a specific device. + * We can traverse all of the tags by bid_tags (linking to the tag bit_names). +@@ -44,6 +48,7 @@ struct blkid_struct_dev + int bid_pri; /* Device priority */ + dev_t bid_devno; /* Device major/minor number */ + time_t bid_time; /* Last update time of device */ ++ suseconds_t bid_utime; /* Last update time (microseconds) */ + unsigned int bid_flags; /* Device status bitflags */ + char *bid_label; /* Shortcut to device LABEL */ + char *bid_uuid; /* Shortcut to binary UUID */ +diff -up util-linux-ng-2.17.1/shlibs/blkid/src/dev.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/dev.c +--- util-linux-ng-2.17.1/shlibs/blkid/src/dev.c.kzak 2010-02-04 12:53:58.000000000 +0100 ++++ util-linux-ng-2.17.1/shlibs/blkid/src/dev.c 2010-03-18 14:58:23.000000000 +0100 +@@ -84,7 +84,7 @@ void blkid_debug_dump_dev(blkid_dev dev) + + printf(" dev: name = %s\n", dev->bid_name); + printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno); +- printf(" dev: TIME=\"%ld\"\n", (long)dev->bid_time); ++ printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime); + printf(" dev: PRI=\"%d\"\n", dev->bid_pri); + printf(" dev: flags = 0x%08X\n", dev->bid_flags); + +diff -up util-linux-ng-2.17.1/shlibs/blkid/src/read.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/read.c +--- util-linux-ng-2.17.1/shlibs/blkid/src/read.c.kzak 2010-02-04 12:53:58.000000000 +0100 ++++ util-linux-ng-2.17.1/shlibs/blkid/src/read.c 2010-03-18 14:58:23.000000000 +0100 +@@ -49,7 +49,8 @@ static void debug_dump_dev(blkid_dev dev + * + * The following tags are required for each entry: + * unique (within this file) ID number of this device +- * (ascii time_t) time this entry was last read from disk ++ * (time_t and suseconds_t) time this entry was last ++ * read from disk + * (detected) type of filesystem/data for this partition + * + * The following tags may be present, depending on the device contents +@@ -318,9 +319,12 @@ static int parse_tag(blkid_cache cache, + dev->bid_devno = STRTOULL(value, 0, 0); + else if (!strcmp(name, "PRI")) + dev->bid_pri = strtol(value, 0, 0); +- else if (!strcmp(name, "TIME")) +- dev->bid_time = STRTOULL(value, 0, 0); +- else ++ else if (!strcmp(name, "TIME")) { ++ char *end = NULL; ++ dev->bid_time = STRTOULL(value, &end, 0); ++ if (end && *end == '.') ++ dev->bid_utime = STRTOULL(end + 1, 0, 0); ++ } else + ret = blkid_set_tag(dev, name, value, strlen(value)); + + DBG(DEBUG_READ, printf(" tag: %s=\"%s\"\n", name, value)); +@@ -455,7 +459,7 @@ static void debug_dump_dev(blkid_dev dev + + printf(" dev: name = %s\n", dev->bid_name); + printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno); +- printf(" dev: TIME=\"%lld\"\n", (long long)dev->bid_time); ++ printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime); + printf(" dev: PRI=\"%d\"\n", dev->bid_pri); + printf(" dev: flags = 0x%08X\n", dev->bid_flags); + +diff -up util-linux-ng-2.17.1/shlibs/blkid/src/save.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/save.c +--- util-linux-ng-2.17.1/shlibs/blkid/src/save.c.kzak 2010-02-22 09:41:12.000000000 +0100 ++++ util-linux-ng-2.17.1/shlibs/blkid/src/save.c 2010-03-18 14:58:23.000000000 +0100 +@@ -37,9 +37,11 @@ static int save_dev(blkid_dev dev, FILE + printf("device %s, type %s\n", dev->bid_name, dev->bid_type ? + dev->bid_type : "(null)")); + +- fprintf(file, +- "bid_devno, (long) dev->bid_time); ++ fprintf(file, "bid_devno, ++ (long) dev->bid_time, ++ (long) dev->bid_utime); ++ + if (dev->bid_pri) + fprintf(file, " PRI=\"%d\"", dev->bid_pri); + list_for_each(p, &dev->bid_tags) { +diff -up util-linux-ng-2.17.1/shlibs/blkid/src/verify.c.kzak util-linux-ng-2.17.1/shlibs/blkid/src/verify.c +--- util-linux-ng-2.17.1/shlibs/blkid/src/verify.c.kzak 2010-02-04 12:53:58.000000000 +0100 ++++ util-linux-ng-2.17.1/shlibs/blkid/src/verify.c 2010-03-18 14:58:23.000000000 +0100 +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + #include + #ifdef HAVE_SYS_STAT_H + #include +@@ -73,19 +74,34 @@ blkid_dev blkid_verify(blkid_cache cache + return NULL; + } + +- if ((now >= dev->bid_time) && +- (st.st_mtime <= dev->bid_time) && +- ((diff < BLKID_PROBE_MIN) || +- (dev->bid_flags & BLKID_BID_FL_VERIFIED && +- diff < BLKID_PROBE_INTERVAL))) ++ if (now >= dev->bid_time && ++#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC ++ (st.st_mtime < dev->bid_time || ++ (st.st_mtime == dev->bid_time && ++ st.st_mtim.tv_nsec / 1000 <= dev->bid_utime)) && ++#else ++ st.st_mtime <= dev->bid_time && ++#endif ++ (diff < BLKID_PROBE_MIN || ++ (dev->bid_flags & BLKID_BID_FL_VERIFIED && ++ diff < BLKID_PROBE_INTERVAL))) + return dev; + ++#ifndef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC + DBG(DEBUG_PROBE, + printf("need to revalidate %s (cache time %lu, stat time %lu,\n\t" + "time since last check %lu)\n", + dev->bid_name, (unsigned long)dev->bid_time, + (unsigned long)st.st_mtime, (unsigned long)diff)); +- ++#else ++ DBG(DEBUG_PROBE, ++ printf("need to revalidate %s (cache time %lu.%lu, stat time %lu.%lu,\n\t" ++ "time since last check %lu)\n", ++ dev->bid_name, ++ (unsigned long)dev->bid_time, (unsigned long)dev->bid_utime, ++ (unsigned long)st.st_mtime, (unsigned long)st.st_mtim.tv_nsec / 1000, ++ (unsigned long)diff)); ++#endif + + if (!cache->probe) { + cache->probe = blkid_new_probe(); +@@ -156,8 +172,16 @@ blkid_dev blkid_verify(blkid_cache cache + + found_type: + if (dev) { ++#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC ++ struct timeval tv; ++ if (!gettimeofday(&tv, NULL)) { ++ dev->bid_time = tv.tv_sec; ++ dev->bid_utime = tv.tv_usec; ++ } else ++#endif ++ dev->bid_time = time(0); ++ + dev->bid_devno = st.st_rdev; +- dev->bid_time = time(0); + dev->bid_flags |= BLKID_BID_FL_VERIFIED; + cache->bic_flags |= BLKID_BIC_FL_CHANGED; + diff --git a/util-linux-ng-2.17-mount-loopdev.patch b/util-linux-ng-2.17-mount-loopdev.patch new file mode 100644 index 0000000..e898b3e --- /dev/null +++ b/util-linux-ng-2.17-mount-loopdev.patch @@ -0,0 +1,83 @@ +diff -up util-linux-ng-2.17.2/mount/mount.c.kzak util-linux-ng-2.17.2/mount/mount.c +--- util-linux-ng-2.17.2/mount/mount.c.kzak 2010-03-22 09:10:56.000000000 +0100 ++++ util-linux-ng-2.17.2/mount/mount.c 2010-07-29 16:15:28.000000000 +0200 +@@ -1090,7 +1090,8 @@ loop_check(const char **spec, const char + if (verbose) + printf(_("mount: skipping the setup of a loop device\n")); + } else { +- int loop_opts = SETLOOP_AUTOCLEAR; /* always attempt autoclear */ ++ /* use autoclear loopdev on system without regular mtab only */ ++ int loop_opts = mtab_is_writable() ? 0 : SETLOOP_AUTOCLEAR; + int res; + + if (*flags & MS_RDONLY) +@@ -1759,6 +1760,50 @@ mounted (const char *spec0, const char * + return ret; + } + ++/* returns 0 if not mounted, 1 if mounted and -1 in case of error */ ++static int ++is_fstab_entry_mounted(struct mntentchn *mc, int verbose) ++{ ++ struct stat st; ++ ++ if (mounted(mc->m.mnt_fsname, mc->m.mnt_dir)) ++ goto yes; ++ ++ /* extra care for loop devices */ ++ if ((strstr(mc->m.mnt_opts, "loop=") || ++ (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) { ++ ++ char *p = strstr(mc->m.mnt_opts, "offset="); ++ uintmax_t offset = 0; ++ ++ if (p && *(p + 7)) { ++ char *end = NULL; ++ ++ p += 7; ++ errno = 0; ++ offset = strtoumax(p, &end, 0); ++ ++ if (end == p || (errno != 0 && ++ (offset == UINTMAX_MAX || offset == 0))) { ++ if (verbose) ++ printf(_("mount: ignore %s " ++ "(unparsable offset= option)\n"), ++ mc->m.mnt_fsname); ++ return -1; ++ } ++ } ++ if (is_mounted_same_loopfile(mc->m.mnt_dir, mc->m.mnt_fsname, offset)) ++ goto yes; ++ } ++ ++ return 0; ++yes: ++ if (verbose) ++ printf(_("mount: %s already mounted on %s\n"), ++ mc->m.mnt_fsname, mc->m.mnt_dir); ++ return 1; ++} ++ + /* avoid using stat() on things we are not going to mount anyway.. */ + static int + has_noauto (const char *opts) { +@@ -1804,16 +1849,8 @@ do_mount_all (char *types, char *options + if (matching_type (mc->m.mnt_type, types) + && matching_opts (mc->m.mnt_opts, test_opts) + && !streq (mc->m.mnt_dir, "/") +- && !streq (mc->m.mnt_dir, "root")) { +- +- if (mounted (mc->m.mnt_fsname, mc->m.mnt_dir)) { +- if (verbose) +- printf(_("mount: %s already mounted " +- "on %s\n"), +- mc->m.mnt_fsname, +- mc->m.mnt_dir); +- continue; +- } ++ && !streq (mc->m.mnt_dir, "root") ++ && !is_fstab_entry_mounted(mc, verbose)) { + + mtmp = (struct mntentchn *) xmalloc(sizeof(*mtmp)); + *mtmp = *mc; diff --git a/util-linux-ng-2.17-partx.patch b/util-linux-ng-2.17-partx.patch new file mode 100644 index 0000000..50d3abc --- /dev/null +++ b/util-linux-ng-2.17-partx.patch @@ -0,0 +1,52 @@ +Upstream patches: + + From d6d9cc6ea158ef3b2525742ee3f80c4a3be8b049 Mon Sep 17 00:00:00 2001 + From: Phillip Susi + Date: Wed, 31 Mar 2010 15:52:08 +0200 + Subject: [PATCH] partx: do not add nonexistent partitions + + This simple patch fixes partx -a to not add nonexistent zero length + partitions for unused primary partition slots to to the kernel. This + makes partx conform to the usual kernel behavior. + + Signed-off-by: Phillip Susi + Signed-off-by: Karel Zak + + + From c86dda7b36e3a6cfc63b9c03f7d275d715d35fd0 Mon Sep 17 00:00:00 2001 + From: Karel Zak + Date: Wed, 31 Mar 2010 16:38:51 +0200 + Subject: [PATCH] partx: fix infinite loop + + On Wed, Mar 24, 2010 at 04:39:35PM -0400, Phillip Susi wrote: + > I noticed that running partx -d /dev/sda hangs so I looked into it + > and it seems that it keeps trying to delete partitions forever. + + Reported-By: Phillip Susi + Signed-off-by: Karel Zak + +--- + partx/partx.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- util-linux-ng-2.17.2.orig/partx/partx.c ++++ util-linux-ng-2.17.2/partx/partx.c +@@ -178,6 +178,8 @@ main(int argc, char **argv){ + while (upper == 0 || lower <= upper) { + int err; + ++ if (lower > MAXSLICES) ++ break; + pt.pno = lower; + pt.start = 0; + pt.length = 0; +@@ -295,6 +297,9 @@ main(int argc, char **argv){ + } + } + for (j=0; j +Date: Thu, 8 Apr 2010 08:51:00 +0200 +Subject: [PATCH 1/2] rtcwake: does miss the "off" option + +Reported-by: Piergiorgio Sartor +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=580296 +Signed-off-by: Karel Zak +--- + sys-utils/rtcwake.c | 24 +++++++++++++++++++----- + 1 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c +index 7b2df26..344fed7 100644 +--- a/sys-utils/rtcwake.c ++++ b/sys-utils/rtcwake.c +@@ -468,15 +468,19 @@ int main(int argc, char **argv) + fflush(stdout); + usleep(10 * 1000); + +- if (strcmp(suspend, "no") == 0) ++ if (strcmp(suspend, "no") == 0) { ++ if (verbose) ++ printf(_("suspend mode: no; leaving\n")); ++ close(fd); + exit(EXIT_SUCCESS); +- else if (strcmp(suspend, "on") != 0) { +- sync(); +- suspend_system(suspend); ++ + } else if (strcmp(suspend, "off") == 0) { + char *arg[4]; + int i = 0; + ++ if (verbose) ++ printf(_("suspend mode: off; executing %s\n"), ++ _PATH_SHUTDOWN); + arg[i++] = _PATH_SHUTDOWN; + arg[i++] = "-P"; + arg[i++] = "now"; +@@ -487,9 +491,13 @@ int main(int argc, char **argv) + fprintf(stderr, _("%s: unable to execute %s: %s\n"), + progname, _PATH_SHUTDOWN, strerror(errno)); + rc = EXIT_FAILURE; +- } else { ++ ++ } else if (strcmp(suspend, "on") == 0) { + unsigned long data; + ++ if (verbose) ++ printf(_("suspend mode: on; reading rtc\n")); ++ + do { + t = read(fd, &data, sizeof data); + if (t < 0) { +@@ -499,6 +507,12 @@ int main(int argc, char **argv) + if (verbose) + printf("... %s: %03lx\n", devname, data); + } while (!(data & RTC_AF)); ++ ++ } else { ++ if (verbose) ++ printf(_("suspend mode: %s; suspending system\n"), suspend); ++ sync(); ++ suspend_system(suspend); + } + + if (ioctl(fd, RTC_AIE_OFF, 0) < 0) +-- +1.6.6 + diff --git a/util-linux-ng-2.18-blkid-HFS.patch b/util-linux-ng-2.18-blkid-HFS.patch new file mode 100644 index 0000000..be16e5d --- /dev/null +++ b/util-linux-ng-2.18-blkid-HFS.patch @@ -0,0 +1,28 @@ +From 791a2fd67c118c3f07141e4cc95532fe908015a9 Mon Sep 17 00:00:00 2001 +From: Alexandre Peixoto Ferreira +Date: Mon, 19 Jul 2010 18:04:33 -0500 +Subject: [PATCH] libblkid: set tolerant flag for HFS + +An CDROM can contain both HFS and ISO9660 views on the same filesystem. +This confuses mount/KDE/Gnome. + +Signed-off-by: Karel Zak +--- + shlibs/blkid/src/superblocks/hfs.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/shlibs/blkid/src/superblocks/hfs.c b/shlibs/blkid/src/superblocks/hfs.c +index 8ebff68..033a65d 100644 +--- a/shlibs/blkid/src/superblocks/hfs.c ++++ b/shlibs/blkid/src/superblocks/hfs.c +@@ -291,6 +291,7 @@ const struct blkid_idinfo hfs_idinfo = + .name = "hfs", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_hfs, ++ .flags = BLKID_IDINFO_TOLERANT, + .magics = + { + { .magic = "BD", .len = 2, .kboff = 1 }, +-- +1.7.2.3 + diff --git a/util-linux-ng.spec b/util-linux-ng.spec index e07f111..ee9dca0 100644 --- a/util-linux-ng.spec +++ b/util-linux-ng.spec @@ -1,13 +1,13 @@ ### Header Summary: A collection of basic system utilities Name: util-linux-ng -Version: 2.17.1 -Release: 0.1%{?dist} +Version: 2.17.2 +Release: 10%{?dist} License: GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng -%define upstream_version %{version}-rc1 +%define upstream_version %{version} ### Features %if 0%{?rhel} @@ -104,6 +104,26 @@ Patch7: util-linux-ng-2.13-login-lastlog.patch # 231192 - ipcs is not printing correct values on pLinux Patch8: util-linux-ng-2.15-ipcs-32bit.patch +### Upstream Patches +### +# 575734 - use microsecond resolution for blkid cache entries +Patch9: util-linux-ng-2.17-blkid-usec.patch +# 580296 - "rtcwake" does miss the "off" option +Patch10: util-linux-ng-2.17-rtcwake-off.patch +# 588668 - F13: don't probe for RAIDs on CD-ROMs +Patch11: util-linux-ng-2.17-blkid-cdrom.patch +# 543749 - After upgrade from Fedora 11, RAID-1 mdraid assembles incorrectly +# 592958 - whole disk raid members to not be identified +Patch12: util-linux-ng-2.17-blkid-raid.patch +# 592061 - partx infinite loop +Patch13: util-linux-ng-2.17-partx.patch +# 598631 - shutdown, reboot, halt and C-A-D don't work +Patch14: util-linux-ng-2.17-agetty-clocal.patch +# 618957 - ISO images listed in fstab are mounted twice at boot +Patch15: util-linux-ng-2.17-mount-loopdev.patch +# 538551 - Dual-filesystem (ISO9660/HFS) CD-ROMs not mounted automatically +Patch16: util-linux-ng-2.18-blkid-HFS.patch + %description The util-linux-ng package contains a large variety of low-level system utilities that are necessary for a Linux system to function. Among @@ -196,6 +216,14 @@ cp %{SOURCE8} %{SOURCE9} . %patch5 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 %build unset LINGUAS || : @@ -715,6 +743,63 @@ fi %changelog +* Wed Jan 12 2011 Karel Zak 2.17.2-10 +- improve libblkid RAIDs detection (#543749) + +* Mon Oct 11 2010 Karel Zak 2.17.2-9 +* fix #538551 - Dual-filesystem (ISO9660/HFS) CD-ROMs not mounted automatically + +* Thu Aug 5 2010 Karel Zak 2.17.2-8 +- fix #620924 - /sbin/mount.tmpfs uses not available /usr/bin/id + +* Mon Aug 2 2010 Karel Zak 2.17.2-7 +- fix #618957 - ISO images listed in fstab are mounted twice at boot + +* Tue Jul 20 2010 Karel Zak 2.17.2-6 +- fix #615719 - tmpfs mount fails with 'user' option. +- fix #598631 - shutdown, reboot, halt and C-A-D don't work + +* Wed May 19 2010 Karel Zak 2.17.2-5 +- fix #592958 - whole disk raid members to not be identified +- fix #592061 - partx infinite loop +- add diffstat (by quilt refresh) to some old patches + +* Tue May 4 2010 Karel Zak 2.17.2-4 +- fix #588668 - F13: don't probe for RAIDs on CD-ROMs +- fix #543749 - After upgrade from Fedora 11, RAID-1 mdraid assembles incorrectly + +* Mon Apr 12 2010 Karel Zak 2.17.2-3 +- fix #581252 - remounting tmpfs fails because of hidden rootcontext= + +* Thu Apr 8 2010 Karel Zak 2.17.2-2 +- fix #580296 - "rtcwake" does miss the "off" option + +* Mon Mar 22 2010 Karel Zak 2.17.2-1 +- upgrade to the bugfix release 2.17.2 + ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.17/v2.17.2-ReleaseNotes + ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.17/v2.17.2-ChangeLog +- remove: util-linux-ng-2.17-blkid-alignment-offset.patch + util-linux-ng-2.17-blkid-minix.patch + util-linux-ng-2.17-blkid-tinyflag.patch +- fix #575734 - use microsecond resolution for blkid cache entries + +* Wed Mar 10 2010 Karel Zak 2.17.1-5 +- minor bugfix in the spec file + +* Wed Mar 10 2010 Karel Zak 2.17.1-4 +- fix #572139 - reset tiny flag in libblkid + +* Mon Mar 8 2010 Karel Zak 2.17.1-3 +- fix #570606 - blkid (and related) should be a bit more robust + +* Wed Mar 3 2010 Karel Zak 2.17.1-2 +- fix #570136 - RHEL6: libblkid: support alignment_offset=-1 + +* Mon Feb 22 2010 Karel Zak 2.17.1-1 +- upgrade to the final 2.17.1 + ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.17/v2.17.1-ReleaseNotes + ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.17/v2.17.1-ChangeLog + * Tue Feb 16 2010 Karel Zak 2.17.1-0.1 - upgrade to 2.17.1-rc1