5
This commit is contained in:
parent
4f815c3ee1
commit
e6ebf985b9
15
libfs.c
15
libfs.c
@ -1,5 +1,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fs_context.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/namei.h>
|
||||
@ -36,6 +38,8 @@ static struct inode *books_inode;
|
||||
static const struct inode_operations fs_dir_iops;
|
||||
DEFINE_HASHTABLE(link_table, 6);
|
||||
|
||||
static const struct inode_operations custom_file_inode_operations = {};
|
||||
|
||||
struct link_entry {
|
||||
struct hlist_node node;
|
||||
struct dentry *link;
|
||||
@ -113,8 +117,13 @@ static int books_create(struct user_namespace *ns, struct inode *dir,
|
||||
return -ENOMEM;
|
||||
|
||||
inode->i_uid = current_fsuid();
|
||||
// inode->i_op = &simple_file_inode_operations;
|
||||
inode->i_op = &custom_file_inode_operations;
|
||||
inode->i_fop = &custom_file_ops;
|
||||
d_instantiate(dentry, inode);
|
||||
mark_inode_dirty(inode);
|
||||
|
||||
logf("books_create: created file %s (ino=%lu)", dentry->d_name.name, inode->i_ino);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -352,6 +361,9 @@ static int fill_super(struct super_block *sb, void *data, int silent) {
|
||||
if (!books)
|
||||
return -ENOMEM;
|
||||
d_add(books, books_inode);
|
||||
inc_nlink(root_inode); // ✅ важно!
|
||||
inc_nlink(books_inode); // ✅ важно!
|
||||
logf("fill_super: books directory instantiated");
|
||||
|
||||
// authors
|
||||
struct inode *authors_inode = get_inode(sb, S_IFDIR | MODE_AUTHORS);
|
||||
@ -364,6 +376,9 @@ static int fill_super(struct super_block *sb, void *data, int silent) {
|
||||
if (!authors)
|
||||
return -ENOMEM;
|
||||
d_add(authors, authors_inode);
|
||||
inc_nlink(root_inode); // ✅ важно!
|
||||
inc_nlink(authors_inode); // ✅ важно!
|
||||
logf("fill_super: authors directory instantiated");
|
||||
|
||||
logf("fill_super: books and authors created");
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user