- btrfs-progs: canonicalize pathnames for device commands (bnc#880486).

- Added patch:
  * btrfs-progs-canonicalize-pathnames-for-device-commands

- 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

- 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

OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=162
This commit is contained in:
Jeff Mahoney 2014-06-06 13:23:35 +00:00 committed by Git OBS Bridge
parent 4b765ed3cf
commit fa2002d5ac
5 changed files with 520 additions and 102 deletions

View File

@ -1,93 +0,0 @@
From 1e9e1d5c876a4c281b3b9e72f4cbaaef1e3a2fa5 Mon Sep 17 00:00:00 2001
From: David Marcin <djmarcin@google.com>
Date: Mon, 21 Nov 2011 20:51:15 -0600
Subject: [PATCH 170/170] btrfs-progs: In find-root, dump bytenr for every
slot.
Signed-off-by: David Marcin <djmarcin@google.com>
---
btrfs-find-root.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index ffbdde1..00b10e7 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -127,8 +127,63 @@ out:
return NULL;
}
+static int dump_root_bytenr(struct btrfs_root *root, u64 bytenr, u64 gen)
+{
+ struct btrfs_root *tmp = malloc(sizeof(struct btrfs_root));
+ struct btrfs_path *path;
+ struct btrfs_key key;
+ struct btrfs_root_item ri;
+ struct extent_buffer *leaf;
+ struct btrfs_disk_key disk_key;
+ struct btrfs_key found_key;
+ int slot;
+ int ret;
+
+ if (!tmp)
+ return -ENOMEM;
+
+ __setup_root(4096, 4096, 4096, 4096, tmp,
+ root->fs_info, BTRFS_ROOT_TREE_OBJECTID);
+
+ tmp->node = read_tree_block(root, bytenr, 4096, gen);
+
+ key.objectid = 0;
+ key.type = BTRFS_ROOT_ITEM_KEY;
+ key.offset = -1;
+
+ path = btrfs_alloc_path();
+
+ /* Walk the slots of this root looking for BTRFS_ROOT_ITEM_KEYs. */
+ ret = btrfs_search_slot(NULL, tmp, &key, path, 0, 0);
+ BUG_ON(ret < 0);
+ while (1) {
+ leaf = path->nodes[0];
+ slot = path->slots[0];
+ if (slot >= btrfs_header_nritems(leaf)) {
+ ret = btrfs_next_leaf(tmp, path);
+ if (ret != 0)
+ break;
+ leaf = path->nodes[0];
+ slot = path->slots[0];
+ }
+ btrfs_item_key(leaf, &disk_key, path->slots[0]);
+ btrfs_disk_key_to_cpu(&found_key, &disk_key);
+ if (btrfs_key_type(&found_key) == BTRFS_ROOT_ITEM_KEY) {
+ unsigned long offset;
+
+ offset = btrfs_item_ptr_offset(leaf, slot);
+ read_extent_buffer(leaf, &ri, offset, sizeof(ri));
+ printf("Generation: %Lu Root bytenr: %Lu\n", gen, btrfs_root_bytenr(&ri));
+ }
+ path->slots[0]++;
+ }
+ btrfs_free_path(path);
+ free_extent_buffer(leaf);
+ return 0;
+}
+
static int search_iobuf(struct btrfs_root *root, void *iobuf,
- size_t iobuf_size, off_t offset)
+ size_t iobuf_size, off_t offset)
{
u64 gen = search_generation;
u64 objectid = search_objectid;
@@ -160,6 +215,9 @@ static int search_iobuf(struct btrfs_root *root, void *iobuf,
h_byte);
goto next;
}
+ /* Found some kind of root and it's fairly valid. */
+ if (dump_root_bytenr(root, h_byte, h_gen))
+ break;
if (h_gen != gen) {
fprintf(stderr, "Well block %Lu seems great, "
"but generation doesn't match, "
--
1.8.3.1

View File

@ -0,0 +1,182 @@
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

View File

@ -0,0 +1,292 @@
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);

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
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

View File

@ -62,7 +62,8 @@ Patch164: 0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch
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
@ -135,7 +136,8 @@ build applications to interface with btrfs.
%patch167 -p1
%patch168 -p1
%patch169 -p1
%patch170 -p1
%patch171 -p1
%patch172 -p1
%patch200 -p1
%patch201 -p1
%patch202 -p1
@ -143,8 +145,7 @@ build applications to interface with btrfs.
%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}
@ -182,6 +183,17 @@ find %{buildroot} -type f -name "*.la" -delete -print
# 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
@ -194,11 +206,9 @@ rm -f %{buildroot}/%{_libdir}/*.a
/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
@ -206,11 +216,9 @@ rm -f %{buildroot}/%{_libdir}/*.a
%{_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
@ -228,7 +236,6 @@ rm -f %{buildroot}/%{_libdir}/*.a
%{_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
@ -249,6 +256,14 @@ rm -f %{buildroot}/%{_libdir}/*.a
%{_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)
%{_libdir}/libbtrfs.so.*