Hello community, here is the log from the commit of package bcache-tools for openSUSE:Factory checked in at 2014-04-13 13:14:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/bcache-tools (Old) and /work/SRC/openSUSE:Factory/.bcache-tools.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bcache-tools" Changes: -------- --- /work/SRC/openSUSE:Factory/bcache-tools/bcache-tools.changes 2014-03-21 13:28:34.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.bcache-tools.new/bcache-tools.changes 2014-04-13 13:14:28.000000000 +0200 @@ -1,0 +2,10 @@ +Fri Apr 4 07:57:33 UTC 2014 - [email protected] + +- Update to new upstream release 0.9 +* Run probe-bcache a little later in the udev rule sequence + (moving from position 61 to 69), fixing a machine hang on + bcache reassemble (bnc#868938) +- Add 0001-build-remove-inline-keyword-from-crc64.patch, this is + a build fix. + +------------------------------------------------------------------- Old: ---- bcache-tools-0.1.g71.tar.xz New: ---- 0001-build-remove-inline-keyword-from-crc64.patch bcache-tools-0.9.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ bcache-tools.spec ++++++ --- /var/tmp/diff_new_pack.wyjZ2J/_old 2014-04-13 13:14:29.000000000 +0200 +++ /var/tmp/diff_new_pack.wyjZ2J/_new 2014-04-13 13:14:29.000000000 +0200 @@ -20,16 +20,19 @@ Summary: Configuration utilities for bcache License: GPL-2.0 Group: System/Base -Version: 0.1.g71 +Version: 0.9 Release: 0 -#Snapshot: 0b57e166ae86d525ef42842cabf7692fc7c44039 +#Git-Snapshot: v0.9 Url: http://bcache.evilpiepirate.org/ #Git-Clone: http://evilpiepirate.org/git/bcache-tools.git Source: %name-%version.tar.xz +Patch1: 0001-build-remove-inline-keyword-from-crc64.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: libblkid-devel BuildRequires: libuuid-devel BuildRequires: openssl-devel +BuildRequires: pkg-config BuildRequires: xz %description @@ -37,9 +40,12 @@ %prep %setup -qn %name +%patch -P 1 -p1 %build -make all CFLAGS="%optflags" %{?_smp_mflags} +export SUSE_ASNEEDED=0 +make all CFLAGS="%optflags $(pkg-config blkid uuid --cflags) -std=gnu99" \ + LDFLAGS="$(pkg-config blkid uuid --libs)" %{?_smp_mflags} %install b="%buildroot" @@ -49,7 +55,6 @@ mkdir -p "$b/%_sysconfdir/initramfs-tools/hooks" make install DESTDIR="$b" rm -Rf "$b/%_sysconfdir/initramfs-tools" -mv "$b"/lib/udev/rules.d/61-bcache.rules "$b"/lib/udev/rules.d/74-bcache.rules mkdir -p "$b/%_prefix/lib" mv "$b/lib/udev" "$b/%_prefix/lib/" @@ -57,7 +62,6 @@ %defattr(-,root,root) %_sbindir/bcache-super-show %_sbindir/make-bcache -/sbin/probe-bcache %_prefix/lib/udev %_mandir/man8/*.8* %doc COPYING ++++++ 0001-build-remove-inline-keyword-from-crc64.patch ++++++ >From 96e990f72720c87c0bd85b31f819bddcdfdb22d7 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt <[email protected]> Date: Fri, 4 Apr 2014 10:08:17 +0200 Subject: [PATCH] build: remove inline keyword from crc64 In optimization levels like -O2, crc64 gets inlined for me and a linker error follows, because there is no more crc64 function in the object output. --- bcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bcache.c b/bcache.c index 8f37445..8b4b986 100644 --- a/bcache.c +++ b/bcache.c @@ -115,7 +115,7 @@ static const uint64_t crc_table[256] = { 0x9AFCE626CE85B507ULL }; -inline uint64_t crc64(const void *_data, size_t len) +uint64_t crc64(const void *_data, size_t len) { uint64_t crc = 0xFFFFFFFFFFFFFFFFULL; const unsigned char *data = _data; -- 1.8.4.5 ++++++ bcache-tools-0.1.g71.tar.xz -> bcache-tools-0.9.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/61-bcache.rules new/bcache-tools/61-bcache.rules --- old/bcache-tools/61-bcache.rules 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/61-bcache.rules 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -# register bcache devices as they come up -# man 7 udev for syntax - -SUBSYSTEM!="block", GOTO="bcache_end" -ACTION=="remove", GOTO="bcache_end" - -# Backing devices: scan, symlink, register -IMPORT{program}="/sbin/blkid -o udev $tempnode" -# blkid and probe-bcache can disagree, in which case don't register -ENV{ID_FS_TYPE}=="?*", ENV{ID_FS_TYPE}!="bcache", GOTO="bcache_backing_end" - -IMPORT{program}="/sbin/probe-bcache -o udev $tempnode" -ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" -SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="bcache", \ - RUN+="bcache-register $tempnode" -LABEL="bcache_backing_end" - -# Cached devices: symlink -DRIVER=="bcache", ENV{CACHED_UUID}=="?*", \ - SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}" -DRIVER=="bcache", ENV{CACHED_LABEL}=="?*", \ - SYMLINK+="bcache/by-label/$env{CACHED_LABEL}" - -LABEL="bcache_end" - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/69-bcache.rules new/bcache-tools/69-bcache.rules --- old/bcache-tools/69-bcache.rules 1970-01-01 01:00:00.000000000 +0100 +++ new/bcache-tools/69-bcache.rules 2014-04-04 09:56:32.000000000 +0200 @@ -0,0 +1,29 @@ +# register bcache devices as they come up +# man 7 udev for syntax + +SUBSYSTEM!="block", GOTO="bcache_end" +ACTION=="remove", GOTO="bcache_end" + +# blkid was run by the standard udev rules +# It recognised bcache (util-linux 2.24+) +ENV{ID_FS_TYPE}=="bcache", GOTO="bcache_backing_found" +# It recognised something else; bail +ENV{ID_FS_TYPE}=="?*", GOTO="bcache_backing_end" + +# Backing devices: scan, symlink, register +IMPORT{program}="probe-bcache -o udev $tempnode" +ENV{ID_FS_TYPE}!="bcache", GOTO="bcache_backing_end" +ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" + +LABEL="bcache_backing_found" +RUN+="bcache-register $tempnode" +LABEL="bcache_backing_end" + +# Cached devices: symlink +DRIVER=="bcache", ENV{CACHED_UUID}=="?*", \ + SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}" +DRIVER=="bcache", ENV{CACHED_LABEL}=="?*", \ + SYMLINK+="bcache/by-label/$env{CACHED_LABEL}" + +LABEL="bcache_end" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/Makefile new/bcache-tools/Makefile --- old/bcache-tools/Makefile 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/Makefile 2014-04-04 09:56:32.000000000 +0200 @@ -1,24 +1,32 @@ PREFIX=/usr +UDEVLIBDIR=/lib/udev +DRACUTLIBDIR=/lib/dracut +INSTALL=install CFLAGS+=-O2 -Wall -g all: make-bcache probe-bcache bcache-super-show install: make-bcache probe-bcache bcache-super-show - install -m0755 make-bcache bcache-super-show $(DESTDIR)${PREFIX}/sbin/ - install -m0755 probe-bcache $(DESTDIR)/sbin/ - install -m0644 61-bcache.rules $(DESTDIR)/lib/udev/rules.d/ - install -m0755 bcache-register $(DESTDIR)/lib/udev/ - -install -m0755 initramfs/hook $(DESTDIR)/etc/initramfs-tools/hooks/bcache - install -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8 -# install -m0755 bcache-test $(DESTDIR)${PREFIX}/sbin/ + $(INSTALL) -m0755 make-bcache bcache-super-show $(DESTDIR)${PREFIX}/sbin/ + $(INSTALL) -m0755 probe-bcache bcache-register $(DESTDIR)$(UDEVLIBDIR)/ + $(INSTALL) -m0644 69-bcache.rules $(DESTDIR)$(UDEVLIBDIR)/rules.d/ + -$(INSTALL) -T -m0755 initramfs/hook $(DESTDIR)/usr/share/initramfs-tools/hooks/bcache + if [ -d $(DESTDIR)$(DRACUTLIBDIR)/modules.d ]; \ + then $(INSTALL) -D -m0755 dracut/module-setup.sh $(DESTDIR)$(DRACUTLIBDIR)/modules.d/90bcache/module-setup.sh; \ + fi + $(INSTALL) -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8/ +# $(INSTALL) -m0755 bcache-test $(DESTDIR)${PREFIX}/sbin/ clean: $(RM) -f make-bcache probe-bcache bcache-super-show bcache-test *.o -bcache-test: LDLIBS += -lm -lssl -lcrypto -make-bcache: LDLIBS += -luuid +bcache-test: LDLIBS += `pkg-config --libs openssl` +make-bcache: LDLIBS += `pkg-config --libs uuid blkid` +make-bcache: CFLAGS += `pkg-config --cflags uuid blkid` make-bcache: bcache.o -probe-bcache: LDLIBS += -luuid -bcache-super-show: LDLIBS += -luuid +probe-bcache: LDLIBS += `pkg-config --libs uuid blkid` +probe-bcache: CFLAGS += `pkg-config --cflags uuid blkid` +bcache-super-show: LDLIBS += `pkg-config --libs uuid` +bcache-super-show: CFLAGS += -std=gnu99 bcache-super-show: bcache.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/bcache-register new/bcache-tools/bcache-register --- old/bcache-tools/bcache-register 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/bcache-register 2014-04-04 09:56:32.000000000 +0200 @@ -1,4 +1,4 @@ #!/bin/sh -modprobe -qba bcache -test -f /sys/fs/bcache/register && echo "$1" > /sys/fs/bcache/register +/sbin/modprobe -qba bcache +test -f /sys/fs/bcache/register_quiet && echo "$1" > /sys/fs/bcache/register_quiet diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/bcache-super-show.c new/bcache-tools/bcache-super-show.c --- old/bcache-tools/bcache-super-show.c 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/bcache-super-show.c 2014-04-04 09:56:32.000000000 +0200 @@ -4,6 +4,7 @@ * GPLv2 */ + #define _FILE_OFFSET_BITS 64 #define __USE_FILE_OFFSET64 #define _XOPEN_SOURCE 500 @@ -32,6 +33,29 @@ } +static bool accepted_char(char c) +{ + if ('0' <= c && c <= '9') + return true; + if ('A' <= c && c <= 'Z') + return true; + if ('a' <= c && c <= 'z') + return true; + if (strchr(".-_", c)) + return true; + return false; +} + +static void print_encode(char* in) +{ + for (char* pos = in; *pos; pos++) + if (accepted_char(*pos)) + putchar(*pos); + else + printf("%%%x", *pos); +} + + int main(int argc, char **argv) { bool force_csum = false; @@ -123,6 +147,16 @@ putchar('\n'); + char label[SB_LABEL_SIZE + 1]; + strncpy(label, (char*)sb.label, SB_LABEL_SIZE); + label[SB_LABEL_SIZE] = '\0'; + printf("dev.label\t\t"); + if (*label) + print_encode(label); + else + printf("(empty)"); + putchar('\n'); + uuid_unparse(sb.uuid, uuid); printf("dev.uuid\t\t%s\n", uuid); @@ -136,13 +170,31 @@ printf("dev.cache.first_sector\t%u\n" "dev.cache.cache_sectors\t%ju\n" "dev.cache.total_sectors\t%ju\n" + "dev.cache.ordered\t%s\n" "dev.cache.discard\t%s\n" - "dev.cache.pos\t\t%u\n", + "dev.cache.pos\t\t%u\n" + "dev.cache.replacement\t%ju", sb.bucket_size * sb.first_bucket, sb.bucket_size * (sb.nbuckets - sb.first_bucket), sb.bucket_size * sb.nbuckets, + CACHE_SYNC(&sb) ? "yes" : "no", CACHE_DISCARD(&sb) ? "yes" : "no", - sb.nr_this_dev); + sb.nr_this_dev, + CACHE_REPLACEMENT(&sb)); + switch (CACHE_REPLACEMENT(&sb)) { + case CACHE_REPLACEMENT_LRU: + printf(" [lru]\n"); + break; + case CACHE_REPLACEMENT_FIFO: + printf(" [fifo]\n"); + break; + case CACHE_REPLACEMENT_RANDOM: + printf(" [random]\n"); + break; + default: + putchar('\n'); + } + } else { uint64_t first_sector; if (sb.version == BCACHE_SB_VERSION_BDEV) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/bcache.h new/bcache-tools/bcache.h --- old/bcache-tools/bcache.h 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/bcache.h 2014-04-04 09:56:32.000000000 +0200 @@ -115,7 +115,7 @@ #define BDEV_STATE_DIRTY 2U #define BDEV_STATE_STALE 3U -inline uint64_t crc64(const void *_data, size_t len); +uint64_t crc64(const void *_data, size_t len); #define node(i, j) ((void *) ((i)->d + (j))) #define end(i) node(i, (i)->keys) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/dracut/module-setup.sh new/bcache-tools/dracut/module-setup.sh --- old/bcache-tools/dracut/module-setup.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/bcache-tools/dracut/module-setup.sh 2014-04-04 09:56:32.000000000 +0200 @@ -0,0 +1,34 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +# +# At some point (util-linux v2.24) blkid will be able to identify bcache +# but until every system has this version of util-linux, probe-bcache is +# provided as an alternative. +# + +check() { + if [[ $hostonly ]] || [[ $mount_needs ]] + then + for fs in "${host_fs_types[@]}"; do + [[ $fs = "bcache" ]] && return 0 + done + return 255 + fi + + return 0 +} + +depends() { + return 0 +} + +installkernel() { + instmods bcache +} + +install() { + inst_multiple ${udevdir}/probe-bcache ${udevdir}/bcache-register + inst_rules 69-bcache.rules +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/initramfs/hook new/bcache-tools/initramfs/hook --- old/bcache-tools/initramfs/hook 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/initramfs/hook 2014-04-04 09:56:32.000000000 +0200 @@ -16,7 +16,7 @@ . /usr/share/initramfs-tools/hook-functions -cp -pt "${DESTDIR}/lib/udev/rules.d" /lib/udev/rules.d/61-bcache.rules +cp -pt "${DESTDIR}/lib/udev/rules.d" /lib/udev/rules.d/69-bcache.rules copy_exec /lib/udev/bcache-register -copy_exec /sbin/probe-bcache +copy_exec /lib/udev/probe-bcache manual_add_modules bcache diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/make-bcache.c new/bcache-tools/make-bcache.c --- old/bcache-tools/make-bcache.c 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/make-bcache.c 2014-04-04 09:56:32.000000000 +0200 @@ -8,6 +8,7 @@ #define __USE_FILE_OFFSET64 #define _XOPEN_SOURCE 600 +#include <blkid.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -76,19 +77,19 @@ uint64_t v = hatoi(s); if (v & (v - 1)) { - printf("%s must be a power of two\n", msg); + fprintf(stderr, "%s must be a power of two\n", msg); exit(EXIT_FAILURE); } v /= 512; if (v > USHRT_MAX) { - printf("%s too large\n", msg); + fprintf(stderr, "%s too large\n", msg); exit(EXIT_FAILURE); } if (!v) { - printf("%s too small\n", msg); + fprintf(stderr, "%s too small\n", msg); exit(EXIT_FAILURE); } @@ -143,7 +144,8 @@ void usage() { - printf("Usage: make-bcache [options] device\n" + fprintf(stderr, + "Usage: make-bcache [options] device\n" " -C, --cache Format a cache device\n" " -B, --bdev Format a backing device\n" " -b, --bucket bucket size\n" @@ -166,17 +168,41 @@ }; static void write_sb(char *dev, unsigned block_size, unsigned bucket_size, - bool writeback, bool discard, + bool writeback, bool discard, bool wipe_bcache, unsigned cache_replacement_policy, uint64_t data_offset, uuid_t set_uuid, bool bdev) { int fd; - char uuid_str[40], set_uuid_str[40]; + char uuid_str[40], set_uuid_str[40], zeroes[SB_START] = {0}; struct cache_sb sb; + blkid_probe pr; if ((fd = open(dev, O_RDWR|O_EXCL)) == -1) { - printf("Can't open dev %s: %s\n", dev, strerror(errno)); + fprintf(stderr, "Can't open dev %s: %s\n", dev, strerror(errno)); + exit(EXIT_FAILURE); + } + + if (pread(fd, &sb, sizeof(sb), SB_START) != sizeof(sb)) + exit(EXIT_FAILURE); + + if (!memcmp(sb.magic, bcache_magic, 16) && !wipe_bcache) { + fprintf(stderr, "Already a bcache device on %s, " + "overwrite with --wipe-bcache\n", dev); + exit(EXIT_FAILURE); + } + + if (!(pr = blkid_new_probe())) + exit(EXIT_FAILURE); + if (blkid_probe_set_device(pr, fd, 0, 0)) + exit(EXIT_FAILURE); + /* enable ptable probing; superblock probing is enabled by default */ + if (blkid_probe_enable_partitions(pr, true)) + exit(EXIT_FAILURE); + if (!blkid_do_probe(pr)) { + /* XXX wipefs doesn't know how to remove partition tables */ + fprintf(stderr, "Device %s already has a non-bcache superblock, " + "remove it using wipefs and wipefs -a\n", dev); exit(EXIT_FAILURE); } @@ -221,7 +247,7 @@ sb.first_bucket = (23 / sb.bucket_size) + 1; if (sb.nbuckets < 1 << 7) { - printf("Not enough buckets: %ju, need %u\n", + fprintf(stderr, "Not enough buckets: %ju, need %u\n", sb.nbuckets, 1 << 7); exit(EXIT_FAILURE); } @@ -250,7 +276,13 @@ sb.csum = csum_set(&sb); - if (pwrite(fd, &sb, sizeof(sb), SB_SECTOR << 9) != sizeof(sb)) { + /* Zero start of disk */ + if (pwrite(fd, zeroes, SB_START, 0) != SB_START) { + perror("write error\n"); + exit(EXIT_FAILURE); + } + /* Write superblock */ + if (pwrite(fd, &sb, sizeof(sb), SB_START) != sizeof(sb)) { perror("write error\n"); exit(EXIT_FAILURE); } @@ -311,7 +343,7 @@ char *backing_devices[argc]; unsigned block_size = 0, bucket_size = 1024; - int writeback = 0, discard = 0; + int writeback = 0, discard = 0, wipe_bcache = 0; unsigned cache_replacement_policy = 0; uint64_t data_offset = BDEV_DATA_START_DEFAULT; uuid_t set_uuid; @@ -324,6 +356,7 @@ { "bucket", 1, NULL, 'b' }, { "block", 1, NULL, 'w' }, { "writeback", 0, &writeback, 1 }, + { "wipe-bcache", 0, &wipe_bcache, 1 }, { "discard", 0, &discard, 1 }, { "cache_replacement_policy", 1, NULL, 'p' }, { "data_offset", 1, NULL, 'o' }, @@ -351,7 +384,7 @@ #if 0 case 'U': if (uuid_parse(optarg, sb.uuid)) { - printf("Bad uuid\n"); + fprintf(stderr, "Bad uuid\n"); exit(EXIT_FAILURE); } break; @@ -363,14 +396,14 @@ case 'o': data_offset = atoll(optarg); if (data_offset < BDEV_DATA_START_DEFAULT) { - printf("Bad data offset; minimum %d sectors\n", + fprintf(stderr, "Bad data offset; minimum %d sectors\n", BDEV_DATA_START_DEFAULT); exit(EXIT_FAILURE); } break; case 'u': if (uuid_parse(optarg, set_uuid)) { - printf("Bad uuid\n"); + fprintf(stderr, "Bad uuid\n"); exit(EXIT_FAILURE); } break; @@ -379,7 +412,7 @@ break; case 1: if (bdev == -1) { - printf("Please specify -C or -B\n"); + fprintf(stderr, "Please specify -C or -B\n"); exit(EXIT_FAILURE); } @@ -391,12 +424,12 @@ } if (!ncache_devices && !nbacking_devices) { - printf("Please supply a device\n"); + fprintf(stderr, "Please supply a device\n"); usage(); } if (bucket_size < block_size) { - printf("Bucket size cannot be smaller than block size\n"); + fprintf(stderr, "Bucket size cannot be smaller than block size\n"); exit(EXIT_FAILURE); } @@ -412,12 +445,14 @@ for (i = 0; i < ncache_devices; i++) write_sb(cache_devices[i], block_size, bucket_size, - writeback, discard, cache_replacement_policy, + writeback, discard, wipe_bcache, + cache_replacement_policy, data_offset, set_uuid, false); for (i = 0; i < nbacking_devices; i++) write_sb(backing_devices[i], block_size, bucket_size, - writeback, discard, cache_replacement_policy, + writeback, discard, wipe_bcache, + cache_replacement_policy, data_offset, set_uuid, true); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcache-tools/probe-bcache.c new/bcache-tools/probe-bcache.c --- old/bcache-tools/probe-bcache.c 2013-08-08 00:00:49.000000000 +0200 +++ new/bcache-tools/probe-bcache.c 2014-04-04 09:56:32.000000000 +0200 @@ -8,6 +8,7 @@ #define __USE_FILE_OFFSET64 #define _XOPEN_SOURCE 500 +#include <blkid.h> #include <fcntl.h> #include <linux/fs.h> #include <stdbool.h> @@ -30,6 +31,7 @@ extern char *optarg; struct cache_sb sb; char uuid[40]; + blkid_probe pr; while ((o = getopt(argc, argv, "o:")) != EOF) switch (o) { @@ -51,8 +53,20 @@ if (fd == -1) continue; + if (!(pr = blkid_new_probe())) + continue; + if (blkid_probe_set_device(pr, fd, 0, 0)) + continue; + /* probe partitions too */ + if (blkid_probe_enable_partitions(pr, true)) + continue; + /* bail if anything was found + * probe-bcache isn't needed once blkid recognizes bcache */ + if (!blkid_do_probe(pr)) { + continue; + } - if (pread(fd, &sb, sizeof(sb), 4096) != sizeof(sb)) + if (pread(fd, &sb, sizeof(sb), SB_START) != sizeof(sb)) continue; if (memcmp(sb.magic, bcache_magic, 16)) -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
