Subversion Repositories Kolibri OS

Rev

Rev 6934 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * sysfs.h - definitions for the device driver filesystem
  3.  *
  4.  * Copyright (c) 2001,2002 Patrick Mochel
  5.  * Copyright (c) 2004 Silicon Graphics, Inc.
  6.  * Copyright (c) 2007 SUSE Linux Products GmbH
  7.  * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
  8.  *
  9.  * Please see Documentation/filesystems/sysfs.txt for more information.
  10.  */
  11.  
  12. #ifndef _SYSFS_H_
  13. #define _SYSFS_H_
  14. #include <linux/compiler.h>
  15. #include <linux/errno.h>
  16. #include <linux/list.h>
  17. #include <linux/atomic.h>
  18.  
  19. struct kobject;
  20. struct module;
  21. struct bin_attribute;
  22. enum kobj_ns_type;
  23.  
  24. struct attribute {
  25.         const char              *name;
  26.         umode_t                 mode;
  27. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  28.         bool                    ignore_lockdep:1;
  29.         struct lock_class_key   *key;
  30.         struct lock_class_key   skey;
  31. #endif
  32. };
  33. #ifdef CONFIG_SYSFS
  34.  
  35. int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
  36. void sysfs_remove_dir(struct kobject *kobj);
  37. int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
  38.                                      const void *new_ns);
  39. int __must_check sysfs_move_dir_ns(struct kobject *kobj,
  40.                                    struct kobject *new_parent_kobj,
  41.                                    const void *new_ns);
  42. int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
  43.                                           const char *name);
  44. void sysfs_remove_mount_point(struct kobject *parent_kobj,
  45.                               const char *name);
  46.  
  47. int __must_check sysfs_create_file_ns(struct kobject *kobj,
  48.                                       const struct attribute *attr,
  49.                                       const void *ns);
  50. int __must_check sysfs_create_files(struct kobject *kobj,
  51.                                    const struct attribute **attr);
  52. int __must_check sysfs_chmod_file(struct kobject *kobj,
  53.                                   const struct attribute *attr, umode_t mode);
  54. void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
  55.                           const void *ns);
  56. bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
  57. void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
  58.  
  59. int __must_check sysfs_create_bin_file(struct kobject *kobj,
  60.                                        const struct bin_attribute *attr);
  61. void sysfs_remove_bin_file(struct kobject *kobj,
  62.                            const struct bin_attribute *attr);
  63.  
  64. int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
  65.                                    const char *name);
  66. int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
  67.                                           struct kobject *target,
  68.                                           const char *name);
  69. void sysfs_remove_link(struct kobject *kobj, const char *name);
  70.  
  71. int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
  72.                          const char *old_name, const char *new_name,
  73.                          const void *new_ns);
  74.  
  75. void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
  76.                         const char *name);
  77.  
  78. int __must_check sysfs_create_group(struct kobject *kobj,
  79.                                     const struct attribute_group *grp);
  80. int __must_check sysfs_create_groups(struct kobject *kobj,
  81.                                      const struct attribute_group **groups);
  82. int sysfs_update_group(struct kobject *kobj,
  83.                        const struct attribute_group *grp);
  84. void sysfs_remove_group(struct kobject *kobj,
  85.                         const struct attribute_group *grp);
  86. void sysfs_remove_groups(struct kobject *kobj,
  87.                          const struct attribute_group **groups);
  88. int sysfs_add_file_to_group(struct kobject *kobj,
  89.                         const struct attribute *attr, const char *group);
  90. void sysfs_remove_file_from_group(struct kobject *kobj,
  91.                         const struct attribute *attr, const char *group);
  92. int sysfs_merge_group(struct kobject *kobj,
  93.                        const struct attribute_group *grp);
  94. void sysfs_unmerge_group(struct kobject *kobj,
  95.                        const struct attribute_group *grp);
  96. int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
  97.                             struct kobject *target, const char *link_name);
  98. void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
  99.                                   const char *link_name);
  100. int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
  101.                                       struct kobject *target_kobj,
  102.                                       const char *target_name);
  103.  
  104. void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
  105.  
  106. int __must_check sysfs_init(void);
  107.  
  108. static inline void sysfs_enable_ns(struct kernfs_node *kn)
  109. {
  110.         return kernfs_enable_ns(kn);
  111. }
  112.  
  113. #else /* CONFIG_SYSFS */
  114.  
  115. static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
  116. {
  117.         return 0;
  118. }
  119.  
  120. static inline void sysfs_remove_dir(struct kobject *kobj)
  121. {
  122. }
  123.  
  124. static inline int sysfs_rename_dir_ns(struct kobject *kobj,
  125.                                       const char *new_name, const void *new_ns)
  126. {
  127.         return 0;
  128. }
  129.  
  130. static inline int sysfs_move_dir_ns(struct kobject *kobj,
  131.                                     struct kobject *new_parent_kobj,
  132.                                     const void *new_ns)
  133. {
  134.         return 0;
  135. }
  136.  
  137. static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
  138.                                            const char *name)
  139. {
  140.         return 0;
  141. }
  142.  
  143. static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
  144.                                             const char *name)
  145. {
  146. }
  147.  
  148. static inline int sysfs_create_file_ns(struct kobject *kobj,
  149.                                        const struct attribute *attr,
  150.                                        const void *ns)
  151. {
  152.         return 0;
  153. }
  154.  
  155. static inline int sysfs_create_files(struct kobject *kobj,
  156.                                     const struct attribute **attr)
  157. {
  158.         return 0;
  159. }
  160.  
  161. static inline int sysfs_chmod_file(struct kobject *kobj,
  162.                                    const struct attribute *attr, umode_t mode)
  163. {
  164.         return 0;
  165. }
  166.  
  167. static inline void sysfs_remove_file_ns(struct kobject *kobj,
  168.                                         const struct attribute *attr,
  169.                                         const void *ns)
  170. {
  171. }
  172.  
  173. static inline bool sysfs_remove_file_self(struct kobject *kobj,
  174.                                           const struct attribute *attr)
  175. {
  176.         return false;
  177. }
  178.  
  179. static inline void sysfs_remove_files(struct kobject *kobj,
  180.                                      const struct attribute **attr)
  181. {
  182. }
  183.  
  184. static inline int sysfs_create_bin_file(struct kobject *kobj,
  185.                                         const struct bin_attribute *attr)
  186. {
  187.         return 0;
  188. }
  189.  
  190. static inline void sysfs_remove_bin_file(struct kobject *kobj,
  191.                                          const struct bin_attribute *attr)
  192. {
  193. }
  194.  
  195. #define sysfs_create_link(kobj,target, name) (0)
  196.  
  197. static inline int sysfs_create_link_nowarn(struct kobject *kobj,
  198.                                            struct kobject *target,
  199.                                            const char *name)
  200. {
  201.         return 0;
  202. }
  203.  
  204. #define sysfs_remove_link(kobj, name)
  205.  
  206. static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
  207.                                        const char *old_name,
  208.                                        const char *new_name, const void *ns)
  209. {
  210.         return 0;
  211. }
  212.  
  213. static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
  214.                                      const char *name)
  215. {
  216. }
  217.  
  218.  
  219. static inline int sysfs_add_file_to_group(struct kobject *kobj,
  220.                 const struct attribute *attr, const char *group)
  221. {
  222.         return 0;
  223. }
  224.  
  225. static inline void sysfs_remove_file_from_group(struct kobject *kobj,
  226.                 const struct attribute *attr, const char *group)
  227. {
  228. }
  229.  
  230. static inline int sysfs_add_link_to_group(struct kobject *kobj,
  231.                 const char *group_name, struct kobject *target,
  232.                 const char *link_name)
  233. {
  234.         return 0;
  235. }
  236.  
  237. static inline void sysfs_remove_link_from_group(struct kobject *kobj,
  238.                 const char *group_name, const char *link_name)
  239. {
  240. }
  241.  
  242. static inline int __compat_only_sysfs_link_entry_to_kobj(
  243.         struct kobject *kobj,
  244.         struct kobject *target_kobj,
  245.         const char *target_name)
  246. {
  247.         return 0;
  248. }
  249.  
  250. static inline void sysfs_notify(struct kobject *kobj, const char *dir,
  251.                                 const char *attr)
  252. {
  253. }
  254.  
  255. static inline int __must_check sysfs_init(void)
  256. {
  257.         return 0;
  258. }
  259.  
  260. #endif /* CONFIG_SYSFS */
  261. #endif /* _SYSFS_H_ */
  262.