Tejun Heo | 6d66f5c | 2007-09-20 17:31:38 +0900 | [diff] [blame] | 1 | /* |
| 2 | * fs/sysfs/sysfs.h - sysfs internal header file |
| 3 | * |
| 4 | * Copyright (c) 2001-3 Patrick Mochel |
| 5 | * Copyright (c) 2007 SUSE Linux Products GmbH |
| 6 | * Copyright (c) 2007 Tejun Heo <teheo@suse.de> |
| 7 | * |
| 8 | * This file is released under the GPLv2. |
| 9 | */ |
| 10 | |
Tejun Heo | ae6621b | 2013-11-28 14:54:31 -0500 | [diff] [blame^] | 11 | #ifndef __SYSFS_INTERNAL_H |
| 12 | #define __SYSFS_INTERNAL_H |
David P. Quigley | ddd29ec | 2009-09-09 14:25:37 -0400 | [diff] [blame] | 13 | |
Tejun Heo | ae6621b | 2013-11-28 14:54:31 -0500 | [diff] [blame^] | 14 | #include "../kernfs/kernfs-internal.h" |
| 15 | #include <linux/sysfs.h> |
Tejun Heo | fb6896d | 2007-06-14 04:27:24 +0900 | [diff] [blame] | 16 | |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 17 | /* |
| 18 | * mount.c |
| 19 | */ |
Serge E. Hallyn | be867b1 | 2010-05-03 16:23:15 -0500 | [diff] [blame] | 20 | |
| 21 | /* |
Tejun Heo | c84a3b2 | 2013-11-23 18:01:46 -0500 | [diff] [blame] | 22 | * Each sb is associated with one namespace tag, currently the network |
| 23 | * namespace of the task which mounted this sysfs instance. If multiple |
| 24 | * tags become necessary, make the following an array and compare |
| 25 | * sysfs_dirent tag against every entry. |
Serge E. Hallyn | be867b1 | 2010-05-03 16:23:15 -0500 | [diff] [blame] | 26 | */ |
Eric W. Biederman | 9e7fdd2 | 2010-03-30 11:31:24 -0700 | [diff] [blame] | 27 | struct sysfs_super_info { |
Tejun Heo | c84a3b2 | 2013-11-23 18:01:46 -0500 | [diff] [blame] | 28 | void *ns; |
Eric W. Biederman | 9e7fdd2 | 2010-03-30 11:31:24 -0700 | [diff] [blame] | 29 | }; |
| 30 | #define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info)) |
Tejun Heo | 5122503 | 2007-06-14 04:27:25 +0900 | [diff] [blame] | 31 | extern struct sysfs_dirent sysfs_root; |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 32 | extern struct kmem_cache *sysfs_dir_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 34 | /* |
| 35 | * dir.c |
| 36 | */ |
Tejun Heo | 3007e99 | 2007-06-14 04:27:23 +0900 | [diff] [blame] | 37 | extern struct mutex sysfs_mutex; |
Tejun Heo | 0cae60f | 2013-10-30 10:28:36 -0400 | [diff] [blame] | 38 | extern spinlock_t sysfs_symlink_target_lock; |
Al Viro | 469796d | 2012-06-07 20:51:39 -0400 | [diff] [blame] | 39 | extern const struct dentry_operations sysfs_dentry_ops; |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 40 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 41 | extern const struct file_operations sysfs_dir_operations; |
Arjan van de Ven | c5ef1c4 | 2007-02-12 00:55:40 -0800 | [diff] [blame] | 42 | extern const struct inode_operations sysfs_dir_inode_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Eric W. Biederman | e72ceb8 | 2010-02-11 15:18:38 -0800 | [diff] [blame] | 44 | struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); |
| 45 | void sysfs_put_active(struct sysfs_dirent *sd); |
Tejun Heo | d69ac5a | 2013-09-18 17:15:35 -0400 | [diff] [blame] | 46 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt); |
Tejun Heo | d1c1459 | 2013-10-24 11:49:11 -0400 | [diff] [blame] | 47 | void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name); |
Tejun Heo | d69ac5a | 2013-09-18 17:15:35 -0400 | [diff] [blame] | 48 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, |
| 49 | struct sysfs_dirent *parent_sd); |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 50 | void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); |
Tejun Heo | b402d72 | 2007-06-14 04:27:21 +0900 | [diff] [blame] | 51 | |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 52 | struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); |
| 53 | |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 54 | /* |
| 55 | * inode.c |
| 56 | */ |
Eric W. Biederman | fac2622 | 2010-02-12 19:22:27 -0800 | [diff] [blame] | 57 | struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd); |
Al Viro | 01cd9fe | 2010-06-04 22:21:54 -0400 | [diff] [blame] | 58 | void sysfs_evict_inode(struct inode *inode); |
Al Viro | 10556cb | 2011-06-20 19:28:19 -0400 | [diff] [blame] | 59 | int sysfs_permission(struct inode *inode, int mask); |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 60 | int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); |
Greg Kroah-Hartman | 2c3a908 | 2013-08-21 16:40:05 -0700 | [diff] [blame] | 61 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, |
| 62 | struct kstat *stat); |
David P. Quigley | ddd29ec | 2009-09-09 14:25:37 -0400 | [diff] [blame] | 63 | int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
Greg Kroah-Hartman | 2c3a908 | 2013-08-21 16:40:05 -0700 | [diff] [blame] | 64 | size_t size, int flags); |
Peter Zijlstra | e0bf68d | 2007-10-16 23:25:46 -0700 | [diff] [blame] | 65 | int sysfs_inode_init(void); |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * file.c |
| 69 | */ |
Tejun Heo | c6fb449 | 2013-11-28 14:54:19 -0500 | [diff] [blame] | 70 | extern const struct file_operations kernfs_file_operations; |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 71 | |
| 72 | int sysfs_add_file(struct sysfs_dirent *dir_sd, |
Tejun Heo | a7dc66d | 2013-11-28 14:54:23 -0500 | [diff] [blame] | 73 | const struct attribute *attr, bool is_bin); |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 74 | |
Tejun Heo | 58292cbe | 2013-09-11 22:29:04 -0400 | [diff] [blame] | 75 | int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, |
Tejun Heo | a7dc66d | 2013-11-28 14:54:23 -0500 | [diff] [blame] | 76 | const struct attribute *attr, bool is_bin, |
Tejun Heo | 58292cbe | 2013-09-11 22:29:04 -0400 | [diff] [blame] | 77 | umode_t amode, const void *ns); |
Tejun Heo | 73d9714 | 2013-10-01 17:42:07 -0400 | [diff] [blame] | 78 | void sysfs_unmap_bin_file(struct sysfs_dirent *sd); |
| 79 | |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 80 | /* |
Tejun Heo | 59f6901 | 2007-09-20 16:05:10 +0900 | [diff] [blame] | 81 | * symlink.c |
| 82 | */ |
| 83 | extern const struct inode_operations sysfs_symlink_inode_operations; |
Rafael J. Wysocki | 0bb8f3d | 2013-01-25 21:51:13 +0100 | [diff] [blame] | 84 | int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, |
| 85 | const char *name); |
Tejun Heo | ae6621b | 2013-11-28 14:54:31 -0500 | [diff] [blame^] | 86 | |
| 87 | #endif /* __SYSFS_INTERNAL_H */ |