[Btrfs-devel] I'm kind of confused...
Chris Mason
chris.mason at oracle.com
Thu Aug 16 16:56:33 PDT 2007
On Fri, 17 Aug 2007 06:24:52 +0800
"Yan Zheng" <yanzheng at 21cn.com> wrote:
> 2007/8/17, Josef Bacik <jbacik at redhat.com>:
> > Hello,
> >
> > I'm trying to get the name of the root item so I can populate sysfs
> > properly, and I'm doing this
> >
> >
> > dir_item = btrfs_item_ptr(l, path->slots[0], struct
> > btrfs_dir_item); name_ptr = (char *)(dir_item + 1);
> > ret = btrfs_sysfs_add_root(root, name_ptr,
> > btrfs_dir_name_len(dir_item));
> >
> > in btrfs_find_last_root after the btrfs_disk_key_to_cpu() part.
> > Problem is I'm getting a null name. Now here's the part I'm
> > confused about, we get to btrfs_find_last_root via
> > find_and_setup_root via btrfs_read_fs_root_no_radix. In
> > btrfs_find_last_root you have this
> >
> > ret = btrfs_search_slot(NULL, root, &search_key, path, 0,
> > 0); if (ret < 0)
> > goto out;
> > BUG_ON(ret == 0);
> >
> both search_key's flags and offset are set to the maximum value and
> it's intended no item has such large flags and offset. If there are
> items that have the objectid search for, the item at [path->slots[0]
> - 1] should be last one (the one has largest offset) .
> (btrfs_search_slot use binary search)
That's right. It may make more sense if you use debug-tree to print
out the metadata, that way you can see the keys and where they are.
The print-tree.c code in btrfs-progs should have enough examples to
pull the name out as well.
-chris
More information about the Btrfs-devel
mailing list