Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933432AbbLHJvy (ORCPT ); Tue, 8 Dec 2015 04:51:54 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34463 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933366AbbLHJvZ (ORCPT ); Tue, 8 Dec 2015 04:51:25 -0500 From: Roman Pen Cc: Roman Pen , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/3] debugfs: make create directory logic more generic Date: Tue, 8 Dec 2015 10:51:04 +0100 Message-Id: <1449568266-17404-2-git-send-email-r.peniaev@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449568266-17404-1-git-send-email-r.peniaev@gmail.com> References: <1449568266-17404-1-git-send-email-r.peniaev@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3771 Lines: 92 Now __create_dir() accepts inode operations and private data. I will use this generic call in next path to create directory with temporary files. Signed-off-by: Roman Pen Cc: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org --- fs/debugfs/inode.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b7fcc0d..f1c4f80 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -388,25 +388,9 @@ struct dentry *debugfs_create_file_size(const char *name, umode_t mode, } EXPORT_SYMBOL_GPL(debugfs_create_file_size); -/** - * debugfs_create_dir - create a directory in the debugfs filesystem - * @name: a pointer to a string containing the name of the directory to - * create. - * @parent: a pointer to the parent dentry for this file. This should be a - * directory dentry if set. If this parameter is NULL, then the - * directory will be created in the root of the debugfs filesystem. - * - * This function creates a directory in debugfs with the given name. - * - * This function will return a pointer to a dentry if it succeeds. This - * pointer must be passed to the debugfs_remove() function when the file is - * to be removed (no automatic cleanup happens if your module is unloaded, - * you are responsible here.) If an error occurs, %NULL will be returned. - * - * If debugfs is not enabled in the kernel, the value -%ENODEV will be - * returned. - */ -struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) +static struct dentry *__create_dir(const char *name, + struct dentry *parent, void *data, + const struct inode_operations *i_op) { struct dentry *dentry = start_creating(name, parent); struct inode *inode; @@ -419,7 +403,8 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) return failed_creating(dentry); inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; - inode->i_op = &simple_dir_inode_operations; + inode->i_op = i_op; + inode->i_private = data; inode->i_fop = &simple_dir_operations; /* directory inodes start off with i_nlink == 2 (for "." entry) */ @@ -429,6 +414,29 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) fsnotify_mkdir(d_inode(dentry->d_parent), dentry); return end_creating(dentry); } + +/** + * debugfs_create_dir - create a directory in the debugfs filesystem + * @name: a pointer to a string containing the name of the directory to + * create. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is NULL, then the + * directory will be created in the root of the debugfs filesystem. + * + * This function creates a directory in debugfs with the given name. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -%ENODEV will be + * returned. + */ +struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) +{ + return __create_dir(name, parent, NULL, &simple_dir_inode_operations); +} EXPORT_SYMBOL_GPL(debugfs_create_dir); /** -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/