blob: f8c936f31b37ddaeb30086e5deeccfd5e4bde70c [file] [log] [blame]
Tejun Heo6d66f5c2007-09-20 17:31:38 +09001/*
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 Heoae6621b2013-11-28 14:54:31 -050011#ifndef __SYSFS_INTERNAL_H
12#define __SYSFS_INTERNAL_H
David P. Quigleyddd29ec2009-09-09 14:25:37 -040013
Tejun Heoae6621b2013-11-28 14:54:31 -050014#include "../kernfs/kernfs-internal.h"
15#include <linux/sysfs.h>
Tejun Heofb6896d2007-06-14 04:27:24 +090016
Tejun Heo59f69012007-09-20 16:05:10 +090017/*
18 * mount.c
19 */
Serge E. Hallynbe867b12010-05-03 16:23:15 -050020
21/*
Tejun Heoc84a3b22013-11-23 18:01:46 -050022 * 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. Hallynbe867b12010-05-03 16:23:15 -050026 */
Eric W. Biederman9e7fdd22010-03-30 11:31:24 -070027struct sysfs_super_info {
Tejun Heoc84a3b22013-11-23 18:01:46 -050028 void *ns;
Eric W. Biederman9e7fdd22010-03-30 11:31:24 -070029};
30#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
Tejun Heo51225032007-06-14 04:27:25 +090031extern struct sysfs_dirent sysfs_root;
Christoph Lametere18b8902006-12-06 20:33:20 -080032extern struct kmem_cache *sysfs_dir_cachep;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Tejun Heo59f69012007-09-20 16:05:10 +090034/*
35 * dir.c
36 */
Tejun Heo3007e992007-06-14 04:27:23 +090037extern struct mutex sysfs_mutex;
Tejun Heo0cae60f2013-10-30 10:28:36 -040038extern spinlock_t sysfs_symlink_target_lock;
Al Viro469796d2012-06-07 20:51:39 -040039extern const struct dentry_operations sysfs_dentry_ops;
Tejun Heo59f69012007-09-20 16:05:10 +090040
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -080041extern const struct file_operations sysfs_dir_operations;
Arjan van de Venc5ef1c42007-02-12 00:55:40 -080042extern const struct inode_operations sysfs_dir_inode_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Eric W. Biedermane72ceb82010-02-11 15:18:38 -080044struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd);
45void sysfs_put_active(struct sysfs_dirent *sd);
Tejun Heod69ac5a2013-09-18 17:15:35 -040046void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt);
Tejun Heod1c14592013-10-24 11:49:11 -040047void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name);
Tejun Heod69ac5a2013-09-18 17:15:35 -040048int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
49 struct sysfs_dirent *parent_sd);
Tejun Heo59f69012007-09-20 16:05:10 +090050void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
Tejun Heob402d722007-06-14 04:27:21 +090051
Tejun Heo59f69012007-09-20 16:05:10 +090052struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type);
53
Tejun Heo59f69012007-09-20 16:05:10 +090054/*
55 * inode.c
56 */
Eric W. Biedermanfac26222010-02-12 19:22:27 -080057struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd);
Al Viro01cd9fe2010-06-04 22:21:54 -040058void sysfs_evict_inode(struct inode *inode);
Al Viro10556cb2011-06-20 19:28:19 -040059int sysfs_permission(struct inode *inode, int mask);
Tejun Heo59f69012007-09-20 16:05:10 +090060int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
Greg Kroah-Hartman2c3a9082013-08-21 16:40:05 -070061int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
62 struct kstat *stat);
David P. Quigleyddd29ec2009-09-09 14:25:37 -040063int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
Greg Kroah-Hartman2c3a9082013-08-21 16:40:05 -070064 size_t size, int flags);
Peter Zijlstrae0bf68d2007-10-16 23:25:46 -070065int sysfs_inode_init(void);
Tejun Heo59f69012007-09-20 16:05:10 +090066
67/*
68 * file.c
69 */
Tejun Heoc6fb4492013-11-28 14:54:19 -050070extern const struct file_operations kernfs_file_operations;
Tejun Heo59f69012007-09-20 16:05:10 +090071
72int sysfs_add_file(struct sysfs_dirent *dir_sd,
Tejun Heoa7dc66d2013-11-28 14:54:23 -050073 const struct attribute *attr, bool is_bin);
Tejun Heo59f69012007-09-20 16:05:10 +090074
Tejun Heo58292cbe2013-09-11 22:29:04 -040075int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
Tejun Heoa7dc66d2013-11-28 14:54:23 -050076 const struct attribute *attr, bool is_bin,
Tejun Heo58292cbe2013-09-11 22:29:04 -040077 umode_t amode, const void *ns);
Tejun Heo73d97142013-10-01 17:42:07 -040078void sysfs_unmap_bin_file(struct sysfs_dirent *sd);
79
Tejun Heo59f69012007-09-20 16:05:10 +090080/*
Tejun Heo59f69012007-09-20 16:05:10 +090081 * symlink.c
82 */
83extern const struct inode_operations sysfs_symlink_inode_operations;
Rafael J. Wysocki0bb8f3d2013-01-25 21:51:13 +010084int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target,
85 const char *name);
Tejun Heoae6621b2013-11-28 14:54:31 -050086
87#endif /* __SYSFS_INTERNAL_H */