kernfs.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * kernfs.h - pseudo filesystem decoupled from vfs locking
  3. *
  4. * This file is released under the GPLv2.
  5. */
  6. #ifndef __LINUX_KERNFS_H
  7. #define __LINUX_KERNFS_H
  8. #include <linux/kernel.h>
  9. #include <linux/err.h>
  10. struct file;
  11. struct iattr;
  12. struct sysfs_dirent;
  13. #ifdef CONFIG_SYSFS
  14. struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent,
  15. const char *name, void *priv,
  16. const void *ns);
  17. struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent,
  18. const char *name,
  19. struct sysfs_dirent *target);
  20. void kernfs_remove(struct sysfs_dirent *sd);
  21. int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name,
  22. const void *ns);
  23. int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent,
  24. const char *new_name, const void *new_ns);
  25. void kernfs_enable_ns(struct sysfs_dirent *sd);
  26. int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr);
  27. #else /* CONFIG_SYSFS */
  28. static inline struct sysfs_dirent *
  29. kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv,
  30. const void *ns)
  31. { return ERR_PTR(-ENOSYS); }
  32. static inline struct sysfs_dirent *
  33. kernfs_create_link(struct sysfs_dirent *parent, const char *name,
  34. struct sysfs_dirent *target)
  35. { return ERR_PTR(-ENOSYS); }
  36. static inline void kernfs_remove(struct sysfs_dirent *sd) { }
  37. static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent,
  38. const char *name, const void *ns)
  39. { return -ENOSYS; }
  40. static inline int kernfs_rename_ns(struct sysfs_dirent *sd,
  41. struct sysfs_dirent *new_parent,
  42. const char *new_name, const void *new_ns)
  43. { return -ENOSYS; }
  44. static inline void kernfs_enable_ns(struct sysfs_dirent *sd) { }
  45. static inline int kernfs_setattr(struct sysfs_dirent *sd,
  46. const struct iattr *iattr)
  47. { return -ENOSYS; }
  48. #endif /* CONFIG_SYSFS */
  49. static inline struct sysfs_dirent *
  50. kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv)
  51. {
  52. return kernfs_create_dir_ns(parent, name, priv, NULL);
  53. }
  54. static inline int kernfs_remove_by_name(struct sysfs_dirent *parent,
  55. const char *name)
  56. {
  57. return kernfs_remove_by_name_ns(parent, name, NULL);
  58. }
  59. #endif /* __LINUX_KERNFS_H */