I am trying to create chunk of vfs by kernel, this function create directories in my module. My code looks:
struct dentry *dentry;struct path path;int err, lookup;lookup = LOOKUP_DIRECTORY | LOOKUP_REVAL;mode |= S_IFDIR;dentry = kern_path_create(AT_FDCWD, name, &path, lookup);if (IS_ERR(dentry)){ return PTR_ERR(dentry);}err = vfs_mkdir(d_inode(path.dentry), dentry, mode);if (err){}done_path_create(&path, dentry);return err;
Before reboot
f1 <- dir
f2 <- dir (subdir f1)
f3 <- dir (subdir f1)
After reboot vfs tree disappear in struct dentry.
f1 <- dir
To get this output i used:
err = kern_path(FULL_MAIN_DIR_NAME, LOOKUP_FOLLOW, &tmp_root); printk(KERN_DEBUG "%s <- dir\n",tmp_root.dentry->d_name.name ); list_for_each_entry(tmp_dentry, &tmp_root.dentry->d_subdirs, d_child) { if (tmp_dentry->d_name.name) { printk(KERN_INFO "%s <- dir (subdir f1)\n", tmp_dentry->d_name.name); } }
But directories are still present in system, i can use them normally. In other hand, struct inode_operations attached to them are cleared too. Anybody know how to solve this problem?