Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
dir.c File Reference
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/namei.h>
#include <linux/idr.h>
#include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/security.h>
#include <linux/hash.h>
#include "sysfs.h"

Go to the source code of this file.

Macros

#define to_sysfs_dirent(X)   rb_entry((X), struct sysfs_dirent, s_rb);
 

Functions

 DEFINE_MUTEX (sysfs_mutex)
 
 DEFINE_SPINLOCK (sysfs_assoc_lock)
 
under @parent_sd.

LOCKING: mutex_lock(sysfs_mutex)

RETURNS: Pointer to sysfs_dirent if found, NULL if not.

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

: Null terminated string to hash

sysfs_name_hash : Namespace tag to hash

Returns 31 bit hash of ns + name (so it fits in an off_t )

struct dentry_operations sysfs_dentry_ops
 
struct sysfs_direntsysfs_get_active (struct sysfs_dirent *sd)
 
void sysfs_put_active (struct sysfs_dirent *sd)
 
void release_sysfs_dirent (struct sysfs_dirent *sd)
 
struct sysfs_direntsysfs_new_dirent (const char *name, umode_t mode, int type)
 
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)
 

under @parent_sd and get

it if found.

LOCKING: Kernel thread context (may sleep). Grabs sysfs_mutex.

RETURNS: Pointer to sysfs_dirent if found, NULL if not.

struct inode_operations sysfs_dir_inode_operations
 
struct file_operations sysfs_dir_operations
 
struct sysfs_direntsysfs_get_dirent (struct sysfs_dirent *parent_sd, const void *ns, const unsigned char *name)
 
 EXPORT_SYMBOL_GPL (sysfs_get_dirent)
 
int sysfs_create_subdir (struct kobject *kobj, const char *name, struct sysfs_dirent **p_sd)
 
int sysfs_create_dir (struct kobject *kobj)
 
void sysfs_remove_subdir (struct sysfs_dirent *sd)
 
void sysfs_remove_dir (struct kobject *kobj)
 
int sysfs_rename (struct sysfs_dirent *sd, struct sysfs_dirent *new_parent_sd, const void *new_ns, const char *new_name)
 
int sysfs_rename_dir (struct kobject *kobj, const char *new_name)
 
int sysfs_move_dir (struct kobject *kobj, struct kobject *new_parent_kobj)
 

Macro Definition Documentation

#define to_sysfs_dirent (   X)    rb_entry((X), struct sysfs_dirent, s_rb);

Definition at line 31 of file dir.c.

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.

DEFINE_MUTEX ( sysfs_mutex  )
DEFINE_SPINLOCK ( sysfs_assoc_lock  )
EXPORT_SYMBOL_GPL ( sysfs_get_dirent  )
void release_sysfs_dirent ( struct sysfs_dirent sd)

Definition at line 274 of file dir.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_dir ( struct kobject kobj)

sysfs_create_dir - create a directory for an object. : object we're creating directory for.

Definition at line 746 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.

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 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.

int sysfs_move_dir ( struct kobject kobj,
struct kobject new_parent_kobj 
)

Definition at line 931 of file dir.c.

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

Definition at line 379 of file dir.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_dir ( struct kobject kobj)

sysfs_remove_dir - remove an object's directory. : object.

The only thing special about this is that we remove any files in the directory before we remove the directory, and we've inlined what used to be sysfs_rmdir() below, instead of calling separately.

Definition at line 866 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 new_ns,
const char new_name 
)

Definition at line 877 of file dir.c.

int sysfs_rename_dir ( struct kobject kobj,
const char new_name 
)

Definition at line 920 of file dir.c.

Variable Documentation

struct dentry_operations sysfs_dentry_ops
Initial value:
= {
.d_revalidate = sysfs_dentry_revalidate,
.d_delete = sysfs_dentry_delete,
.d_release = sysfs_dentry_release,
}

Definition at line 373 of file dir.c.

struct inode_operations sysfs_dir_inode_operations
Initial value:
= {
.lookup = sysfs_lookup,
.permission = sysfs_permission,
.setattr = sysfs_setattr,
.getattr = sysfs_getattr,
.setxattr = sysfs_setxattr,
}

Definition at line 812 of file dir.c.

struct file_operations sysfs_dir_operations
Initial value:
= {
.readdir = sysfs_readdir,
.release = sysfs_dir_release,
}

Definition at line 1062 of file dir.c.