# get btrfs filesystem id from kernel module

**URL:** <https://forums.suse.com/t/get-btrfs-filesystem-id-from-kernel-module/31833>\
**Category:** SLES Configure-Administer\
**Created:** [January 14, 2018, 10:03am UTC](https://forums.suse.com/t/get-btrfs-filesystem-id-from-kernel-module/31833 "2018-01-14T10:03:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilansch](https://avatars.discourse-cdn.com/v4/letter/i/90db22/32.png) [@ilansch](https://forums.suse.com/u/ilansch)\
**Post date:** [January 14, 2018, 10:03am UTC](https://forums.suse.com/t/get-btrfs-filesystem-id-from-kernel-module/31833/1 "2018-01-14T10:03:04Z")

</div>

I was wondering regarding to fetching the correct fsid on btrfs.  
fsid returned from stats give: 36h/54d  
and fsid returned from kernel code is 52.  
On kernel 11.3 3.0.101-0.47.71-default in order to get it, I do the  
following: convert inode struct to btrfs\_inode struct (use btrfsInode  
= BTRFS\_I(inode)), then from btrfs\_inode struct i go to root field,  
and from root i take anon\_dev or anon\_super.s\_dev.  
struct btrfs\_inode \*btrfsInode;  
btrfsInode = BTRFS\_I(inode);  
btrfsInode-\>root-\>anon\_super.s\_dev or  
btrfsInode-\>root-\>anon\_dev - depend on kernel.

But in kernel 3.12.28-4-default in order to get the fsid, i need to go  
to the inode → superblock → device id (inode-\>i\_sb-\>s\_dev)

And is there a proper way to get it ?

---

<div class="post-metadata">

**Author:** ![ilansch](https://avatars.discourse-cdn.com/v4/letter/i/90db22/32.png) [@ilansch](https://forums.suse.com/u/ilansch)\
**Post date:** [January 14, 2018, 1:57pm UTC](https://forums.suse.com/t/get-btrfs-filesystem-id-from-kernel-module/31833/2 "2018-01-14T13:57:41Z")

</div>

Thanks to btrfs mailing list,  
the proper way to get fsid is via: BTRFS\_I(inode)-\>root-\>fs\_info-\>fsid
