Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
util.h File Reference
#include <linux/unistd.h>
#include <linux/err.h>

Go to the source code of this file.

Data Structures

struct  ipc_params
 
struct  ipc_ops
 

Macros

#define SEQ_MULTIPLIER   (IPCMNI)
 
#define ipc_init_proc_interface(path, header, ids, show)   do {} while (0)
 
#define IPC_SEM_IDS   0
 
#define IPC_MSG_IDS   1
 
#define IPC_SHM_IDS   2
 
#define ipcid_to_idx(id)   ((id) % SEQ_MULTIPLIER)
 
#define ipc_parse_version(cmd)   IPC_64
 

Functions

void sem_init (void)
 
void msg_init (void)
 
void shm_init (void)
 
void ipc_init_ids (struct ipc_ids *)
 
int ipc_addid (struct ipc_ids *, struct kern_ipc_perm *, int)
 
int ipc_get_maxid (struct ipc_ids *)
 
void ipc_rmid (struct ipc_ids *, struct kern_ipc_perm *)
 
int ipcperms (struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg)
 
voidipc_alloc (int size)
 
void ipc_free (void *ptr, int size)
 
voidipc_rcu_alloc (int size)
 
void ipc_rcu_getref (void *ptr)
 
void ipc_rcu_putref (void *ptr)
 
struct kern_ipc_permipc_lock (struct ipc_ids *, int)
 
void kernel_to_ipc64_perm (struct kern_ipc_perm *in, struct ipc64_perm *out)
 
void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
 
int ipc_update_perm (struct ipc64_perm *in, struct kern_ipc_perm *out)
 
struct kern_ipc_permipcctl_pre_down (struct ipc_namespace *ns, struct ipc_ids *ids, int id, int cmd, struct ipc64_perm *perm, int extra_perm)
 
void free_msg (struct msg_msg *msg)
 
struct msg_msgload_msg (const void __user *src, int len)
 
int store_msg (void __user *dest, struct msg_msg *msg, int len)
 
void recompute_msgmni (struct ipc_namespace *)
 
struct kern_ipc_permipc_lock_check (struct ipc_ids *ids, int id)
 
int ipcget (struct ipc_namespace *ns, struct ipc_ids *ids, struct ipc_ops *ops, struct ipc_params *params)
 
void free_ipcs (struct ipc_namespace *ns, struct ipc_ids *ids, void(*free)(struct ipc_namespace *, struct kern_ipc_perm *))
 

Macro Definition Documentation

#define ipc_init_proc_interface (   path,
  header,
  ids,
  show 
)    do {} while (0)

Definition at line 87 of file util.h.

#define IPC_MSG_IDS   1

Definition at line 91 of file util.h.

#define ipc_parse_version (   cmd)    IPC_64

Definition at line 135 of file util.h.

#define IPC_SEM_IDS   0

Definition at line 90 of file util.h.

#define IPC_SHM_IDS   2

Definition at line 92 of file util.h.

#define ipcid_to_idx (   id)    ((id) % SEQ_MULTIPLIER)

Definition at line 94 of file util.h.

#define SEQ_MULTIPLIER   (IPCMNI)

Definition at line 16 of file util.h.

Function Documentation

void free_ipcs ( struct ipc_namespace ns,
struct ipc_ids ids,
void(*)(struct ipc_namespace *, struct kern_ipc_perm *)  free 
)

Definition at line 72 of file namespace.c.

void free_msg ( struct msg_msg msg)

Definition at line 131 of file msgutil.c.

void ipc64_perm_to_ipc_perm ( struct ipc64_perm in,
struct ipc_perm out 
)

ipc64_perm_to_ipc_perm - convert new ipc permissions to old : new style IPC permissions : old style IPC permissions

Turn the new style permissions object into a compatibility object and store it into the pointer.

Definition at line 663 of file util.c.

int ipc_addid ( struct ipc_ids ids,
struct kern_ipc_perm new,
int  size 
)

ipc_addid - add an IPC identifier : IPC identifier set : new IPC permission set : limit for the number of used ids

Add an entry 'new' to the IPC ids idr. The permissions object is initialised and the first free entry is set up and the id assigned is returned. The 'new' entry is returned in a locked state on success. On failure the entry is not locked and a negative err-code is returned.

Called with ipc_ids.rw_mutex held as a writer.

Definition at line 250 of file util.c.

void* ipc_alloc ( int  size)

ipc_alloc - allocate ipc space : size desired

Allocate memory from the appropriate pools and return a pointer to it. NULL is returned if the allocation fails

Definition at line 445 of file util.c.

void ipc_free ( void ptr,
int  size 
)

