kernfs-internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * fs/kernfs/kernfs-internal.h - kernfs internal header file
  3. *
  4. * Copyright (c) 2001-3 Patrick Mochel
  5. * Copyright (c) 2007 SUSE Linux Products GmbH
  6. * Copyright (c) 2007, 2013 Tejun Heo <teheo@suse.de>
  7. *
  8. * This file is released under the GPLv2.
  9. */
  10. #ifndef __KERNFS_INTERNAL_H
  11. #define __KERNFS_INTERNAL_H
  12. #include <linux/lockdep.h>
  13. #include <linux/fs.h>
  14. #include <linux/mutex.h>
  15. #include <linux/xattr.h>
  16. #include <linux/kernfs.h>
  17. struct kernfs_iattrs {
  18. struct iattr ia_iattr;
  19. void *ia_secdata;
  20. u32 ia_secdata_len;
  21. struct simple_xattrs xattrs;
  22. };
  23. #define KN_DEACTIVATED_BIAS INT_MIN
  24. /* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
  25. /**
  26. * kernfs_root - find out the kernfs_root a kernfs_node belongs to
  27. * @kn: kernfs_node of interest
  28. *
  29. * Return the kernfs_root @kn belongs to.
  30. */
  31. static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
  32. {
  33. /* if parent exists, it's always a dir; otherwise, @sd is a dir */
  34. if (kn->parent)
  35. kn = kn->parent;
  36. return kn->dir.root;
  37. }
  38. /*
  39. * Context structure to be used while adding/removing nodes.
  40. */
  41. struct kernfs_addrm_cxt {
  42. struct kernfs_node *removed;
  43. };
  44. /*
  45. * mount.c
  46. */
  47. struct kernfs_super_info {
  48. /*
  49. * The root associated with this super_block. Each super_block is
  50. * identified by the root and ns it's associated with.
  51. */
  52. struct kernfs_root *root;
  53. /*
  54. * Each sb is associated with one namespace tag, currently the
  55. * network namespace of the task which mounted this kernfs
  56. * instance. If multiple tags become necessary, make the following
  57. * an array and compare kernfs_node tag against every entry.
  58. */
  59. const void *ns;
  60. };
  61. #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
  62. extern struct kmem_cache *kernfs_node_cache;
  63. /*
  64. * inode.c
  65. */
  66. struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
  67. void kernfs_evict_inode(struct inode *inode);
  68. int kernfs_iop_permission(struct inode *inode, int mask);
  69. int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
  70. int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
  71. struct kstat *stat);
  72. int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
  73. size_t size, int flags);
  74. int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
  75. ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
  76. size_t size);
  77. ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
  78. void kernfs_inode_init(void);
  79. /*
  80. * dir.c
  81. */
  82. extern struct mutex kernfs_mutex;
  83. extern const struct dentry_operations kernfs_dops;
  84. extern const struct file_operations kernfs_dir_fops;
  85. extern const struct inode_operations kernfs_dir_iops;
  86. struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
  87. void kernfs_put_active(struct kernfs_node *kn);
  88. void kernfs_addrm_start(struct kernfs_addrm_cxt *acxt);
  89. int kernfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn);
  90. void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt);
  91. struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
  92. const char *name, umode_t mode,
  93. unsigned flags);
  94. /*
  95. * file.c
  96. */
  97. extern const struct file_operations kernfs_file_fops;
  98. void kernfs_unmap_bin_file(struct kernfs_node *kn);
  99. /*
  100. * symlink.c
  101. */
  102. extern const struct inode_operations kernfs_symlink_iops;
  103. #endif /* __KERNFS_INTERNAL_H */