Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 343904 Details for
Bug 464054
sys-fs/btrfs-progs - subvol get-default does not work
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
working patch adapted from upstrem patch (removed fizz)
btrfs-progs-0.19.11_set-stubvolume.patch (text/plain), 3.37 KB, created by
Ulf Dambacher
on 2013-04-01 08:42:14 UTC
(
hide
)
Description:
working patch adapted from upstrem patch (removed fizz)
Filename:
MIME Type:
Creator:
Ulf Dambacher
Created:
2013-04-01 08:42:14 UTC
Size:
3.37 KB
patch
obsolete
>diff -ur btrfs-progs-0.19.11.orig/btrfs-list.c btrfs-progs-0.19.11/btrfs-list.c >--- btrfs-progs-0.19.11.orig/btrfs-list.c 2012-07-08 18:30:47.000000000 +0200 >+++ btrfs-progs-0.19.11/btrfs-list.c 2013-04-01 09:14:41.428074096 +0200 >@@ -553,6 +553,60 @@ > return full; > } > >+static int get_default_subvolid(int fd, u64 *default_id) >+{ >+ struct btrfs_ioctl_search_args args; >+ struct btrfs_ioctl_search_key *sk = &args.key; >+ struct btrfs_ioctl_search_header *sh; >+ u64 found = 0; >+ int ret; >+ >+ memset(&args, 0, sizeof(args)); >+ >+ /* >+ * search for a dir item with a name 'default' in the tree of >+ * tree roots, it should point us to a default root >+ */ >+ sk->tree_id = 1; >+ >+ /* don't worry about ancient format and request only one item */ >+ sk->nr_items = 1; >+ >+ sk->max_objectid = BTRFS_ROOT_TREE_DIR_OBJECTID; >+ sk->min_objectid = BTRFS_ROOT_TREE_DIR_OBJECTID; >+ sk->max_type = BTRFS_DIR_ITEM_KEY; >+ sk->min_type = BTRFS_DIR_ITEM_KEY; >+ sk->max_offset = (u64)-1; >+ sk->max_transid = (u64)-1; >+ >+ ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); >+ if (ret < 0) >+ return ret; >+ >+ /* the ioctl returns the number of items it found in nr_items */ >+ if (sk->nr_items == 0) >+ goto out; >+ >+ sh = (struct btrfs_ioctl_search_header *)args.buf; >+ >+ if (sh->type == BTRFS_DIR_ITEM_KEY) { >+ struct btrfs_dir_item *di; >+ int name_len; >+ char *name; >+ >+ di = (struct btrfs_dir_item *)(sh + 1); >+ name_len = btrfs_stack_dir_name_len(di); >+ name = (char *)(di + 1); >+ >+ if (!strncmp("default", name, name_len)) >+ found = btrfs_disk_key_objectid(&di->location); >+ } >+ >+out: >+ *default_id = found; >+ return 0; >+} >+ > static int __list_subvol_search(int fd, struct root_lookup *root_lookup) > { > int ret; >@@ -668,12 +722,32 @@ > return 0; > } > >-int list_subvols(int fd, int print_parent) >+int list_subvols(int fd, int print_parent, int get_default) > { > struct root_lookup root_lookup; > struct rb_node *n; >+ u64 default_id; > int ret; > >+ if (get_default) { >+ ret = get_default_subvolid(fd, &default_id); >+ if (ret) { >+ fprintf(stderr, "ERROR: can't perform the search - %s\n", >+ strerror(errno)); >+ return ret; >+ } >+ if (default_id == 0) { >+ fprintf(stderr, "ERROR: 'default' dir item not found\n"); >+ return ret; >+ } >+ >+ /* no need to resolve roots if FS_TREE is default */ >+ if (default_id == BTRFS_FS_TREE_OBJECTID) { >+ printf("ID 5 (FS_TREE)\n"); >+ return ret; >+ } >+ } >+ > ret = __list_subvol_search(fd, &root_lookup); > if (ret) { > fprintf(stderr, "ERROR: can't perform the search - %s\n", >@@ -700,7 +774,14 @@ > u64 level; > u64 parent_id; > char *path; >+ > entry = rb_entry(n, struct root_info, rb_node); >+ >+ if (get_default && entry->root_id != default_id) { >+ n = rb_prev(n); >+ continue; >+ } >+ > resolve_root(&root_lookup, entry, &root_id, &parent_id, > &level, &path); > if (print_parent) { >diff -ur btrfs-progs-0.19.11.orig/ctree.h btrfs-progs-0.19.11/ctree.h >--- btrfs-progs-0.19.11.orig/ctree.h 2012-07-08 18:30:47.000000000 +0200 >+++ btrfs-progs-0.19.11/ctree.h 2013-04-01 09:07:34.826066310 +0200 >@@ -1431,6 +1431,8 @@ > BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16); > BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64); > >+BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, name_len, 16); >+ > static inline void btrfs_dir_item_key(struct extent_buffer *eb, > struct btrfs_dir_item *item, > struct btrfs_disk_key *key)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 464054
: 343904