kernfs-internal.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. * mount.c
  40. */
  41. struct kernfs_super_info {
  42. /*
  43. * The root associated with this super_block. Each super_block is
  44. * identified by the root and ns it's associated with.
  45. */
  46. struct kernfs_root *root;
  47. /*
  48. * Each sb is associated with one namespace tag, currently the
  49. * network namespace of the task which mounted this kernfs
  50. * instance. If multiple tags become necessary, make the following
  51. * an array and compare kernfs_node tag against every entry.
  52. */
  53. const void *ns;
  54. };
  55. #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
  56. extern struct kmem_cache *kernfs_node_cache;
  57. /*
  58. * inode.c
  59. */
  60. struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
  61. void kernfs_evict_inode(struct inode *inode);
  62. int kernfs_iop_permission(struct inode *inode, int mask);
  63. int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
  64. int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
  65. struct kstat *stat);
  66. int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
  67. size_t size, int flags);
  68. int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
  69. ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
  70. size_t size);
  71. ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
  72. void kernfs_inode_init(void);
  73. /*
  74. * dir.c
  75. */
  76. extern struct mutex kernfs_mutex;
  77. extern const struct dentry_operations kernfs_dops;
  78. extern const struct file_operations kernfs_dir_fops;
  79. extern const struct inode_operations kernfs_dir_iops;
  80. struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
  81. void kernfs_put_active(struct kernfs_node *kn);
  82. int kernfs_add_one(struct kernfs_node *kn);
  83. struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
  84. const char *name, umode_t mode,
  85. unsigned flags);
  86. /*
  87. * file.c
  88. */
  89. extern const struct file_operations kernfs_file_fops;
  90. void kernfs_unmap_bin_file(struct kernfs_node *kn);
  91. /*
  92. * symlink.c
  93. */
  94. extern const struct inode_operations kernfs_symlink_iops;
  95. #endif /* __KERNFS_INTERNAL_H */