2013-11-29 03:54:31 +08:00
|
|
|
/*
|
|
|
|
* fs/kernfs/kernfs-internal.h - kernfs internal header file
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001-3 Patrick Mochel
|
|
|
|
* Copyright (c) 2007 SUSE Linux Products GmbH
|
|
|
|
* Copyright (c) 2007, 2013 Tejun Heo <teheo@suse.de>
|
|
|
|
*
|
|
|
|
* This file is released under the GPLv2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __KERNFS_INTERNAL_H
|
|
|
|
#define __KERNFS_INTERNAL_H
|
|
|
|
|
|
|
|
#include <linux/lockdep.h>
|
|
|
|
#include <linux/fs.h>
|
2013-11-29 03:54:33 +08:00
|
|
|
#include <linux/mutex.h>
|
2013-11-24 06:40:02 +08:00
|
|
|
#include <linux/xattr.h>
|
2013-11-29 03:54:31 +08:00
|
|
|
|
|
|
|
#include <linux/kernfs.h>
|
|
|
|
|
2013-12-12 03:11:55 +08:00
|
|
|
struct kernfs_iattrs {
|
2013-11-24 06:40:01 +08:00
|
|
|
struct iattr ia_iattr;
|
|
|
|
void *ia_secdata;
|
|
|
|
u32 ia_secdata_len;
|
2013-11-24 06:40:02 +08:00
|
|
|
|
|
|
|
struct simple_xattrs xattrs;
|
2013-11-29 03:54:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SD_DEACTIVATED_BIAS INT_MIN
|
|
|
|
|
2013-11-30 06:18:32 +08:00
|
|
|
/* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
|
2013-11-29 03:54:31 +08:00
|
|
|
|
2013-11-29 03:54:40 +08:00
|
|
|
/**
|
2013-12-12 03:11:53 +08:00
|
|
|
* kernfs_root - find out the kernfs_root a kernfs_node belongs to
|
|
|
|
* @kn: kernfs_node of interest
|
2013-11-29 03:54:40 +08:00
|
|
|
*
|
2013-12-12 03:11:53 +08:00
|
|
|
* Return the kernfs_root @kn belongs to.
|
2013-11-29 03:54:40 +08:00
|
|
|
*/
|
2013-12-12 03:11:53 +08:00
|
|
|
static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
|
2013-11-29 03:54:40 +08:00
|
|
|
{
|
|
|
|
/* if parent exists, it's always a dir; otherwise, @sd is a dir */
|
2013-12-12 03:11:54 +08:00
|
|
|
if (kn->parent)
|
|
|
|
kn = kn->parent;
|
|
|
|
return kn->dir.root;
|
2013-11-29 03:54:40 +08:00
|
|
|
}
|
|
|
|
|
2013-11-29 03:54:31 +08:00
|
|
|
/*
|
|
|
|
* Context structure to be used while adding/removing nodes.
|
|
|
|
*/
|
2013-12-12 03:11:55 +08:00
|
|
|
struct kernfs_addrm_cxt {
|
2013-12-12 03:11:53 +08:00
|
|
|
struct kernfs_node *removed;
|
2013-11-29 03:54:31 +08:00
|
|
|
};
|
|
|
|
|
2013-11-29 03:54:44 +08:00
|
|
|
/*
|
|
|
|
* mount.c
|
|
|
|
*/
|
2013-12-12 03:11:55 +08:00
|
|
|
struct kernfs_super_info {
|
2013-11-29 03:54:44 +08:00
|
|
|
/*
|
|
|
|
* The root associated with this super_block. Each super_block is
|
|
|
|
* identified by the root and ns it's associated with.
|
|
|
|
*/
|
|
|
|
struct kernfs_root *root;
|
|
|
|
|
|
|
|
/*
|
2013-12-12 03:11:53 +08:00
|
|
|
* Each sb is associated with one namespace tag, currently the
|
2013-12-12 03:11:55 +08:00
|
|
|
* network namespace of the task which mounted this kernfs
|
|
|
|
* instance. If multiple tags become necessary, make the following
|
|
|
|
* an array and compare kernfs_node tag against every entry.
|
2013-11-29 03:54:44 +08:00
|
|
|
*/
|
|
|
|
const void *ns;
|
|
|
|
};
|
2013-12-12 03:11:55 +08:00
|
|
|
#define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
|
2013-11-29 03:54:44 +08:00
|
|
|
|
|
|
|
extern struct kmem_cache *sysfs_dir_cachep;
|
|
|
|
|
2013-11-29 03:54:32 +08:00
|
|
|
/*
|
|
|
|
* inode.c
|
|
|
|
*/
|
2013-12-12 03:11:53 +08:00
|
|
|
struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
|
2013-11-29 03:54:32 +08:00
|
|
|
void sysfs_evict_inode(struct inode *inode);
|
|
|
|
int sysfs_permission(struct inode *inode, int mask);
|
|
|
|
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
|
|
|
|
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
|
|
|
|
struct kstat *stat);
|
|
|
|
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
|
|
|
|
size_t size, int flags);
|
2013-11-24 06:40:02 +08:00
|
|
|
int sysfs_removexattr(struct dentry *dentry, const char *name);
|
|
|
|
ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
|
|
|
|
size_t size);
|
|
|
|
ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size);
|
2013-11-29 03:54:43 +08:00
|
|
|
void sysfs_inode_init(void);
|
2013-11-29 03:54:32 +08:00
|
|
|
|
2013-11-29 03:54:33 +08:00
|
|
|
/*
|
|
|
|
* dir.c
|
|
|
|
*/
|
|
|
|
extern struct mutex sysfs_mutex;
|
|
|
|
extern const struct dentry_operations sysfs_dentry_ops;
|
|
|
|
extern const struct file_operations sysfs_dir_operations;
|
|
|
|
extern const struct inode_operations sysfs_dir_inode_operations;
|
|
|
|
|
2013-12-12 03:11:53 +08:00
|
|
|
struct kernfs_node *sysfs_get_active(struct kernfs_node *kn);
|
|
|
|
void sysfs_put_active(struct kernfs_node *kn);
|
2013-12-12 03:11:55 +08:00
|
|
|
void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt);
|
|
|
|
int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
|
2013-12-12 03:11:53 +08:00
|
|
|
struct kernfs_node *parent);
|
2013-12-12 03:11:55 +08:00
|
|
|
void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt);
|
2013-12-12 03:11:53 +08:00
|
|
|
struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,
|
|
|
|
const char *name, umode_t mode, int type);
|
2013-11-29 03:54:33 +08:00
|
|
|
|
2013-11-29 03:54:34 +08:00
|
|
|
/*
|
|
|
|
* file.c
|
|
|
|
*/
|
|
|
|
extern const struct file_operations kernfs_file_operations;
|
|
|
|
|
2013-12-12 03:11:53 +08:00
|
|
|
void sysfs_unmap_bin_file(struct kernfs_node *kn);
|
2013-11-29 03:54:34 +08:00
|
|
|
|
2013-11-29 03:54:35 +08:00
|
|
|
/*
|
|
|
|
* symlink.c
|
|
|
|
*/
|
|
|
|
extern const struct inode_operations sysfs_symlink_inode_operations;
|
|
|
|
|
2013-11-29 03:54:31 +08:00
|
|
|
#endif /* __KERNFS_INTERNAL_H */
|