2007/8/17, Josef Bacik <jbacik@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)
Good luck.
> according to the comments you have for btrfs_search_slot, if we return 1 we
> didn't find that key and we need to insert it. There is a BUG_ON(ret
== 0), so
> I assume that means we don't want to find it, however, it acts like we
did find
> it, and obviously its working right b/c when I don't have this
hairbrained patch
> in place everything works fine. Is the commenting for btrfs_search_slot
wrong?
> If we return 1 does that mean we found it and if we return 0 we need to
insert
> it? I don't understand whats going on here. Also obviously I'm
doing the name
> thing wrong, so if you have any insight on how I should go about doing that
it
> would be helpful. Thank you,
>
> Josef
>
Best Regards
YZ