Skip to content

Commit 221a623

Browse files
committed
feat(ebpf): add support for XFS
1 parent f67e121 commit 221a623

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

fact-ebpf/src/bpf/inode.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#define BTRFS_SUPER_MAGIC 0x9123683E
1414
#define BTRFS_MAGIC 0x4D5F53665248425FULL
1515

16+
#define XFS_SUPER_MAGIC 0x58465342
17+
1618
/**
1719
* Retrieve the inode and device numbers and return them as a new key.
1820
*
@@ -35,6 +37,15 @@ __always_inline static inode_key_t inode_to_key(struct inode* inode) {
3537

3638
unsigned long magic = inode->i_sb->s_magic;
3739
switch (magic) {
40+
case XFS_SUPER_MAGIC: {
41+
// XFS uses a major at bit 20 in kernel space, but puts it at bit
42+
// 8 in userspace.
43+
uint64_t major = inode->i_sb->s_dev >> 20;
44+
uint64_t minor = inode->i_sb->s_dev & 0xFFFFF;
45+
key.dev = (major << 8) | minor;
46+
key.inode = inode->i_ino;
47+
break;
48+
}
3849
case BTRFS_MAGIC:
3950
case BTRFS_SUPER_MAGIC:
4051
if (bpf_core_type_exists(struct btrfs_inode)) {

0 commit comments

Comments
 (0)