-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 84604 b: refs/heads/master c: ae5e1b2 h: refs/heads/master v: v3
- Loading branch information
Pavel Emelyanov
authored and
Linus Torvalds
committed
Feb 8, 2008
1 parent
0053797
commit 58f8ad6
Showing
13 changed files
with
165 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 58bfdd6deeec02b73691ea2c951a3c5d743bca63 | ||
refs/heads/master: ae5e1b22f17983da929a0d0178896269e19da186 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef __IPC_NAMESPACE_H__ | ||
#define __IPC_NAMESPACE_H__ | ||
|
||
#include <linux/err.h> | ||
|
||
struct ipc_ids; | ||
struct ipc_namespace { | ||
struct kref kref; | ||
struct ipc_ids *ids[3]; | ||
|
||
int sem_ctls[4]; | ||
int used_sems; | ||
|
||
int msg_ctlmax; | ||
int msg_ctlmnb; | ||
int msg_ctlmni; | ||
atomic_t msg_bytes; | ||
atomic_t msg_hdrs; | ||
|
||
size_t shm_ctlmax; | ||
size_t shm_ctlall; | ||
int shm_ctlmni; | ||
int shm_tot; | ||
}; | ||
|
||
extern struct ipc_namespace init_ipc_ns; | ||
|
||
#ifdef CONFIG_SYSVIPC | ||
#define INIT_IPC_NS(ns) .ns = &init_ipc_ns, | ||
#else | ||
#define INIT_IPC_NS(ns) | ||
#endif | ||
|
||
#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS) | ||
extern void free_ipc_ns(struct kref *kref); | ||
extern struct ipc_namespace *copy_ipcs(unsigned long flags, | ||
struct ipc_namespace *ns); | ||
|
||
static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | ||
{ | ||
if (ns) | ||
kref_get(&ns->kref); | ||
return ns; | ||
} | ||
|
||
static inline void put_ipc_ns(struct ipc_namespace *ns) | ||
{ | ||
kref_put(&ns->kref, free_ipc_ns); | ||
} | ||
#else | ||
static inline struct ipc_namespace *copy_ipcs(unsigned long flags, | ||
struct ipc_namespace *ns) | ||
{ | ||
if (flags & CLONE_NEWIPC) | ||
return ERR_PTR(-EINVAL); | ||
|
||
return ns; | ||
} | ||
|
||
static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | ||
{ | ||
return ns; | ||
} | ||
|
||
static inline void put_ipc_ns(struct ipc_namespace *ns) | ||
{ | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* linux/ipc/namespace.c | ||
* Copyright (C) 2006 Pavel Emelyanov <xemul@openvz.org> OpenVZ, SWsoft Inc. | ||
*/ | ||
|
||
#include <linux/ipc.h> | ||
#include <linux/msg.h> | ||
#include <linux/ipc_namespace.h> | ||
#include <linux/rcupdate.h> | ||
#include <linux/nsproxy.h> | ||
#include <linux/slab.h> | ||
|
||
#include "util.h" | ||
|
||
static struct ipc_namespace *clone_ipc_ns(struct ipc_namespace *old_ns) | ||
{ | ||
int err; | ||
struct ipc_namespace *ns; | ||
|
||
err = -ENOMEM; | ||
ns = kmalloc(sizeof(struct ipc_namespace), GFP_KERNEL); | ||
if (ns == NULL) | ||
goto err_mem; | ||
|
||
err = sem_init_ns(ns); | ||
if (err) | ||
goto err_sem; | ||
err = msg_init_ns(ns); | ||
if (err) | ||
goto err_msg; | ||
err = shm_init_ns(ns); | ||
if (err) | ||
goto err_shm; | ||
|
||
kref_init(&ns->kref); | ||
return ns; | ||
|
||
err_shm: | ||
msg_exit_ns(ns); | ||
err_msg: | ||
sem_exit_ns(ns); | ||
err_sem: | ||
kfree(ns); | ||
err_mem: | ||
return ERR_PTR(err); | ||
} | ||
|
||
struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns) | ||
{ | ||
struct ipc_namespace *new_ns; | ||
|
||
BUG_ON(!ns); | ||
get_ipc_ns(ns); | ||
|
||
if (!(flags & CLONE_NEWIPC)) | ||
return ns; | ||
|
||
new_ns = clone_ipc_ns(ns); | ||
|
||
put_ipc_ns(ns); | ||
return new_ns; | ||
} | ||
|
||
void free_ipc_ns(struct kref *kref) | ||
{ | ||
struct ipc_namespace *ns; | ||
|
||
ns = container_of(kref, struct ipc_namespace, kref); | ||
sem_exit_ns(ns); | ||
msg_exit_ns(ns); | ||
shm_exit_ns(ns); | ||
kfree(ns); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters