packages: btrfs-progs/btrfs-progs.spec, btrfs-progs/btrfs-progs-build-every...
areq
areq at pld-linux.org
Mon Jun 7 14:14:25 CEST 2010
Author: areq Date: Mon Jun 7 12:14:25 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- add patches from fedora
---- Files affected:
packages/btrfs-progs:
btrfs-progs.spec (1.3 -> 1.4) , btrfs-progs-build-everything.patch (NONE -> 1.1) (NEW), btrfs-progs-build-fixes.patch (NONE -> 1.1) (NEW), btrfs-progs-fix-labels.patch (NONE -> 1.1) (NEW), btrfs-progs-fix-return-value.patch (NONE -> 1.1) (NEW), btrfs-progs-upstream.patch (NONE -> 1.1) (NEW), btrfs-progs-valgrind.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/btrfs-progs/btrfs-progs.spec
diff -u packages/btrfs-progs/btrfs-progs.spec:1.3 packages/btrfs-progs/btrfs-progs.spec:1.4
--- packages/btrfs-progs/btrfs-progs.spec:1.3 Sun Nov 8 00:14:09 2009
+++ packages/btrfs-progs/btrfs-progs.spec Mon Jun 7 14:14:19 2010
@@ -2,11 +2,17 @@
Summary: Utilities belonging to the btrfs filesystem
Name: btrfs-progs
Version: 0.19
-Release: 1
+Release: 2
License: GPL v2
Group: Applications/System
Source0: http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/%{name}-%{version}.tar.bz2
# Source0-md5: 5854728d080cc76f21a83bdc99b6ddaa
+Patch0: %{name}-fix-labels.patch
+Patch1: %{name}-build-everything.patch
+Patch2: %{name}-valgrind.patch
+Patch3: %{name}-fix-return-value.patch
+Patch4: %{name}-build-fixes.patch
+Patch5: %{name}-upstream.patch
URL: http://btrfs.wiki.kernel.org/
BuildRequires: autoconf >= 2.50
BuildRequires: automake
@@ -22,6 +28,12 @@
%prep
%setup -q
+%patch0 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch1 -p1
sed -i -e 's#gcc#$(CC)#g' Makefile
@@ -57,6 +69,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.4 2010/06/07 12:14:19 areq
+- add patches from fedora
+
Revision 1.3 2009/11/07 23:14:09 adamg
- updated to 0.19
================================================================
Index: packages/btrfs-progs/btrfs-progs-build-everything.patch
diff -u /dev/null packages/btrfs-progs/btrfs-progs-build-everything.patch:1.1
--- /dev/null Mon Jun 7 14:14:25 2010
+++ packages/btrfs-progs/btrfs-progs-build-everything.patch Mon Jun 7 14:14:19 2010
@@ -0,0 +1,12 @@
+--- btrfs-progs-0.19/Makefile.orig 2010-03-24 14:45:18.001490900 -0400
++++ btrfs-progs-0.19/Makefile 2010-03-24 14:45:35.745491310 -0400
+@@ -17,8 +17,7 @@
+ LIBS=-luuid
+
+ progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
+- btrfs \
+- btrfs-map-logical
++ btrfs btrfs-map-logical btrfstune btrfs-image
+
+ # make C=1 to enable sparse
+ ifdef C
================================================================
Index: packages/btrfs-progs/btrfs-progs-build-fixes.patch
diff -u /dev/null packages/btrfs-progs/btrfs-progs-build-fixes.patch:1.1
--- /dev/null Mon Jun 7 14:14:25 2010
+++ packages/btrfs-progs/btrfs-progs-build-fixes.patch Mon Jun 7 14:14:19 2010
@@ -0,0 +1,32 @@
+--- btrfs-progs-0.19/btrfsck.c
++++ btrfs-progs-0.19/btrfsck.c
+@@ -21,6 +21,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <fcntl.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
+ #include "kerncompat.h"
+ #include "ctree.h"
+ #include "disk-io.h"
+--- btrfs-progs-0.19/mkfs.c
++++ btrfs-progs-0.19/mkfs.c
+@@ -341,7 +341,7 @@ int main(int ac, char **av)
+ u64 alloc_start = 0;
+ u64 metadata_profile = BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_DUP;
+ u64 data_profile = BTRFS_BLOCK_GROUP_RAID0;
+- u32 leafsize = getpagesize();
++ u32 leafsize = sysconf(_SC_PAGESIZE);
+ u32 sectorsize = 4096;
+ u32 nodesize = leafsize;
+ u32 stripesize = 4096;
+@@ -398,7 +398,7 @@ int main(int ac, char **av)
+ print_usage();
+ }
+ }
+- sectorsize = max(sectorsize, (u32)getpagesize());
++ sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
+ if (leafsize < sectorsize || (leafsize & (sectorsize - 1))) {
+ fprintf(stderr, "Illegal leafsize %u\n", leafsize);
+ exit(1);
================================================================
Index: packages/btrfs-progs/btrfs-progs-fix-labels.patch
diff -u /dev/null packages/btrfs-progs/btrfs-progs-fix-labels.patch:1.1
--- /dev/null Mon Jun 7 14:14:25 2010
+++ packages/btrfs-progs/btrfs-progs-fix-labels.patch Mon Jun 7 14:14:19 2010
@@ -0,0 +1,25 @@
+diff --git a/mkfs.c b/mkfs.c
+index d664254..138bcc9 100644
+--- a/mkfs.c
++++ b/mkfs.c
+@@ -294,7 +294,6 @@ static u64 parse_profile(char *s)
+
+ static char *parse_label(char *input)
+ {
+- int i;
+ int len = strlen(input);
+
+ if (len > BTRFS_LABEL_SIZE) {
+@@ -302,12 +301,6 @@ static char *parse_label(char *input)
+ BTRFS_LABEL_SIZE);
+ exit(1);
+ }
+- for (i = 0; i < len; i++) {
+- if (input[i] == '/' || input[i] == '\\') {
+- fprintf(stderr, "invalid label %s\n", input);
+- exit(1);
+- }
+- }
+ return strdup(input);
+ }
+
================================================================
Index: packages/btrfs-progs/btrfs-progs-fix-return-value.patch
diff -u /dev/null packages/btrfs-progs/btrfs-progs-fix-return-value.patch:1.1
--- /dev/null Mon Jun 7 14:14:25 2010
+++ packages/btrfs-progs/btrfs-progs-fix-return-value.patch Mon Jun 7 14:14:19 2010
@@ -0,0 +1,32 @@
+From 8b6be4c65eda396e0c42182f4ebf2794c62b442c Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef at redhat.com>
+Date: Tue, 2 Feb 2010 09:51:15 -0500
+Subject: [PATCH] Btrfs-progs: make btrfsctl return values like everybody else
+
+This patch makes btrfsctl return 0 for success and 1 for failure, which is the
+behavior of all other userspace applications. Thanks,
+
+Signed-off-by: Josef Bacik <josef at redhat.com>
+---
+ btrfsctl.c | 6 ++----
+ 1 files changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/btrfsctl.c b/btrfsctl.c
+index 66c4e89..73d9c30 100644
+--- a/btrfsctl.c
++++ b/btrfsctl.c
+@@ -231,9 +231,7 @@ int main(int ac, char **av)
+ printf("ioctl failed with error %d\n", ret);
+ }
+ printf("%s\n", BTRFS_BUILD_VERSION);
+- if (ret)
+- exit(0);
+- else
+- exit(1);
++
++ return ret ? 1 : 0;
+ }
+
+--
+1.6.6
+
================================================================
Index: packages/btrfs-progs/btrfs-progs-upstream.patch
diff -u /dev/null packages/btrfs-progs/btrfs-progs-upstream.patch:1.1
--- /dev/null Mon Jun 7 14:14:25 2010
+++ packages/btrfs-progs/btrfs-progs-upstream.patch Mon Jun 7 14:14:19 2010
@@ -0,0 +1,3752 @@
+diff --git a/Makefile b/Makefile
+index 8097b5a..525676e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -4,7 +4,7 @@ CFLAGS = -g -Werror -Os
+ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
+ root-tree.o dir-item.o file-item.o inode-item.o \
+ inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
+- volumes.o utils.o
++ volumes.o utils.o btrfs-list.o
+
+ #
+ CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
+@@ -16,7 +16,9 @@ prefix ?= /usr/local
+ bindir = $(prefix)/bin
+ LIBS=-luuid
+
+-progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck
++progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
++ btrfs \
++ btrfs-map-logical
+
+ # make C=1 to enable sparse
+ ifdef C
+@@ -35,6 +37,10 @@ all: version $(progs) manpages
+ version:
+ bash version.sh
+
++btrfs: $(objects) btrfs.o btrfs_cmds.o
++ gcc $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o \
++ $(objects) $(LDFLAGS) $(LIBS)
++
+ btrfsctl: $(objects) btrfsctl.o
+ gcc $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
+
+@@ -56,6 +62,9 @@ btrfs-debug-tree: $(objects) debug-tree.o
+ btrfstune: $(objects) btrfstune.o
+ gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
+
++btrfs-map-logical: $(objects) btrfs-map-logical.o
++ gcc $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS)
++
+ btrfs-image: $(objects) btrfs-image.o
+ gcc $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS)
+
+@@ -68,6 +77,9 @@ quick-test: $(objects) quick-test.o
+ convert: $(objects) convert.o
+ gcc $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs $(LDFLAGS) $(LIBS)
+
++ioctl-test: $(objects) ioctl-test.o
++ gcc $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
++
+ manpages:
+ cd man; make
+
+diff --git a/btrfs-defrag.c b/btrfs-defrag.c
+new file mode 100644
+index 0000000..8f1525a
+--- /dev/null
++++ b/btrfs-defrag.c
+@@ -0,0 +1,39 @@
++/*
++ * Copyright (C) 2010 Oracle. All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public
++ * License v2 as published by the Free Software Foundation.
++ *
++ * This program 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.
++ *
++ * You should have received a copy of the GNU General Public
++ * License along with this program; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 021110-1307, USA.
++ */
++
++#ifndef __CHECKER__
++#include <sys/ioctl.h>
++#include <sys/mount.h>
++#include "ioctl.h"
++#endif
++#include <stdio.h>
++#include <stdlib.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <ctype.h>
++#include <unistd.h>
++#include <dirent.h>
++#include <libgen.h>
++#include <getopt.h>
++#include "kerncompat.h"
++#include "ctree.h"
++#include "transaction.h"
++#include "utils.h"
++#include "version.h"
++
+diff --git a/btrfs-list.c b/btrfs-list.c
+new file mode 100644
+index 0000000..7741705
+--- /dev/null
++++ b/btrfs-list.c
+@@ -0,0 +1,825 @@
++/*
++ * Copyright (C) 2010 Oracle. All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public
++ * License v2 as published by the Free Software Foundation.
++ *
++ * This program 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.
++ *
++ * You should have received a copy of the GNU General Public
++ * License along with this program; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 021110-1307, USA.
++ */
++
++#ifndef __CHECKER__
++#include <sys/ioctl.h>
++#include <sys/mount.h>
++#include "ioctl.h"
++#endif
++#include <stdio.h>
++#include <stdlib.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <dirent.h>
++#include <libgen.h>
++#include "kerncompat.h"
++#include "ctree.h"
++#include "transaction.h"
++#include "utils.h"
++#include "version.h"
++
++/* we store all the roots we find in an rbtree so that we can
++ * search for them later.
++ */
++struct root_lookup {
++ struct rb_root root;
++};
++
++/*
++ * one of these for each root we find.
++ */
++struct root_info {
++ struct rb_node rb_node;
++
++ /* this root's id */
++ u64 root_id;
++
++ /* the id of the root that references this one */
++ u64 ref_tree;
++
++ /* the dir id we're in from ref_tree */
++ u64 dir_id;
++
++ /* path from the subvol we live in to this root, including the
++ * root's name. This is null until we do the extra lookup ioctl.
++ */
++ char *path;
++
++ /* the name of this root in the directory it lives in */
++ char name[];
++};
++
++static void root_lookup_init(struct root_lookup *tree)
++{
++ tree->root.rb_node = NULL;
++}
++
++static int comp_entry(struct root_info *entry, u64 root_id, u64 ref_tree)
++{
++ if (entry->root_id > root_id)
++ return 1;
++ if (entry->root_id < root_id)
++ return -1;
++ if (entry->ref_tree > ref_tree)
++ return 1;
++ if (entry->ref_tree < ref_tree)
++ return -1;
++ return 0;
++}
++
++/*
++ * insert a new root into the tree. returns the existing root entry
++ * if one is already there. Both root_id and ref_tree are used
++ * as the key
++ */
++static struct rb_node *tree_insert(struct rb_root *root, u64 root_id,
++ u64 ref_tree, struct rb_node *node)
++{
++ struct rb_node ** p = &root->rb_node;
++ struct rb_node * parent = NULL;
++ struct root_info *entry;
++ int comp;
++
++ while(*p) {
++ parent = *p;
++ entry = rb_entry(parent, struct root_info, rb_node);
++
++ comp = comp_entry(entry, root_id, ref_tree);
++
++ if (comp < 0)
++ p = &(*p)->rb_left;
++ else if (comp > 0)
++ p = &(*p)->rb_right;
++ else
++ return parent;
++ }
++
++ entry = rb_entry(parent, struct root_info, rb_node);
++ rb_link_node(node, parent, p);
++ rb_insert_color(node, root);
++ return NULL;
++}
++
++/*
++ * find a given root id in the tree. We return the smallest one,
++ * rb_next can be used to move forward looking for more if required
++ */
++static struct root_info *tree_search(struct rb_root *root, u64 root_id)
++{
++ struct rb_node * n = root->rb_node;
++ struct root_info *entry;
++
++ while(n) {
++ entry = rb_entry(n, struct root_info, rb_node);
++
++ if (entry->root_id < root_id)
++ n = n->rb_left;
++ else if (entry->root_id > root_id)
++ n = n->rb_right;
++ else {
++ struct root_info *prev;
++ struct rb_node *prev_n;
++ while (1) {
++ prev_n = rb_prev(n);
++ if (!prev_n)
++ break;
++ prev = rb_entry(prev_n, struct root_info,
++ rb_node);
++ if (prev->root_id != root_id)
++ break;
++ entry = prev;
++ n = prev_n;
++ }
++ return entry;
++ }
++ }
++ return NULL;
++}
++
++/*
++ * this allocates a new root in the lookup tree.
++ *
++ * root_id should be the object id of the root
++ *
++ * ref_tree is the objectid of the referring root.
++ *
++ * dir_id is the directory in ref_tree where this root_id can be found.
++ *
++ * name is the name of root_id in that directory
++ *
++ * name_len is the length of name
++ */
++static int add_root(struct root_lookup *root_lookup,
++ u64 root_id, u64 ref_tree, u64 dir_id, char *name,
++ int name_len)
++{
++ struct root_info *ri;
++ struct rb_node *ret;
++ ri = malloc(sizeof(*ri) + name_len + 1);
++ if (!ri) {
++ printf("memory allocation failed\n");
++ exit(1);
++ }
++ memset(ri, 0, sizeof(*ri) + name_len + 1);
++ ri->path = NULL;
++ ri->dir_id = dir_id;
++ ri->root_id = root_id;
++ ri->ref_tree = ref_tree;
++ strncpy(ri->name, name, name_len);
++
++ ret = tree_insert(&root_lookup->root, root_id, ref_tree, &ri->rb_node);
++ if (ret) {
++ printf("failed to insert tree %llu\n", (unsigned long long)root_id);
++ exit(1);
++ }
++ return 0;
++}
++
++/*
++ * for a given root_info, search through the root_lookup tree to construct
++ * the full path name to it.
++ *
++ * This can't be called until all the root_info->path fields are filled
++ * in by lookup_ino_path
++ */
++static int resolve_root(struct root_lookup *rl, struct root_info *ri)
++{
++ u64 top_id;
++ char *full_path = NULL;
++ int len = 0;
++ struct root_info *found;
++
++ /*
++ * we go backwards from the root_info object and add pathnames
++ * from parent directories as we go.
++ */
++ found = ri;
++ while (1) {
++ char *tmp;
++ u64 next;
++ int add_len = strlen(found->path);
++
++ /* room for / and for null */
++ tmp = malloc(add_len + 2 + len);
++ if (full_path) {
++ memcpy(tmp + add_len + 1, full_path, len);
++ tmp[add_len] = '/';
++ memcpy(tmp, found->path, add_len);
++ tmp [add_len + len + 1] = '\0';
++ free(full_path);
++ full_path = tmp;
++ len += add_len + 1;
++ } else {
++ full_path = strdup(found->path);
++ len = add_len;
++ }
++
++ next = found->ref_tree;
++ /* if the ref_tree refers to ourselves, we're at the top */
++ if (next == found->root_id) {
++ top_id = next;
++ break;
++ }
++
++ /*
++ * if the ref_tree wasn't in our tree of roots, we're
++ * at the top
++ */
++ found = tree_search(&rl->root, next);
++ if (!found) {
++ top_id = next;
++ break;
++ }
++ }
++ printf("ID %llu top level %llu path %s\n", ri->root_id, top_id,
++ full_path);
++ free(full_path);
++ return 0;
++}
++
++/*
++ * for a single root_info, ask the kernel to give us a path name
++ * inside it's ref_root for the dir_id where it lives.
++ *
++ * This fills in root_info->path with the path to the directory and and
++ * appends this root's name.
++ */
++static int lookup_ino_path(int fd, struct root_info *ri)
++{
++ struct btrfs_ioctl_ino_lookup_args args;
++ int ret;
++
++ if (ri->path)
++ return 0;
++
++ memset(&args, 0, sizeof(args));
++ args.treeid = ri->ref_tree;
++ args.objectid = ri->dir_id;
++
++ ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
++ if (ret) {
++ fprintf(stderr, "ERROR: Failed to lookup path for root %llu\n",
++ (unsigned long long)ri->ref_tree);
++ return ret;
++ }
++
++ if (args.name[0]) {
++ /*
++ * we're in a subdirectory of ref_tree, the kernel ioctl
++ * puts a / in there for us
++ */
++ ri->path = malloc(strlen(ri->name) + strlen(args.name) + 1);
++ if (!ri->path) {
++ perror("malloc failed");
++ exit(1);
++ }
++ strcpy(ri->path, args.name);
++ strcat(ri->path, ri->name);
++ } else {
++ /* we're at the root of ref_tree */
++ ri->path = strdup(ri->name);
++ if (!ri->path) {
++ perror("strdup failed");
++ exit(1);
++ }
++ }
++ return 0;
++}
++
++/* finding the generation for a given path is a two step process.
++ * First we use the inode loookup routine to find out the root id
++ *
++ * Then we use the tree search ioctl to scan all the root items for a
++ * given root id and spit out the latest generation we can find
++ */
++static u64 find_root_gen(int fd)
++{
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/btrfs-progs/btrfs-progs.spec?r1=1.3&r2=1.4&f=u
More information about the pld-cvs-commit
mailing list