Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
kobject.c File Reference
#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/export.h>
#include <linux/stat.h>
#include <linux/slab.h>

Go to the source code of this file.

Functions

charkobject_get_path (struct kobject *kobj, gfp_t gfp_mask)
 
 EXPORT_SYMBOL_GPL (kobject_get_path)
 
int kobject_set_name_vargs (struct kobject *kobj, const char *fmt, va_list vargs)
 
int kobject_set_name (struct kobject *kobj, const char *fmt,...)
 
 EXPORT_SYMBOL (kobject_set_name)
 
void kobject_init (struct kobject *kobj, struct kobj_type *ktype)
 
 EXPORT_SYMBOL (kobject_init)
 
int kobject_add (struct kobject *kobj, struct kobject *parent, const char *fmt,...)
 
 EXPORT_SYMBOL (kobject_add)
 
int kobject_init_and_add (struct kobject *kobj, struct kobj_type *ktype, struct kobject *parent, const char *fmt,...)
 
 EXPORT_SYMBOL_GPL (kobject_init_and_add)
 
int kobject_rename (struct kobject *kobj, const char *new_name)
 
 EXPORT_SYMBOL_GPL (kobject_rename)
 
int kobject_move (struct kobject *kobj, struct kobject *new_parent)
 
void kobject_del (struct kobject *kobj)
 
struct kobjectkobject_get (struct kobject *kobj)
 
void kobject_put (struct kobject *kobj)
 
struct kobjectkobject_create (void)
 

: the name for the kobject

kobject_create_and_add - create a struct kobject dynamically and register it with sysfs

: the parent kobject of this kobject, if any.

This function creates a kobject structure dynamically and registers it with sysfs. When you are finished with this structure, call kobject_put() and the structure will be dynamically freed when it is no longer being used.

If the kobject was not able to be created, NULL will be returned.

struct sysfs_ops kobj_sysfs_ops
 
struct kobjectkobject_create_and_add (const char *name, struct kobject *parent)
 
 EXPORT_SYMBOL_GPL (kobject_create_and_add)
 
void kset_init (struct kset *k)
 
int kset_register (struct kset *k)
 
void kset_unregister (struct kset *k)
 

: object's name.

kset_find_obj - search for object in kset. : kset we're looking in.

Lock kset via ->subsys, and iterate over ->list, looking for a matching kobject. If matching object is found take a reference and return the object.

struct kobjectkset_find_obj (struct kset *kset, const char *name)
 

: the name for the kset

kset_create_and_add - create a struct kset dynamically and add it to sysfs

: a struct kset_uevent_ops for the kset : the parent kobject of this kset, if any.

This function creates a kset structure dynamically and registers it with sysfs. When you are finished with this structure, call kset_unregister() and the structure will be dynamically freed when it is no longer being used.

If the kset was not able to be created, NULL will be returned.

struct ksetkset_create_and_add (const char *name, const struct kset_uevent_ops *uevent_ops, struct kobject *parent_kobj)
 
 EXPORT_SYMBOL_GPL (kset_create_and_add)
 
int kobj_ns_type_register (const struct kobj_ns_type_operations *ops)
 
int kobj_ns_type_registered (enum kobj_ns_type type)
 
struct kobj_ns_type_operationskobj_child_ns_ops (struct kobject *parent)
 
struct kobj_ns_type_operationskobj_ns_ops (struct kobject *kobj)
 
voidkobj_ns_grab_current (enum kobj_ns_type type)
 
const voidkobj_ns_netlink (enum kobj_ns_type type, struct sock *sk)
 
const voidkobj_ns_initial (enum kobj_ns_type type)
 
void kobj_ns_drop (enum kobj_ns_type type, void *ns)
 
 EXPORT_SYMBOL (kobject_get)
 
 EXPORT_SYMBOL (kobject_put)
 
 EXPORT_SYMBOL (kobject_del)
 
 EXPORT_SYMBOL (kset_register)
 
 EXPORT_SYMBOL (kset_unregister)
 

Function Documentation

EXPORT_SYMBOL ( kobject_set_name  )
EXPORT_SYMBOL ( kobject_init  )
EXPORT_SYMBOL ( kobject_add  )
EXPORT_SYMBOL ( kobject_get  )
EXPORT_SYMBOL ( kobject_put  )
EXPORT_SYMBOL ( kobject_del  )
EXPORT_SYMBOL ( kset_register  )
EXPORT_SYMBOL ( kset_unregister  )
EXPORT_SYMBOL_GPL ( kobject_get_path  )
EXPORT_SYMBOL_GPL ( kobject_init_and_add  )
EXPORT_SYMBOL_GPL ( kobject_rename  )
EXPORT_SYMBOL_GPL ( kobject_create_and_add  )
EXPORT_SYMBOL_GPL ( kset_create_and_add  )
struct kobj_ns_type_operations* kobj_child_ns_ops ( struct kobject parent)
read

Definition at line 896 of file kobject.c.

void kobj_ns_drop ( enum kobj_ns_type  type,
void ns 
)

Definition at line 951 of file kobject.c.

void* kobj_ns_grab_current ( enum kobj_ns_type  type)

Definition at line 912 of file kobject.c.

const void* kobj_ns_initial ( enum kobj_ns_type  type)

Definition at line 938 of file kobject.c.

const void* kobj_ns_netlink ( enum kobj_ns_type  type,
struct sock sk 
)

Definition at line 925 of file kobject.c.

struct kobj_ns_type_operations* kobj_ns_ops ( struct kobject kobj)
read

Definition at line 906 of file kobject.c.

int kobj_ns_type_register ( const struct kobj_ns_type_operations ops)

Definition at line 857 of file kobject.c.

int kobj_ns_type_registered ( enum kobj_ns_type  type)

Definition at line 884 of file kobject.c.

int kobject_add ( struct kobject kobj,
struct kobject parent,
const char fmt,
  ... 
)

kobject_add - the main kobject add function : the kobject to add : pointer to the parent of the kobject. : format to name the kobject with.

The kobject name is set and added to the kobject hierarchy in this function.

If is set, then the parent of the will be set to it. If is NULL, then the parent of the will be set to the kobject associted with the kset assigned to this kobject. If no kset is assigned to the kobject, then the kobject will be located in the root of the sysfs tree.

If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Under no instance should the kobject that is passed to this function be directly freed with a call to kfree(), that can leak memory.

Note, no "add" uevent will be created with this call, the caller should set up all of the necessary sysfs files for the object and then call kobject_uevent() with the UEVENT_ADD parameter to ensure that userspace is properly notified of this kobject's creation.

Definition at line 336 of file kobject.c.

struct kobject* kobject_create ( void  )
read

kobject_create - create a struct kobject dynamically

This function creates a kobject structure dynamically and sets it up to be a "dynamic" kobject with a default release function set up.

If the kobject was not able to be created, NULL will be returned. The kobject structure returned from here must be cleaned up with a call to kobject_put() and not kfree(), as kobject_init() has already been called on this structure.

Definition at line 620 of file kobject.c.

struct kobject* kobject_create_and_add ( const char name,
struct kobject parent 
)
read

Definition at line 645 of file kobject.c.

void kobject_del ( struct kobject kobj)

kobject_del - unlink kobject from hierarchy. : object.

Definition at line 509 of file kobject.c.

struct kobject* kobject_get ( struct kobject kobj)
read

kobject_get - increment refcount for object. : object.

Definition at line 525 of file kobject.c.

char* kobject_get_path ( struct kobject kobj,
gfp_t  gfp_mask 
)

kobject_get_path - generate and return the path associated with a given kobj and kset pair.

: kobject in question, with which to build the path : the allocation type used to allocate the path

The result must be freed by the caller with kfree().

Definition at line 102 of file kobject.c.

void kobject_init ( struct kobject kobj,
struct kobj_type ktype 
)

kobject_init - initialize a kobject structure : pointer to the kobject to initialize : pointer to the ktype for this kobject.

This function will properly initialize a kobject such that it can then be passed to the kobject_add() call.

After this function is called, the kobject MUST be cleaned up by a call to kobject_put(), not by a call to kfree directly to ensure that all of the memory is cleaned up properly.

Definition at line 268 of file kobject.c.

int kobject_init_and_add ( struct kobject kobj,
struct kobj_type ktype,
struct kobject parent,
const char fmt,
  ... 
)

kobject_init_and_add - initialize a kobject structure and add it to the kobject hierarchy : pointer to the kobject to initialize : pointer to the ktype for this kobject. : pointer to the parent of this kobject. : the name of the kobject.

This function combines the call to kobject_init() and kobject_add(). The same type of error handling after a call to kobject_add() and kobject lifetime rules are the same here.

Definition at line 371 of file kobject.c.

int kobject_move ( struct kobject kobj,
struct kobject new_parent 
)

kobject_move - move object to another parent : object in question. : object's new parent (can be NULL)

Definition at line 459 of file kobject.c.

void kobject_put ( struct kobject kobj)

kobject_put - decrement refcount for object. : object.

Decrement the refcount, and if 0, call kobject_cleanup().

Definition at line 587 of file kobject.c.

int kobject_rename ( struct kobject kobj,
const char new_name 
)

kobject_rename - change the name of an object : object in question. : object's new name

It is the responsibility of the caller to provide mutual exclusion between two different calls of kobject_rename on the same kobject and to ensure that new_name is valid and won't conflict with other kobjects.

Definition at line 397 of file kobject.c.

int kobject_set_name ( struct kobject kobj,
const char fmt,
  ... 
)

kobject_set_name - Set the name of a kobject : struct kobject to set the name of : format string used to build the name

This sets the name of the kobject. If you have already added the kobject to the system, you must call kobject_rename() in order to change the name of the kobject.

Definition at line 243 of file kobject.c.

int kobject_set_name_vargs ( struct kobject kobj,
const char fmt,
va_list  vargs 
)

kobject_set_name_vargs - Set the name of an kobject : struct kobject to set the name of : format string used to build the name : vargs to format the string.

Definition at line 213 of file kobject.c.

struct kset* kset_create_and_add ( const char name,
const struct kset_uevent_ops uevent_ops,
struct kobject parent_kobj 
)
read

Definition at line 834 of file kobject.c.

struct kobject* kset_find_obj ( struct kset kset,
const char name 
)
read

Definition at line 745 of file kobject.c.

void kset_init ( struct kset k)

kset_init - initialize a kset for use : kset

Definition at line 669 of file kobject.c.

int kset_register ( struct kset k)

kset_register - initialize and add a kset. : kset.

Definition at line 710 of file kobject.c.

void kset_unregister ( struct kset k)

kset_unregister - remove a kset. : kset.

Definition at line 729 of file kobject.c.

Variable Documentation

struct sysfs_ops kobj_sysfs_ops
Initial value:
= {
.show = kobj_attr_show,
.store = kobj_attr_store,
}

Definition at line 701 of file kobject.c.