blob: 93c1910783fce57abdcaefab5e017d031a443600 [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 Heofb6896da2007-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/*
Tejun Heo59f69012007-09-20 16:05:10 +090055 * file.c
56 */
Tejun Heoc6fb4492013-11-28 14:54:19 -050057extern const struct file_operations kernfs_file_operations;
Tejun Heo59f69012007-09-20 16:05:10 +090058
59int sysfs_add_file(struct sysfs_dirent *dir_sd,
Tejun Heoa7dc66d2013-11-28 14:54:23 -050060 const struct attribute *attr, bool is_bin);
Tejun Heo59f69012007-09-20 16:05:10 +090061
Tejun Heo58292cbe2013-09-11 22:29:04 -040062int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
Tejun Heoa7dc66d2013-11-28 14:54:23 -050063 const struct attribute *attr, bool is_bin,
Tejun Heo58292cbe2013-09-11 22:29:04 -040064 umode_t amode, const void *ns);
Tejun Heo73d97142013-10-01 17:42:07 -040065void sysfs_unmap_bin_file(struct sysfs_dirent *sd);
66
Tejun Heo59f69012007-09-20 16:05:10 +090067/*
Tejun Heo59f69012007-09-20 16:05:10 +090068 * symlink.c
69 */
70extern const struct inode_operations sysfs_symlink_inode_operations;
Rafael J. Wysocki0bb8f3d2013-01-25 21:51:13 +010071int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target,
72 const char *name);
Tejun Heoae6621b2013-11-28 14:54:31 -050073
74#endif /* __SYSFS_INTERNAL_H */