[Btrfs-devel] I'm kind of confused...

Josef Bacik jbacik at redhat.com
Thu Aug 16 14:22:12 PDT 2007


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);

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



More information about the Btrfs-devel mailing list