]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
convert debugfs
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 13 May 2024 21:19:05 +0000 (15:19 -0600)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 16 Nov 2025 06:35:03 +0000 (01:35 -0500)
similar to tracefs - simulation of normal codepath for creation,
simple_recursive_removal() for removal.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/debugfs/inode.c

index 661a99a7dfbe26cd2d723e7ed90756b92eab4821..682120fdbb17bb4d8f2c372df6f09925181cd9c9 100644 (file)
@@ -329,7 +329,7 @@ static struct file_system_type debug_fs_type = {
        .name =         "debugfs",
        .init_fs_context = debugfs_init_fs_context,
        .parameters =   debugfs_param_specs,
-       .kill_sb =      kill_litter_super,
+       .kill_sb =      kill_anon_super,
 };
 MODULE_ALIAS_FS("debugfs");
 
@@ -405,16 +405,15 @@ static struct dentry *debugfs_start_creating(const char *name,
 
 static struct dentry *failed_creating(struct dentry *dentry)
 {
-       inode_unlock(d_inode(dentry->d_parent));
-       dput(dentry);
+       simple_done_creating(dentry);
        simple_release_fs(&debugfs_mount, &debugfs_mount_count);
        return ERR_PTR(-ENOMEM);
 }
 
 static struct dentry *end_creating(struct dentry *dentry)
 {
-       inode_unlock(d_inode(dentry->d_parent));
-       return dentry;
+       simple_done_creating(dentry);
+       return dentry; // borrowed
 }
 
 static struct dentry *__debugfs_create_file(const char *name, umode_t mode,
@@ -456,7 +455,7 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode,
        DEBUGFS_I(inode)->raw = real_fops;
        DEBUGFS_I(inode)->aux = (void *)aux;
 
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        fsnotify_create(d_inode(dentry->d_parent), dentry);
        return end_creating(dentry);
 }
@@ -602,7 +601,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
 
        /* directory inodes start off with i_nlink == 2 (for "." entry) */
        inc_nlink(inode);
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        inc_nlink(d_inode(dentry->d_parent));
        fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
        return end_creating(dentry);
@@ -649,7 +648,7 @@ struct dentry *debugfs_create_automount(const char *name,
        DEBUGFS_I(inode)->automount = f;
        /* directory inodes start off with i_nlink == 2 (for "." entry) */
        inc_nlink(inode);
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        inc_nlink(d_inode(dentry->d_parent));
        fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
        return end_creating(dentry);
@@ -704,7 +703,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
        inode->i_mode = S_IFLNK | S_IRWXUGO;
        inode->i_op = &debugfs_symlink_inode_operations;
        inode->i_link = link;
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        return end_creating(dentry);
 }
 EXPORT_SYMBOL_GPL(debugfs_create_symlink);