Re: [PATCH 2/9] fs: add an argument-less alloc_anon_inode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09.03.21 16:53, Christoph Hellwig wrote:
Add a new alloc_anon_inode helper that allocates an inode on
the anon_inode file system.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  fs/anon_inodes.c            | 15 +++++++++++++--
  include/linux/anon_inodes.h |  1 +
  2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 4745fc37014332..b6a8ea71920bc3 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -63,7 +63,7 @@ static struct inode *anon_inode_make_secure_inode(
  	const struct qstr qname = QSTR_INIT(name, strlen(name));
  	int error;
- inode = alloc_anon_inode_sb(anon_inode_mnt->mnt_sb);
+	inode = alloc_anon_inode();
  	if (IS_ERR(inode))
  		return inode;
  	inode->i_flags &= ~S_PRIVATE;
@@ -225,13 +225,24 @@ int anon_inode_getfd_secure(const char *name, const struct file_operations *fops
  }
  EXPORT_SYMBOL_GPL(anon_inode_getfd_secure);
+/**
+ * alloc_anon_inode - create a new anonymous inode
+ *
+ * Create an inode on the anon_inode file system and return it.
+ */
+struct inode *alloc_anon_inode(void)
+{
+	return alloc_anon_inode_sb(anon_inode_mnt->mnt_sb);
+}
+EXPORT_SYMBOL_GPL(alloc_anon_inode);
+
  static int __init anon_inode_init(void)
  {
  	anon_inode_mnt = kern_mount(&anon_inode_fs_type);
  	if (IS_ERR(anon_inode_mnt))
  		panic("anon_inode_init() kernel mount failed (%ld)\n", PTR_ERR(anon_inode_mnt));
- anon_inode_inode = alloc_anon_inode_sb(anon_inode_mnt->mnt_sb);
+	anon_inode_inode = alloc_anon_inode();
  	if (IS_ERR(anon_inode_inode))
  		panic("anon_inode_init() inode allocation failed (%ld)\n", PTR_ERR(anon_inode_inode));
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h
index 71881a2b6f7860..b5ae9a6eda9923 100644
--- a/include/linux/anon_inodes.h
+++ b/include/linux/anon_inodes.h
@@ -21,6 +21,7 @@ int anon_inode_getfd_secure(const char *name,
  			    const struct file_operations *fops,
  			    void *priv, int flags,
  			    const struct inode *context_inode);
+struct inode *alloc_anon_inode(void);
#endif /* _LINUX_ANON_INODES_H */

Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>

--
Thanks,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux