Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
sysfs.h File Reference
#include <linux/lockdep.h>
#include <linux/kobject_ns.h>
#include <linux/fs.h>
#include <linux/rbtree.h>

Go to the source code of this file.

Data Structures

struct  sysfs_elem_dir
 
struct  sysfs_elem_symlink
 
struct  sysfs_elem_attr
 
struct  sysfs_elem_bin_attr
 
struct  sysfs_inode_attrs
 
struct  sysfs_dirent
 
struct  sysfs_addrm_cxt
 
struct  sysfs_super_info
 

Macros

#define SD_DEACTIVATED_BIAS   INT_MIN
 
#define SYSFS_TYPE_MASK   0x00ff
 
#define SYSFS_DIR   0x0001
 
#define SYSFS_KOBJ_ATTR   0x0002
 
#define SYSFS_KOBJ_BIN_ATTR   0x0004
 
#define SYSFS_KOBJ_LINK   0x0008
 
#define SYSFS_COPY_NAME   (SYSFS_DIR | SYSFS_KOBJ_LINK)
 
#define SYSFS_ACTIVE_REF   (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR)
 
#define SYSFS_NS_TYPE_MASK   0xf00
 
#define SYSFS_NS_TYPE_SHIFT   8
 
#define SYSFS_FLAG_MASK   ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK)
 
#define SYSFS_FLAG_REMOVED   0x02000
 
#define sysfs_dirent_init_lockdep(sd)   do {} while(0)
 
#define sysfs_info(SB)   ((struct sysfs_super_info *)(SB->s_fs_info))
 
#define sysfs_get(sd)   __sysfs_get(sd)
 
#define sysfs_put(sd)   __sysfs_put(sd)
 

Functions

struct dentrysysfs_get_dentry (struct sysfs_dirent *sd)
 
struct sysfs_direntsysfs_get_active (struct sysfs_dirent *sd)
 
void sysfs_put_active (struct sysfs_dirent *sd)
 
void sysfs_addrm_start (struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *parent_sd)
 
int __sysfs_add_one (struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
 
int sysfs_add_one (struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
 
void sysfs_remove_one (struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
 
void sysfs_addrm_finish (struct sysfs_addrm_cxt *acxt)
 
struct sysfs_direntsysfs_find_dirent (struct sysfs_dirent *parent_sd, const void *ns, const unsigned char *name)
 
struct sysfs_direntsysfs_get_dirent (struct sysfs_dirent *parent_sd, const void *ns, const unsigned char *name)
 
struct sysfs_direntsysfs_new_dirent (const char *name, umode_t mode, int type)
 
void release_sysfs_dirent (struct sysfs_dirent *sd)
 
int sysfs_create_subdir (struct kobject *kobj, const char *name, struct sysfs_dirent **p_sd)
 
void sysfs_remove_subdir (struct sysfs_dirent *sd)
 
int sysfs_rename (struct sysfs_dirent *sd, struct sysfs_dirent *new_parent_sd, const void *ns, const char *new_name)
 
struct inodesysfs_get_inode (struct super_block *sb, struct sysfs_dirent *sd)
 
void sysfs_evict_inode (struct inode *inode)
 
int sysfs_sd_setattr (struct sysfs_dirent *sd, struct iattr *iattr)
 
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)
 
int sysfs_hash_and_remove (struct sysfs_dirent *dir_sd, const void *ns, const char *name)
 
int sysfs_inode_init (void)
 
int sysfs_add_file (struct sysfs_dirent *dir_sd, const struct attribute *attr, int type)
 
int sysfs_add_file_mode (struct sysfs_dirent *dir_sd, const struct attribute *attr, int type, umode_t amode)
 
void unmap_bin_file (struct sysfs_dirent *attr_sd)
 

Variables

struct sysfs_dirent sysfs_root
 
struct kmem_cachesysfs_dir_cachep
 
struct mutex sysfs_mutex
 
spinlock_t sysfs_assoc_lock
 
struct dentry_operations sysfs_dentry_ops
 
struct file_operations sysfs_dir_operations
 
struct inode_operations sysfs_dir_inode_operations
 
struct file_operations sysfs_file_operations
 
struct file_operations bin_fops
 
struct inode_operations sysfs_symlink_inode_operations
 

Macro Definition Documentation

#define SD_DEACTIVATED_BIAS   INT_MIN

Definition at line 86 of file sysfs.h.

#define SYSFS_ACTIVE_REF   (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR)

Definition at line 94 of file sysfs.h.

#define SYSFS_COPY_NAME   (SYSFS_DIR | SYSFS_KOBJ_LINK)

Definition at line 93 of file sysfs.h.

#define SYSFS_DIR   0x0001

Definition at line 89 of file sysfs.h.

#define sysfs_dirent_init_lockdep (   sd)    do {} while(0)

Definition at line 128 of file sysfs.h.

#define SYSFS_FLAG_MASK   ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK)

Definition at line 100 of file sysfs.h.

#define SYSFS_FLAG_REMOVED   0x02000

Definition at line 101 of file sysfs.h.

#define sysfs_get (   sd)    __sysfs_get(sd)

Definition at line 200 of file sysfs.h.

#define sysfs_info (   SB)    ((struct sysfs_super_info *)(SB->s_fs_info))

Definition at line 151 of file sysfs.h.

#define SYSFS_KOBJ_ATTR   0x0002

Definition at line 90 of file sysfs.h.

#define SYSFS_KOBJ_BIN_ATTR   0x0004

Definition at line 91 of file sysfs.h.

#define SYSFS_KOBJ_LINK   0x0008

Definition at line 92 of file sysfs.h.

#define SYSFS_NS_TYPE_MASK   0xf00

Definition at line 97 of file sysfs.h.

#define SYSFS_NS_TYPE_SHIFT   8

Definition at line 98 of file sysfs.h.

#define sysfs_put (   sd)    __sysfs_put(sd)

Definition at line 207 of file sysfs.h.

#define SYSFS_TYPE_MASK   0x00ff

Definition at line 88 of file sysfs.h.

Function Documentation

int __sysfs_add_one ( struct sysfs_addrm_cxt acxt,
struct sysfs_dirent sd 
)

__sysfs_add_one - add sysfs_dirent to parent without warning : addrm context to use : sysfs_dirent to be added

Get ->parent_sd and set sd->s_parent to it and increment nlink of parent inode if is a directory and link into the children list of the parent.

This function should be called between calls to sysfs_addrm_start() and sysfs_addrm_finish() and should be passed the same as passed to sysfs_addrm_start().

LOCKING: Determined by sysfs_addrm_start().

RETURNS: 0 on success, -EEXIST if entry with the given name already exists.

Definition at line 456 of file dir.c.

void release_sysfs_dirent ( struct sysfs_dirent sd)

Definition at line 274 of file dir.c.

int sysfs_add_file ( struct sysfs_dirent dir_sd,
const struct attribute attr,
int  type 
)

Definition at line 558 of file file.c.

int sysfs_add_file_mode ( struct sysfs_dirent dir_sd,
const struct attribute attr,
int  type,
umode_t  amode 
)

Definition at line 526 of file file.c.

int sysfs_add_one ( struct sysfs_addrm_cxt acxt,
struct sysfs_dirent sd 
)

sysfs_add_one - add sysfs_dirent to parent : addrm context to use : sysfs_dirent to be added

Get ->parent_sd and set sd->s_parent to it and increment nlink of parent inode if is a directory and link into the children list of the parent.

This function should be called between calls to sysfs_addrm_start() and sysfs_addrm_finish() and should be passed the same as passed to sysfs_addrm_start().

LOCKING: Determined by sysfs_addrm_start().

RETURNS: 0 on success, -EEXIST if entry with the given name already exists.

Definition at line 523 of file dir.c.

void sysfs_addrm_finish ( struct sysfs_addrm_cxt acxt)

sysfs_addrm_finish - finish up sysfs_dirent add/remove : addrm context to finish up

Finish up sysfs_dirent add/remove. Resources acquired by sysfs_addrm_start() are released and removed sysfs_dirents are cleaned up.

LOCKING: sysfs_mutex is released.

Definition at line 589 of file dir.c.

void sysfs_addrm_start ( struct sysfs_addrm_cxt acxt,
struct sysfs_dirent parent_sd 
)

sysfs_addrm_start - prepare for sysfs_dirent add/remove : pointer to sysfs_addrm_cxt to be used : parent sysfs_dirent

This function is called when the caller is about to add or remove sysfs_dirent under . This function acquires sysfs_mutex. is used to keep and pass context to other addrm functions.

LOCKING: Kernel thread context (may sleep). sysfs_mutex is locked on return.

Definition at line 427 of file dir.c.

int sysfs_create_subdir ( struct kobject kobj,
const char name,
struct sysfs_dirent **  p_sd 
)

Definition at line 710 of file dir.c.

void sysfs_evict_inode ( struct inode inode)

Definition at line 308 of file inode.c.

struct sysfs_dirent* sysfs_find_dirent ( struct sysfs_dirent parent_sd,
const void ns,
const unsigned char name 
)
read

Definition at line 619 of file dir.c.

struct sysfs_dirent* sysfs_get_active ( struct sysfs_dirent sd)
read

sysfs_get_active - get an active reference to sysfs_dirent : sysfs_dirent to get an active reference to

Get an active reference of . This function is noop if is NULL.

RETURNS: Pointer to on success, NULL on failure.

Definition at line 163 of file dir.c.

struct dentry* sysfs_get_dentry ( struct sysfs_dirent sd)
read
struct sysfs_dirent* sysfs_get_dirent ( struct sysfs_dirent parent_sd,
const void ns,
const unsigned char name 
)
read

Definition at line 664 of file dir.c.

struct inode* sysfs_get_inode ( struct super_block sb,
struct sysfs_dirent sd 
)
read

sysfs_get_inode - get inode for sysfs_dirent : super block : sysfs_dirent to allocate inode for

Get inode for . If such inode doesn't exist, a new inode is allocated and basics are initialized. New inode is returned locked.

LOCKING: Kernel thread context (may sleep).

RETURNS: Pointer to allocated inode on success, NULL on failure.

Definition at line 290 of file inode.c.

int sysfs_getattr ( struct vfsmount mnt,
struct dentry dentry,
struct kstat stat 
)

Definition at line 225 of file inode.c.

int sysfs_hash_and_remove ( struct sysfs_dirent dir_sd,
const void ns,
const char name 
)

Definition at line 317 of file inode.c.

int sysfs_inode_init ( void  )

Definition at line 48 of file inode.c.

struct sysfs_dirent* sysfs_new_dirent ( const char name,
umode_t  mode,
int  type 
)
read

Definition at line 379 of file dir.c.

int sysfs_permission ( struct inode inode,
int  mask 
)

Definition at line 342 of file inode.c.

void sysfs_put_active ( struct sysfs_dirent sd)

sysfs_put_active - put an active reference to sysfs_dirent : sysfs_dirent to put an active reference to

Put an active reference to . This function is noop if is NULL.

Definition at line 196 of file dir.c.

void sysfs_remove_one ( struct sysfs_addrm_cxt acxt,
struct sysfs_dirent sd 
)

sysfs_remove_one - remove sysfs_dirent from parent : addrm context to use : sysfs_dirent to be removed

Mark removed and drop nlink of parent inode if is a directory. is unlinked from the children list.

This function should be called between calls to sysfs_addrm_start() and sysfs_addrm_finish() and should be passed the same as passed to sysfs_addrm_start().

LOCKING: Determined by sysfs_addrm_start().

Definition at line 558 of file dir.c.

void sysfs_remove_subdir ( struct sysfs_dirent sd)

Definition at line 829 of file dir.c.

int sysfs_rename ( struct sysfs_dirent sd,
struct sysfs_dirent new_parent_sd,
const void ns,
const char new_name 
)

Definition at line 877 of file dir.c.

int sysfs_sd_setattr ( struct sysfs_dirent sd,
struct iattr iattr 
)

Definition at line 72 of file inode.c.

int sysfs_setattr ( struct dentry dentry,
struct iattr iattr 
)

Definition at line 107 of file inode.c.

int sysfs_setxattr ( struct dentry dentry,
const char name,
const void value,
size_t  size,
int  flags 
)

Definition at line 157 of file inode.c.

void unmap_bin_file ( struct sysfs_dirent attr_sd)

Definition at line 461 of file bin.c.

Variable Documentation

Definition at line 451 of file bin.c.

spinlock_t sysfs_assoc_lock
struct dentry_operations sysfs_dentry_ops

Definition at line 373 of file dir.c.

struct kmem_cache* sysfs_dir_cachep

Definition at line 27 of file mount.c.

struct inode_operations sysfs_dir_inode_operations

Definition at line 812 of file dir.c.

struct file_operations sysfs_dir_operations

Definition at line 1062 of file dir.c.

struct file_operations sysfs_file_operations

Definition at line 479 of file file.c.

struct mutex sysfs_mutex
struct sysfs_dirent sysfs_root

Definition at line 35 of file mount.c.

struct inode_operations sysfs_symlink_inode_operations

Definition at line 294 of file symlink.c.