kernfs-internal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. extern const struct super_operations kernfs_sops;
  61. extern struct kmem_cache *kernfs_node_cache;
  62. /*
  63. * inode.c
  64. */
  65. extern const struct xattr_handler *kernfs_xattr_handlers[];
  66. void kernfs_evict_inode(struct inode *inode);
  67. int kernfs_iop_permission(struct inode *inode, int mask);
  68. int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
  69. int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
  70. struct kstat *stat);
  71. ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
  72. /*
  73. * dir.c
  74. */
  75. extern struct mutex kernfs_mutex;
  76. extern const struct dentry_operations kernfs_dops;
  77. extern const struct file_operations kernfs_dir_fops;
  78. extern const struct inode_operations kernfs_dir_iops;
  79. struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
  80. void kernfs_put_active(struct kernfs_node *kn);
  81. int kernfs_add_one(struct kernfs_node *kn);
  82. struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
  83. const char *name, umode_t mode,
  84. unsigned flags);
  85. /*
  86. * file.c
  87. */
  88. extern const struct file_operations kernfs_file_fops;
  89. void kernfs_unmap_bin_file(struct kernfs_node *kn);
  90. /*
  91. * symlink.c
  92. */
  93. extern const struct inode_operations kernfs_symlink_iops;
  94. #endif /* __KERNFS_INTERNAL_H */