ipc_free - free ipc space : pointer returned by ipc_alloc : size of block

Free a block created with ipc_alloc(). The caller must know the size used in the allocation call.

Definition at line 464 of file util.c.

int ipc_get_maxid ( struct ipc_ids ids)

ipc_get_maxid - get the last assigned id : IPC identifier set

Called with ipc_ids.rw_mutex held.

Definition at line 212 of file util.c.

void ipc_init_ids ( struct ipc_ids ids)

ipc_init_ids - initialise IPC identifiers : Identifier set

Set up the sequence range to use for the ipc identifier range (limited below IPCMNI) then initialise the ids idr.

Definition at line 119 of file util.c.

struct kern_ipc_perm* ipc_lock ( struct ipc_ids ids,
int  id 
)
read

ipc_lock - Lock an ipc structure without rw_mutex held : IPC identifier set : ipc id to look for

Look for an id in the ipc ids idr and lock the associated ipc object.

The ipc object is locked on exit.

Definition at line 684 of file util.c.

struct kern_ipc_perm* ipc_lock_check ( struct ipc_ids ids,
int  id 
)
read

Definition at line 710 of file util.c.

void* ipc_rcu_alloc ( int  size)

ipc_rcu_alloc - allocate ipc and rcu space : size desired

Allocate memory for the rcu header structure + the object. Returns the pointer to the object. NULL is returned if the allocation fails.

Definition at line 526 of file util.c.

void ipc_rcu_getref ( void ptr)

Definition at line 552 of file util.c.

void ipc_rcu_putref ( void ptr)

Definition at line 582 of file util.c.

void ipc_rmid ( struct ipc_ids ids,
struct kern_ipc_perm ipcp 
)

ipc_rmid - remove an IPC identifier : IPC identifier set : ipc perm structure containing the identifier to remove

ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held before this function is called, and remain locked on the exit.

Definition at line 424 of file util.c.

int ipc_update_perm ( struct ipc64_perm in,
struct kern_ipc_perm out 
)

ipc_update_perm - update the permissions of an IPC. : the permission given as input. : the permission of the ipc to set.

Definition at line 750 of file util.c.

struct kern_ipc_perm* ipcctl_pre_down ( struct ipc_namespace ns,
struct ipc_ids ids,
int  id,
int  cmd,
struct ipc64_perm perm,
int  extra_perm 
)
read

ipcctl_pre_down - retrieve an ipc and check permissions for some IPC_XXX cmd : the ipc namespace : the table of ids where to look for the ipc : the id of the ipc to retrieve : the cmd to check : the permission to set : one extra permission parameter used by msq

This function does some common audit and permissions check for some IPC_XXX cmd and is called from semctl_down, shmctl_down and msgctl_down. It must be called without any lock held and

  • retrieves the ipc with the given id in the given table.
  • performs some audit and permission check, depending on the given cmd
  • returns the ipc with both ipc and rw_mutex locks held in case of success or an err-code without any lock held otherwise.

Definition at line 782 of file util.c.

int ipcget ( struct ipc_namespace ns,
struct ipc_ids ids,
struct ipc_ops ops,
struct ipc_params params 
)

ipcget - Common sys_*get() code : namsepace : IPC identifier set : operations to be called on ipc object creation, permission checks and further checks : the parameters needed by the previous operations.

Common routine called by sys_msgget(), sys_semget() and sys_shmget().

Definition at line 736 of file util.c.

int ipcperms ( struct ipc_namespace ns,
struct kern_ipc_perm ipcp,
short  flag 
)

ipcperms - check IPC permissions : IPC namespace : IPC permission set : desired permission set.

Check user, group, other permissions for access to ipc resources. return 0 if allowed

will most probably be 0 or S_...UGO from <linux/stat.h>

Definition at line 607 of file util.c.

void kernel_to_ipc64_perm ( struct kern_ipc_perm in,
struct ipc64_perm out 
)

kernel_to_ipc64_perm - convert kernel ipc permissions to user : kernel permissions : new style IPC permissions

Turn the kernel object into a set of permissions descriptions for returning to userspace ().

Definition at line 643 of file util.c.

struct msg_msg* load_msg ( const void __user src,
int  len 
)
read

Definition at line 45 of file msgutil.c.

void msg_init ( void  )

Definition at line 131 of file msg.c.

void recompute_msgmni ( struct ipc_namespace )

Definition at line 86 of file msg.c.

void sem_init ( void  )

Definition at line 185 of file sem.c.

void shm_init ( void  )

Definition at line 116 of file shm.c.

int store_msg ( void __user dest,
struct msg_msg msg,
int  len 
)

Definition at line 104 of file msgutil.c.