/** @file file_key_tools.h @brief Tools for managing file keys @details Copyright (c) 2024 Acronis International GmbH @author Denis Kopyrin ([email protected]) @since $Id: $ */ #pragma once #include "transport_protocol.h" #ifndef BPF_PROGRAM #include "compat.h" #include <linux/fs.h> #endif static inline void make_key_from_inode(file_key_t* key, const struct inode *inode) { key->ptr = (uint64_t) inode; key->ino = (uint64_t) KERNEL_READ(inode, i_ino); key->gen = (uint64_t) KERNEL_READ(inode, i_generation); key->dev = (uint64_t) KERNEL_READ2(inode, i_sb, s_dev); } static inline void make_key(file_key_t* key, const struct path *path) { return make_key_from_inode(key, KERNEL_READ2(path, dentry, d_inode)); } static inline int cmp_file_key(const file_key_t *k1, const file_key_t *k2) { if (k1->ptr != k2->ptr || k1->ino != k2->ino || k1->gen != k2->gen || k1->dev != k2->dev) { return -1; } return 0; }