Hello community, here is the log from the commit of package btrfsprogs for openSUSE:Factory checked in at 2014-06-18 07:50:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/btrfsprogs (Old) and /work/SRC/openSUSE:Factory/.btrfsprogs.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "btrfsprogs" Changes: -------- --- /work/SRC/openSUSE:Factory/btrfsprogs/btrfsprogs.changes 2014-05-27 11:51:13.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.btrfsprogs.new/btrfsprogs.changes 2014-06-18 07:52:32.000000000 +0200 @@ -1,0 +2,40 @@ +Fri Jun 6 13:20:54 UTC 2014 - jeffm@suse.com + +- btrfs-progs: canonicalize pathnames for device commands (bnc#880486). +- Added patch: + * btrfs-progs-canonicalize-pathnames-for-device-commands + +------------------------------------------------------------------- +Fri Jun 6 13:20:10 UTC 2014 - jeffm@suse.com + +- fsck: fix checking on filesystems with large sectorsize (bnc#872286) +- Added patches: + * 0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch + +------------------------------------------------------------------- +Fri Jun 6 13:15:01 UTC 2014 - jeffm@suse.com + +- Do not package btrfs-find-root and btrfs-select-super by default. +- Removed printing byte number for every slot (bnc#872364). +- Removed patch: + * 0170-btrfs-progs-In-find-root-dump-bytenr-for-every-slot.patch + +------------------------------------------------------------------- +Mon Jun 2 14:47:05 UTC 2014 - dsterba@suse.cz + +- update to upstream 3.14.2 + - man: separate pages for all subcommands + - minor bugfixes + - spec: removed upstreamed patches, update build dependencies +- Added patches: + * 0001-btrfs-progs-doc-fix-symlink-target-for-btrfsck.8.patch +- Removed patches: + * 0001-Btrfs-progs-fix-check-to-test-trim-support.patch + * 0002-Btrfs-progs-fsck-fix-double-free-memory-crash.patch + * 0003-Btrfs-progs-mkfs-Remove-zero_end-1-since-it-has-been.patch + * 0004-btrfs-progs-fix-wrong-max-system-array-size-check-in.patch + * 0005-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch + * 0009-btrfs-progs-prevent-close_root-if-the-root-to-close-.patch + * 0010-btrfs-progs-fix-mkfs.btrfs-segfault-with-features-op.patch + +------------------------------------------------------------------- Old: ---- 0001-Btrfs-progs-fix-check-to-test-trim-support.patch 0002-Btrfs-progs-fsck-fix-double-free-memory-crash.patch 0003-Btrfs-progs-mkfs-Remove-zero_end-1-since-it-has-been.patch 0004-btrfs-progs-fix-wrong-max-system-array-size-check-in.patch 0005-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch 0009-btrfs-progs-prevent-close_root-if-the-root-to-close-.patch 0010-btrfs-progs-fix-mkfs.btrfs-segfault-with-features-op.patch 0170-btrfs-progs-In-find-root-dump-bytenr-for-every-slot.patch btrfs-progs-v3.14.1.tar.bz2 New: ---- 0001-btrfs-progs-doc-fix-symlink-target-for-btrfsck.8.patch 0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch btrfs-progs-canonicalize-pathnames-for-device-commands btrfs-progs-v3.14.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ btrfsprogs.spec ++++++ --- /var/tmp/diff_new_pack.cdyria/_old 2014-06-18 07:52:33.000000000 +0200 +++ /var/tmp/diff_new_pack.cdyria/_new 2014-06-18 07:52:33.000000000 +0200 @@ -16,9 +16,9 @@ # -%define tar_version v3.14.1 +%define tar_version v3.14.2 Name: btrfsprogs -Version: 3.14.1 +Version: 3.14.2 Release: 0 Summary: Utilities for the Btrfs filesystem License: GPL-2.0 @@ -31,16 +31,10 @@ Source1: boot-btrfs.sh Source4: setup-btrfs.sh -Patch1: 0001-Btrfs-progs-fix-check-to-test-trim-support.patch -Patch2: 0002-Btrfs-progs-fsck-fix-double-free-memory-crash.patch -Patch3: 0003-Btrfs-progs-mkfs-Remove-zero_end-1-since-it-has-been.patch -Patch4: 0004-btrfs-progs-fix-wrong-max-system-array-size-check-in.patch -Patch5: 0005-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch +Patch1: 0001-btrfs-progs-doc-fix-symlink-target-for-btrfsck.8.patch Patch6: 0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch Patch7: 0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch Patch8: 0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch -Patch9: 0009-btrfs-progs-prevent-close_root-if-the-root-to-close-.patch -Patch10: 0010-btrfs-progs-fix-mkfs.btrfs-segfault-with-features-op.patch Patch11: 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch Patch12: 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch Patch13: 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch @@ -68,13 +62,15 @@ Patch167: 0167-Btrfs-progs-make-find_and_setup_root-return-an-error.patch Patch168: 0168-Btrfs-progs-don-t-bug-out-if-we-can-t-find-the-last-.patch Patch169: 0169-btrfs-progs-Check-metadata-mirrors-in-find-root.patch -Patch170: 0170-btrfs-progs-In-find-root-dump-bytenr-for-every-slot.patch +Patch171: 0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch +Patch172: btrfs-progs-canonicalize-pathnames-for-device-commands Patch200: 0200-btrfs-progs-print-qgroup-excl-as-unsigned.patch Patch201: 0201-btrfs-progs-import-ulist.patch Patch202: 0202-btrfs-progs-add-quota-group-verify-code.patch Patch1000: local-version-override.patch +BuildRequires: asciidoc BuildRequires: libacl-devel BuildRequires: libattr-devel BuildRequires: libblkid-devel @@ -82,9 +78,8 @@ BuildRequires: libuuid-devel BuildRequires: lzo-devel BuildRequires: udev +BuildRequires: xmlto BuildRequires: zlib-devel -# for /bin/true -Requires: coreutils Supplements: filesystem(btrfs) BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -112,15 +107,9 @@ %prep %setup -q -n btrfs-progs-%{tar_version} %patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 %patch6 -p1 %patch7 -p1 %patch8 -p1 -%patch9 -p1 -%patch10 -p1 %patch11 -p1 %patch12 -p1 %patch13 -p1 @@ -147,7 +136,8 @@ %patch167 -p1 %patch168 -p1 %patch169 -p1 -%patch170 -p1 +%patch171 -p1 +%patch172 -p1 %patch200 -p1 %patch201 -p1 %patch202 -p1 @@ -155,8 +145,7 @@ %build make %{?_smp_mflags} CFLAGS="%{optflags}" all btrfs-convert \ - btrfs-zero-log btrfs-select-super btrfs-image btrfstune \ - btrfs-find-root + btrfs-zero-log btrfs-select-super btrfs-image btrfstune %install make install DESTDIR=%{buildroot} prefix=%{_prefix} bindir=%{_sbindir} mandir=%{_mandir} libdir=%{_libdir} @@ -194,6 +183,17 @@ # don't install .a for now rm -f %{buildroot}/%{_libdir}/*.a +%if 0%{!?for_debugging:1} +DEBUG_FILES="/sbin/btrfs-find-root + %{_sbindir}/btrfs-find-root + %_mandir/man8/btrfs-find-root.8.gz + /sbin/btrfs-select-super + %{_sbindir}/btrfs-select-super" +for file in $DEBUG_FILES; do + rm -f %{buildroot}$file +done +%endif + %post -n libbtrfs0 -p /sbin/ldconfig %postun -n libbtrfs0 -p /sbin/ldconfig @@ -206,11 +206,9 @@ /sbin/btrfs /sbin/btrfs-zero-log /sbin/btrfs-convert -/sbin/btrfs-select-super /sbin/btrfs-image /sbin/btrfstune /sbin/btrfsck -/sbin/btrfs-find-root /sbin/mkfs.btrfs /sbin/btrfs-debug-tree /sbin/btrfs-show-super @@ -218,11 +216,9 @@ %{_sbindir}/btrfs %{_sbindir}/btrfs-zero-log %{_sbindir}/btrfs-convert -%{_sbindir}/btrfs-select-super %{_sbindir}/btrfs-image %{_sbindir}/btrfstune %{_sbindir}/btrfsck -%{_sbindir}/btrfs-find-root %{_sbindir}/fsck.btrfs %{_sbindir}/mkfs.btrfs %{_sbindir}/btrfs-debug-tree @@ -240,11 +236,33 @@ %{_mandir}/man8/btrfs.8.gz %{_mandir}/man8/btrfs-convert.8.gz %{_mandir}/man8/btrfs-debug-tree.8.gz -%{_mandir}/man8/btrfs-find-root.8.gz %{_mandir}/man8/btrfs-map-logical.8.gz %{_mandir}/man8/btrfs-show-super.8.gz %{_mandir}/man8/btrfs-zero-log.8.gz %{_mandir}/man8/btrfstune.8.gz +%{_mandir}/man8/btrfs-balance.8.gz +%{_mandir}/man8/btrfs-check.8.gz +%{_mandir}/man8/btrfs-device.8.gz +%{_mandir}/man8/btrfs-filesystem.8.gz +%{_mandir}/man8/btrfs-inspect-internal.8.gz +%{_mandir}/man8/btrfs-property.8.gz +%{_mandir}/man8/btrfs-qgroup.8.gz +%{_mandir}/man8/btrfs-quota.8.gz +%{_mandir}/man8/btrfs-receive.8.gz +%{_mandir}/man8/btrfs-replace.8.gz +%{_mandir}/man8/btrfs-rescue.8.gz +%{_mandir}/man8/btrfs-restore.8.gz +%{_mandir}/man8/btrfs-scrub.8.gz +%{_mandir}/man8/btrfs-send.8.gz +%{_mandir}/man8/btrfs-subvolume.8.gz + +%if 0%{?for_debugging:1} +/sbin/btrfs-find-root +%{_sbindir}/btrfs-find-root +%{_mandir}/man8/btrfs-find-root.8.gz +/sbin/btrfs-select-super +%{_sbindir}/btrfs-select-super +%endif %files -n libbtrfs0 %defattr(-, root, root) ++++++ 0001-btrfs-progs-doc-fix-symlink-target-for-btrfsck.8.patch ++++++
From 1982864ee7028c36be8636d1fb2e4e679ee66bed Mon Sep 17 00:00:00 2001 From: David Sterba <dsterba@suse.cz> Date: Mon, 5 May 2014 16:54:00 +0200 Subject: [PATCH] btrfs-progs: doc: fix symlink target for btrfsck.8
The manpage of btrfsck.8 is supposed to link to btrfs-check.8 . Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> --- Documentation/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 45299bb29f9b..2df6af001cbc 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -74,7 +74,7 @@ install: install-man install-man: man $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir) $(INSTALL) -m 644 $(GZ_MAN8) $(DESTDIR)$(man8dir) - $(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir) + $(LNS) btrfs-check.8.gz $(DESTDIR)$(man8dir)/btrfsck.8.gz clean: $(RM) *.xml *.xml+ *.8 *.8.gz -- 1.9.0 ++++++ 0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch ++++++
From d4a4b24f0466b6559d54da3864538afb07188836 Mon Sep 17 00:00:00 2001 From: David Sterba <dsterba@suse.cz> Date: Wed, 28 May 2014 11:25:24 +0200 Subject: [PATCH] btrfs-progs: make free space checker work on non-4k sectorsize filesystems
The value of sector for space cache was hardcoded to 4k, and used to calculate bitmap sizes. In kernel, the BITS_PER_BITMAP is derived from PAGE_CACHE_SIZE which is not available for userspace, that can also deal with filesystem of varying sectorsize. Signed-off-by: David Sterba <dsterba@suse.cz> --- free-space-cache.c | 39 ++++++++++++++++++++++++--------------- free-space-cache.h | 1 + 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/free-space-cache.c b/free-space-cache.c index bddde2403723..b705f1b8208e 100644 --- a/free-space-cache.c +++ b/free-space-cache.c @@ -25,8 +25,12 @@ #include "crc32c.h" #include "bitops.h" -#define CACHE_SECTORSIZE 4096 -#define BITS_PER_BITMAP (CACHE_SECTORSIZE * 8) +/* + * Kernel always uses PAGE_CACHE_SIZE for sectorsize, but we don't have + * anything like that in userspace and have to get the value from the + * filesystem + */ +#define BITS_PER_BITMAP(sectorsize) ((sectorsize) * 8) #define MAX_CACHE_BYTES_PER_GIG (32 * 1024) static int link_free_space(struct btrfs_free_space_ctl *ctl, @@ -48,7 +52,7 @@ static int io_ctl_init(struct io_ctl *io_ctl, u64 size, u64 ino, struct btrfs_root *root) { memset(io_ctl, 0, sizeof(struct io_ctl)); - io_ctl->num_pages = (size + CACHE_SECTORSIZE - 1) / CACHE_SECTORSIZE; + io_ctl->num_pages = (size + root->sectorsize - 1) / root->sectorsize; io_ctl->buffer = kzalloc(size, GFP_NOFS); if (!io_ctl->buffer) return -ENOMEM; @@ -75,11 +79,11 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl) static void io_ctl_map_page(struct io_ctl *io_ctl, int clear) { BUG_ON(io_ctl->index >= io_ctl->num_pages); - io_ctl->cur = io_ctl->buffer + (io_ctl->index++ * CACHE_SECTORSIZE); + io_ctl->cur = io_ctl->buffer + (io_ctl->index++ * io_ctl->root->sectorsize); io_ctl->orig = io_ctl->cur; - io_ctl->size = CACHE_SECTORSIZE; + io_ctl->size = io_ctl->root->sectorsize; if (clear) - memset(io_ctl->cur, 0, CACHE_SECTORSIZE); + memset(io_ctl->cur, 0, io_ctl->root->sectorsize); } static void io_ctl_drop_pages(struct io_ctl *io_ctl) @@ -203,7 +207,7 @@ static int io_ctl_check_crc(struct io_ctl *io_ctl, int index) val = *tmp; io_ctl_map_page(io_ctl, 0); - crc = crc32c(crc, io_ctl->orig + offset, CACHE_SECTORSIZE - offset); + crc = crc32c(crc, io_ctl->orig + offset, io_ctl->root->sectorsize - offset); btrfs_csum_final(crc, (char *)&crc); if (val != crc) { printk("btrfs: csum mismatch on free space cache\n"); @@ -250,7 +254,7 @@ static int io_ctl_read_bitmap(struct io_ctl *io_ctl, if (ret) return ret; - memcpy(entry->bitmap, io_ctl->cur, CACHE_SECTORSIZE); + memcpy(entry->bitmap, io_ctl->cur, io_ctl->root->sectorsize); io_ctl_unmap_page(io_ctl); return 0; @@ -371,7 +375,7 @@ static int __load_free_space_cache(struct btrfs_root *root, } else { BUG_ON(!num_bitmaps); num_bitmaps--; - e->bitmap = kzalloc(CACHE_SECTORSIZE, GFP_NOFS); + e->bitmap = kzalloc(ctl->sectorsize, GFP_NOFS); if (!e->bitmap) { free(e); goto free_cache; @@ -458,8 +462,9 @@ static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl, { u64 bitmap_start; u64 bytes_per_bitmap; + u32 sectorsize = ctl->sectorsize; - bytes_per_bitmap = BITS_PER_BITMAP * ctl->unit; + bytes_per_bitmap = BITS_PER_BITMAP(sectorsize) * ctl->unit; bitmap_start = offset - ctl->start; bitmap_start = bitmap_start / bytes_per_bitmap; bitmap_start *= bytes_per_bitmap; @@ -528,6 +533,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, { struct rb_node *n = ctl->free_space_offset.rb_node; struct btrfs_free_space *entry, *prev = NULL; + u32 sectorsize = ctl->sectorsize; /* find entry that is closest to the 'offset' */ while (1) { @@ -612,7 +618,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, prev->offset + prev->bytes > offset) return prev; } - if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) + if (entry->offset + BITS_PER_BITMAP(sectorsize) * ctl->unit > offset) return entry; } else if (entry->offset + entry->bytes > offset) return entry; @@ -622,7 +628,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, while (1) { if (entry->bitmap) { - if (entry->offset + BITS_PER_BITMAP * + if (entry->offset + BITS_PER_BITMAP(sectorsize) * ctl->unit > offset) break; } else { @@ -669,14 +675,15 @@ static int search_bitmap(struct btrfs_free_space_ctl *ctl, unsigned long found_bits = 0; unsigned long bits, i; unsigned long next_zero; + u32 sectorsize = ctl->sectorsize; i = offset_to_bit(bitmap_info->offset, ctl->unit, max_t(u64, *offset, bitmap_info->offset)); bits = bytes_to_bits(*bytes, ctl->unit); - for_each_set_bit_from(i, bitmap_info->bitmap, BITS_PER_BITMAP) { + for_each_set_bit_from(i, bitmap_info->bitmap, BITS_PER_BITMAP(sectorsize)) { next_zero = find_next_zero_bit(bitmap_info->bitmap, - BITS_PER_BITMAP, i); + BITS_PER_BITMAP(sectorsize), i); if ((next_zero - i) >= bits) { found_bits = next_zero - i; break; @@ -763,6 +770,7 @@ int btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group, if (!ctl) return -ENOMEM; + ctl->sectorsize = sectorsize; ctl->unit = sectorsize; ctl->start = block_group->key.objectid; ctl->private = block_group; @@ -823,6 +831,7 @@ static void merge_space_tree(struct btrfs_free_space_ctl *ctl) struct btrfs_free_space *e, *prev = NULL; struct rb_node *n; int ret; + u32 sectorsize = ctl->sectorsize; again: prev = NULL; @@ -832,7 +841,7 @@ again: u64 offset = e->offset, bytes = ctl->unit; u64 end; - end = e->offset + (u64)(BITS_PER_BITMAP * ctl->unit); + end = e->offset + (u64)(BITS_PER_BITMAP(sectorsize) * ctl->unit); unlink_free_space(ctl, e); while (!(search_bitmap(ctl, e, &offset, &bytes))) { diff --git a/free-space-cache.h b/free-space-cache.h index d28625867f76..ec213da66ccf 100644 --- a/free-space-cache.h +++ b/free-space-cache.h @@ -36,6 +36,7 @@ struct btrfs_free_space_ctl { int unit; u64 start; void *private; + u32 sectorsize; }; int load_free_space_cache(struct btrfs_fs_info *fs_info, -- 1.9.0 ++++++ btrfs-progs-canonicalize-pathnames-for-device-commands ++++++ From: Jeff Mahoney <jeffm@suse.com> Subject: btrfs-progs: canonicalize pathnames for device commands References: bnc#880486 Patch-mainline: Submitted to linux-btrfs, 4 Jun 2014 mount(8) will canonicalize pathnames before passing them to the kernel. Links to e.g. /dev/sda will be resolved to /dev/sda. Links to /dev/dm-# will be resolved using the name of the device mapper table to /dev/mapper/<name>. Btrfs will use whatever name the user passes to it, regardless of whether it is canonical or not. That means that if a 'btrfs device ready' is issued on any device node pointing to the original device, it will adopt the new name instead of the name that was used during mount. Mounting using /dev/sdb2 will result in df: /dev/sdb2 209715200 39328 207577088 1% /mnt # ls -la /dev/whatever-i-like lrwxrwxrwx 1 root root 4 Jun 4 13:36 /dev/whatever-i-like -> sdb2 # btrfs dev ready /dev/whatever-i-like # df /mnt /dev/whatever-i-like 209715200 39328 207577088 1% /mnt Likewise, mounting with /dev/mapper/whatever and using /dev/dm-0 with a btrfs device command results in df showing /dev/dm-0. This can happen with multipath devices with friendly names enabled and doing something like 'partprobe' which (at least with our version) ends up issuing a 'change' uevent on the sysfs node. That *always* uses the dm-# name, and we get confused users. This patch does the same canonicalization of the paths that mount does so that we don't end up having inconsistent names reported by ->show_devices later. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- cmds-device.c | 60 ++++++++++++++++++++++++++++++++++++++++++++------------- cmds-replace.c | 13 ++++++++++-- utils.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ utils.h | 2 + 4 files changed, 117 insertions(+), 15 deletions(-) --- a/cmds-device.c +++ b/cmds-device.c @@ -95,6 +95,7 @@ static int cmd_add_dev(int argc, char ** int devfd, res; u64 dev_block_count = 0; int mixed = 0; + char *path; res = test_dev_for_mkfs(argv[i], force, estr); if (res) { @@ -118,15 +119,24 @@ static int cmd_add_dev(int argc, char ** goto error_out; } - strncpy_null(ioctl_args.name, argv[i]); + path = canonicalize_path(argv[i]); + if (!path) { + fprintf(stderr, + "ERROR: Could not canonicalize pathname '%s': %s\n", + argv[i], strerror(errno)); + ret++; + goto error_out; + } + + strncpy_null(ioctl_args.name, path); res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args); e = errno; - if(res<0){ + if (res < 0) { fprintf(stderr, "ERROR: error adding the device '%s' - %s\n", - argv[i], strerror(e)); + path, strerror(e)); ret++; } - + free(path); } error_out: @@ -242,6 +252,7 @@ static int cmd_scan_dev(int argc, char * for( i = devstart ; i < argc ; i++ ){ struct btrfs_ioctl_vol_args args; + char *path; if (!is_block_device(argv[i])) { fprintf(stderr, @@ -249,9 +260,17 @@ static int cmd_scan_dev(int argc, char * ret = 1; goto close_out; } - printf("Scanning for Btrfs filesystems in '%s'\n", argv[i]); + path = canonicalize_path(argv[i]); + if (!path) { + fprintf(stderr, + "ERROR: Could not canonicalize path '%s': %s\n", + argv[i], strerror(errno)); + ret = 1; + goto close_out; + } + printf("Scanning for Btrfs filesystems in '%s'\n", path); - strncpy_null(args.name, argv[i]); + strncpy_null(args.name, path); /* * FIXME: which are the error code returned by this ioctl ? * it seems that is impossible to understand if there no is @@ -262,9 +281,11 @@ static int cmd_scan_dev(int argc, char * if( ret < 0 ){ fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n", - argv[i], strerror(e)); + path, strerror(e)); + free(path); goto close_out; } + free(path); } close_out: @@ -284,6 +305,7 @@ static int cmd_ready_dev(int argc, char struct btrfs_ioctl_vol_args args; int fd; int ret; + char *path; if (check_argc_min(argc, 2)) usage(cmd_ready_dev_usage); @@ -293,22 +315,34 @@ static int cmd_ready_dev(int argc, char perror("failed to open /dev/btrfs-control"); return 1; } - if (!is_block_device(argv[1])) { + + path = canonicalize_path(argv[argc - 1]); + if (!path) { fprintf(stderr, - "ERROR: %s is not a block device\n", argv[1]); - close(fd); - return 1; + "ERROR: Could not canonicalize pathname '%s': %s\n", + argv[argc - 1], strerror(errno)); + ret = 1; + goto out; } - strncpy(args.name, argv[argc - 1], BTRFS_PATH_NAME_MAX); + if (!is_block_device(path)) { + fprintf(stderr, + "ERROR: %s is not a block device\n", path); + ret = 1; + goto out; + } + + strncpy(args.name, path, BTRFS_PATH_NAME_MAX); ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args); if (ret < 0) { fprintf(stderr, "ERROR: unable to determine if the device '%s'" - " is ready for mounting - %s\n", argv[argc - 1], + " is ready for mounting - %s\n", path, strerror(errno)); ret = 1; } +out: + free(path); close(fd); return ret; } --- a/cmds-replace.c +++ b/cmds-replace.c @@ -134,7 +134,7 @@ static int cmd_start_replace(int argc, c int fddstdev = -1; char *path; char *srcdev; - char *dstdev; + char *dstdev = NULL; int avoid_reading_from_srcdev = 0; int force_using_targetdev = 0; struct stat st; @@ -204,7 +204,12 @@ static int cmd_start_replace(int argc, c } srcdev = argv[optind]; - dstdev = argv[optind + 1]; + dstdev = canonicalize_path(argv[optind + 1]); + if (!dstdev) { + fprintf(stderr, + "ERROR: Could not canonicalize path '%s': %s\n", + argv[optind + 1], strerror(errno)); + } if (is_numerical(srcdev)) { struct btrfs_ioctl_fs_info_args fi_args; @@ -278,6 +283,8 @@ static int cmd_start_replace(int argc, c close(fddstdev); fddstdev = -1; + free(dstdev); + dstdev = NULL; dev_replace_handle_sigint(fdmnt); if (!do_not_background) { @@ -312,6 +319,8 @@ static int cmd_start_replace(int argc, c return 0; leave_with_error: + if (dstdev) + free(dstdev); if (fdmnt != -1) close(fdmnt); if (fdsrcdev != -1) --- a/utils.c +++ b/utils.c @@ -987,6 +987,63 @@ static int blk_file_in_dev_list(struct b } /* + * Resolve a pathname to a device mapper node to /dev/mapper/<name> + * Returns NULL on invalid input or malloc failure; Other failures + * will be handled by the caller using the input pathame. + */ +char *canonicalize_dm_name(const char *ptname) +{ + FILE *f; + size_t sz; + char path[256], name[256], *res = NULL; + + if (!ptname || !*ptname) + return NULL; + + snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptname); + if (!(f = fopen(path, "r"))) + return NULL; + + /* read <name>\n from sysfs */ + if (fgets(name, sizeof(name), f) && (sz = strlen(name)) > 1) { + name[sz - 1] = '\0'; + snprintf(path, sizeof(path), "/dev/mapper/%s", name); + + if (access(path, F_OK) == 0) + res = strdup(path); + } + fclose(f); + return res; +} + +/* + * Resolve a pathname to a canonical device node, e.g. /dev/sda1 or + * to a device mapper pathname. + * Returns NULL on invalid input or malloc failure; Other failures + * will be handled by the caller using the input pathame. + */ +char *canonicalize_path(const char *path) +{ + char *canonical, *p; + + if (!path || !*path) + return NULL; + + canonical = realpath(path, NULL); + if (!canonical) + return strdup(path); + p = strrchr(canonical, '/'); + if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) { + char *dm = canonicalize_dm_name(p + 1); + if (dm) { + free(canonical); + return dm; + } + } + return canonical; +} + +/* * returns 1 if the device was mounted, < 0 on error or 0 if everything * is safe to continue. */ --- a/utils.h +++ b/utils.h @@ -61,6 +61,8 @@ int btrfs_add_to_fsid(struct btrfs_trans int btrfs_scan_for_fsid(int run_ioctls); void btrfs_register_one_device(char *fname); int btrfs_scan_one_dir(char *dirname, int run_ioctl); +char *canonicalize_dm_name(const char *ptname); +char *canonicalize_path(const char *path); int check_mounted(const char *devicename); int check_mounted_where(int fd, const char *file, char *where, int size, struct btrfs_fs_devices **fs_devices_mnt); ++++++ btrfs-progs-v3.14.1.tar.bz2 -> btrfs-progs-v3.14.2.tar.bz2 ++++++ ++++ 4613 lines of diff (skipped) ++++++ local-version-override.patch ++++++ --- /var/tmp/diff_new_pack.cdyria/_old 2014-06-18 07:52:34.000000000 +0200 +++ /var/tmp/diff_new_pack.cdyria/_new 2014-06-18 07:52:34.000000000 +0200 @@ -6,8 +6,8 @@ # Copyright 2008, Oracle # Released under the GNU GPLv2 --v="v3.14.1" -+v="v3.14.1+20140502" +-v="v3.14.2" ++v="v3.14.2+20140530" which git &> /dev/null if [ $? == 0 -a -d .git ]; then -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org