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/lockdep.h>
  18. #include <linux/atomic.h>
  19.  
  20. struct kobject;
  21. struct module;
  22. struct bin_attribute;
  23. enum kobj_ns_type;
  24.  
  25. struct attribute {
  26.         const char              *name;
  27.         umode_t                 mode;
  28. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  29.         bool                    ignore_lockdep:1;
  30.         struct lock_class_key   *key;
  31.         struct lock_class_key   skey;
  32. #endif
  33. };
  34. struct attribute_group {
  35.         const char              *name;
  36.         umode_t                 (*is_visible)(struct kobject *,
  37.                                               struct attribute *, int);
  38.         umode_t                 (*is_bin_visible)(struct kobject *,
  39.                                                   struct bin_attribute *, int);
  40.         struct attribute        **attrs;
  41.         struct bin_attribute    **bin_attrs;
  42. };
  43. #ifdef CONFIG_SYSFS
  44.  
  45. int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
  46. void sysfs_remove_dir(struct kobject *kobj);
  47. int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
  48.                                      const void *new_ns);
  49. int __must_check sysfs_move_dir_ns(struct kobject *kobj,
  50.                                    struct kobject *new_parent_kobj,
  51.                                    const void *new_ns);
  52. int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
  53.                                           const char *name);
  54. void sysfs_remove_mount_point(struct kobject *parent_kobj,
  55.                               const char *name);
  56.  
  57. int __must_check sysfs_create_file_ns(struct kobject *kobj,
  58.                                       const struct attribute *attr,
  59.                                       const void *ns);
  60. int __must_check sysfs_create_files(struct kobject *kobj,
  61.                                    const struct attribute **attr);
  62. int __must_check sysfs_chmod_file(struct kobject *kobj,
  63.                                   const struct attribute *attr, umode_t mode);
  64. void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
  65.                           const void *ns);
  66. bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
  67. void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
  68.  
  69. int __must_check sysfs_create_bin_file(struct kobject *kobj,
  70.                                        const struct bin_attribute *attr);
  71. void sysfs_remove_bin_file(struct kobject *kobj,
  72.                            const struct bin_attribute *attr);
  73.  
  74. int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
  75.                                    const char *name);
  76. int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
  77.                                           struct kobject *target,
  78.                                           const char *name);
  79. void sysfs_remove_link(struct kobject *kobj, const char *name);
  80.  
  81. int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
  82.                          const char *old_name, const char *new_name,
  83.                          const void *new_ns);
  84.  
  85. void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
  86.                         const char *name);
  87.  
  88. int __must_check sysfs_create_group(struct kobject *kobj,
  89.                                     const struct attribute_group *grp);
  90. int __must_check sysfs_create_groups(struct kobject *kobj,
  91.                                      const struct attribute_group **groups);
  92. int sysfs_update_group(struct kobject *kobj,
  93.                        const struct attribute_group *grp);
  94. void sysfs_remove_group(struct kobject *kobj,
  95.                         const struct attribute_group *grp);
  96. void sysfs_remove_groups(struct kobject *kobj,
  97.                          const struct attribute_group **groups);
  98. int sysfs_add_file_to_group(struct kobject *kobj,
  99.                         const struct attribute *attr, const char *group);
  100. void sysfs_remove_file_from_group(struct kobject *kobj,
  101.                         const struct attribute *attr, const char *group);
  102. int sysfs_merge_group(struct kobject *kobj,
  103.                        const struct attribute_group *grp);
  104. void sysfs_unmerge_group(struct kobject *kobj,
  105.                        const struct attribute_group *grp);
  106. int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
  107.                             struct kobject *target, const char *link_name);
  108. void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
  109.                                   const char *link_name);
  110. int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
  111.                                       struct kobject *target_kobj,
  112.                                       const char *target_name);
  113.  
  114. void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
  115.  
  116. int __must_check sysfs_init(void);
  117.  
  118. static inline void sysfs_enable_ns(struct kernfs_node *kn)
  119. {
  120.         return kernfs_enable_ns(kn);
  121. }
  122.  
  123. #else /* CONFIG_SYSFS */
  124.  
  125. static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
  126. {
  127.         return 0;
  128. }
  129.  
  130. static inline void sysfs_remove_dir(struct kobject *kobj)
  131. {
  132. }
  133.  
  134. static inline int sysfs_rename_dir_ns(struct kobject *kobj,
  135.                                       const char *new_name, const void *new_ns)
  136. {
  137.         return 0;
  138. }
  139.  
  140. static inline int sysfs_move_dir_ns(struct kobject *kobj,
  141.                                     struct kobject *new_parent_kobj,
  142.                                     const void *new_ns)
  143. {
  144.         return 0;
  145. }
  146.  
  147. static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
  148.                                            const char *name)
  149. {
  150.         return 0;
  151. }
  152.  
  153. static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
  154.                                             const char *name)
  155. {
  156. }
  157.  
  158. static inline int sysfs_create_file_ns(struct kobject *kobj,
  159.                                        const struct attribute *attr,
  160.                                        const void *ns)
  161. {
  162.         return 0;
  163. }
  164.  
  165. static inline int sysfs_create_files(struct kobject *kobj,
  166.                                     const struct attribute **attr)
  167. {
  168.         return 0;
  169. }
  170.  
  171. static inline int sysfs_chmod_file(struct kobject *kobj,
  172.                                    const struct attribute *attr, umode_t mode)
  173. {
  174.         return 0;
  175. }
  176.  
  177. static inline void sysfs_remove_file_ns(struct kobject *kobj,
  178.                                         const struct attribute *attr,
  179.                                         const void *ns)
  180. {
  181. }
  182.  
  183. static inline bool sysfs_remove_file_self(struct kobject *kobj,
  184.                                           const struct attribute *attr)
  185. {
  186.         return false;
  187. }
  188.  
  189. static inline void sysfs_remove_files(struct kobject *kobj,
  190.                                      const struct attribute **attr)
  191. {
  192. }
  193.  
  194. static inline int sysfs_create_bin_file(struct kobject *kobj,
  195.                                         const struct bin_attribute *attr)
  196. {
  197.         return 0;
  198. }
  199.  
  200. static inline void sysfs_remove_bin_file(struct kobject *kobj,
  201.                                          const struct bin_attribute *attr)
  202. {
  203. }
  204.  
  205. #define sysfs_create_link(kobj,target, name) (0)
  206.  
  207. static inline int sysfs_create_link_nowarn(struct kobject *kobj,
  208.                                            struct kobject *target,
  209.                                            const char *name)
  210. {
  211.         return 0;
  212. }
  213.  
  214. #define sysfs_remove_link(kobj, name)
  215.  
  216. static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
  217.                                        const char *old_name,
  218.                                        const char *new_name, const void *ns)
  219. {
  220.         return 0;
  221. }
  222.  
  223. static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
  224.                                      const char *name)
  225. {
  226. }
  227.  
  228. static inline int sysfs_create_group(struct kobject *kobj,
  229.                                      const struct attribute_group *grp)
  230. {
  231.         return 0;
  232. }
  233.  
  234. static inline int sysfs_create_groups(struct kobject *kobj,
  235.                                       const struct attribute_group **groups)
  236. {
  237.         return 0;
  238. }
  239.  
  240. static inline int sysfs_update_group(struct kobject *kobj,
  241.                                 const struct attribute_group *grp)
  242. {
  243.         return 0;
  244. }
  245.  
  246. static inline void sysfs_remove_group(struct kobject *kobj,
  247.                                       const struct attribute_group *grp)
  248. {
  249. }
  250.  
  251. static inline void sysfs_remove_groups(struct kobject *kobj,
  252.                                        const struct attribute_group **groups)
  253. {
  254. }
  255.  
  256. static inline int sysfs_add_file_to_group(struct kobject *kobj,
  257.                 const struct attribute *attr, const char *group)
  258. {
  259.         return 0;
  260. }
  261.  
  262. static inline void sysfs_remove_file_from_group(struct kobject *kobj,
  263.                 const struct attribute *attr, const char *group)
  264. {
  265. }
  266.  
  267. static inline int sysfs_merge_group(struct kobject *kobj,
  268.                        const struct attribute_group *grp)
  269. {
  270.         return 0;
  271. }
  272.  
  273. static inline void sysfs_unmerge_group(struct kobject *kobj,
  274.                        const struct attribute_group *grp)
  275. {
  276. }
  277.  
  278. static inline int sysfs_add_link_to_group(struct kobject *kobj,
  279.                 const char *group_name, struct kobject *target,
  280.                 const char *link_name)
  281. {
  282.         return 0;
  283. }
  284.  
  285. static inline void sysfs_remove_link_from_group(struct kobject *kobj,
  286.                 const char *group_name, const char *link_name)
  287. {
  288. }
  289.  
  290. static inline int __compat_only_sysfs_link_entry_to_kobj(
  291.         struct kobject *kobj,
  292.         struct kobject *target_kobj,
  293.         const char *target_name)
  294. {
  295.         return 0;
  296. }
  297.  
  298. static inline void sysfs_notify(struct kobject *kobj, const char *dir,
  299.                                 const char *attr)
  300. {
  301. }
  302.  
  303. static inline int __must_check sysfs_init(void)
  304. {
  305.         return 0;
  306. }
  307.  
  308. #endif /* CONFIG_SYSFS */
  309. #endif /* _SYSFS_H_ */
  310.