aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 16:02:57 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-17 11:59:15 -0500
commit2063d608f5110d120db60e896ec2c70c95bb7978 (patch)
tree45b02932c241cf2fe6a54ee4013a94221b2c2b8d /fs/kernfs/file.c
parentd0ae3d4347ee025cf23b850d484fe8593f7dd0f2 (diff)
kernfs: mark static names with KERNFS_STATIC_NAME
Because sysfs used struct attribute which are supposed to stay constant, sysfs didn't copy names when creating regular files. The specified string for name was supposed to stay constant. Such distinction isn't inherent for kernfs. kernfs_create_file[_ns]() should be able to take the same @name as kernfs_create_dir[_ns]() As there can be huge number of sysfs attributes, we still want to be able to use static names for sysfs attributes. This patch renames kernfs_create_file_ns_key() to __kernfs_create_file() and adds @name_is_static parameter so that the caller can explicitly indicate that @name can be used without copying. kernfs is updated to use KERNFS_STATIC_NAME to distinguish static and copied names. This patch doesn't introduce any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r--fs/kernfs/file.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 053cfd9a6a40..316604cc3a1c 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -762,7 +762,7 @@ const struct file_operations kernfs_file_fops = {
762}; 762};
763 763
764/** 764/**
765 * kernfs_create_file_ns_key - create a file 765 * __kernfs_create_file - kernfs internal function to create a file
766 * @parent: directory to create the file in 766 * @parent: directory to create the file in
767 * @name: name of the file 767 * @name: name of the file
768 * @mode: mode of the file 768 * @mode: mode of the file
@@ -770,23 +770,30 @@ const struct file_operations kernfs_file_fops = {
770 * @ops: kernfs operations for the file 770 * @ops: kernfs operations for the file
771 * @priv: private data for the file 771 * @priv: private data for the file
772 * @ns: optional namespace tag of the file 772 * @ns: optional namespace tag of the file
773 * @static_name: don't copy file name
773 * @key: lockdep key for the file's active_ref, %NULL to disable lockdep 774 * @key: lockdep key for the file's active_ref, %NULL to disable lockdep
774 * 775 *
775 * Returns the created node on success, ERR_PTR() value on error. 776 * Returns the created node on success, ERR_PTR() value on error.
776 */ 777 */
777struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent, 778struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
778 const char *name, 779 const char *name,
779 umode_t mode, loff_t size, 780 umode_t mode, loff_t size,
780 const struct kernfs_ops *ops, 781 const struct kernfs_ops *ops,
781 void *priv, const void *ns, 782 void *priv, const void *ns,
782 struct lock_class_key *key) 783 bool name_is_static,
784 struct lock_class_key *key)
783{ 785{
784 struct kernfs_addrm_cxt acxt; 786 struct kernfs_addrm_cxt acxt;
785 struct kernfs_node *kn; 787 struct kernfs_node *kn;
788 unsigned flags;
786 int rc; 789 int rc;
787 790
791 flags = KERNFS_FILE;
792 if (name_is_static)
793 flags |= KERNFS_STATIC_NAME;
794
788 kn = kernfs_new_node(kernfs_root(parent), name, 795 kn = kernfs_new_node(kernfs_root(parent), name,
789 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE); 796 (mode & S_IALLUGO) | S_IFREG, flags);
790 if (!kn) 797 if (!kn)
791 return ERR_PTR(-ENOMEM); 798 return ERR_PTR(-ENOMEM);
792 799