kernfs-internal.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. /* +1 to avoid triggering overflow warning when negating it */
  24. #define KN_DEACTIVATED_BIAS (INT_MIN + 1)
  25. /* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
  26. /**
  27. * kernfs_root - find out the kernfs_root a kernfs_node belongs to
  28. * @kn: kernfs_node of interest
  29. *
  30. * Return the kernfs_root @kn belongs to.
  31. */
  32. static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
  33. {
  34. /* if parent exists, it's always a dir; otherwise, @sd is a dir */
  35. if (kn->parent)
  36. kn = kn->parent;
  37. return kn->dir.root;
  38. }
  39. /*
  40. * mount.c
  41. */
  42. struct kernfs_super_info {
  43. struct super_block *sb;
  44. /*
  45. * The root associated with this super_block. Each super_block is
  46. * identified by the root and ns it's associated with.
  47. */
  48. struct kernfs_root *root;
  49. /*
  50. * Each sb is associated with one namespace tag, currently the
  51. * network namespace of the task which mounted this kernfs
  52. * instance. If multiple tags become necessary, make the following
  53. * an array and compare kernfs_node tag against every entry.
  54. */
  55. const void *ns;
  56. /* anchored at kernfs_root->supers, protected by kernfs_mutex */
  57. struct list_head node;
  58. };
  59. #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
  60. static inline struct kernfs_node *kernfs_dentry_node(struct dentry *dentry)
  61. {
  62. if (d_really_is_negative(dentry))
  63. return NULL;
  64. return d_inode(dentry)->i_private;
  65. }
  66. extern const struct super_operations kernfs_sops;
  67. extern struct kmem_cache *kernfs_node_cache;
  68. /*
  69. * inode.c
  70. */
  71. extern const struct xattr_handler *kernfs_xattr_handlers[];
  72. void kernfs_evict_inode(struct inode *inode);
  73. int kernfs_iop_permission(struct inode *inode, int mask);
  74. int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
  75. int kernfs_iop_getattr(const struct path *path, struct kstat *stat,
  76. u32 request_mask, unsigned int query_flags);
  77. ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
  78. int __kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
  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. int kernfs_add_one(struct kernfs_node *kn);
  89. struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
  90. const char *name, umode_t mode,
  91. kuid_t uid, kgid_t gid,
  92. unsigned flags);
  93. struct kernfs_node *kernfs_find_and_get_node_by_ino(struct kernfs_root *root,
  94. unsigned int ino);
  95. /*
  96. * file.c
  97. */
  98. extern const struct file_operations kernfs_file_fops;
  99. void kernfs_drain_open_files(struct kernfs_node *kn);
  100. /*
  101. * symlink.c
  102. */
  103. extern const struct inode_operations kernfs_symlink_iops;
  104. #endif /* __KERNFS_INTERNAL_H */