[CRIU] [PATCH 6/7] files: Add c/r for /proc/$pid/ns/$ids references
Pavel Emelyanov
xemul at parallels.com
Thu May 9 13:57:50 EDT 2013
> +static int open_ns_fd(struct file_desc *d)
> +{
> + struct ns_file_info *nfi = container_of(d, struct ns_file_info, d);
> + struct ns_proc_entry *ns_proc_entry = NULL;
> + struct pstree_item *item, *t;
> + char path[64];
> + int fd;
> +
> +#define __ns_match(_name) \
> + ids->has_##_name && \
> + ids->_name == nfi->nfe->ns_id
Macro referencing stuff from stack is bad idea.
> +
> + /*
> + * Find out who can open us.
> + *
> + * FIXME I need a hash or RBtree here.
> + */
> + for_each_pstree_item(t) {
> + TaskKobjIdsEntry *ids = t->ids;
> +
> + if (__ns_match(pid_ns_id)) {
> + item = t;
> + ns_proc_entry = &ns_proc_entries[PROC_NS_PID];
> + break;
> + } else if (__ns_match(net_ns_id)) {
> + item = t;
> + ns_proc_entry = &ns_proc_entries[PROC_NS_NET];
> + break;
> + } else if (__ns_match(ipc_ns_id)) {
> + item = t;
> + ns_proc_entry = &ns_proc_entries[PROC_NS_IPC];
> + break;
> + } else if (__ns_match(uts_ns_id)) {
> + item = t;
> + ns_proc_entry = &ns_proc_entries[PROC_NS_UTS];
> + break;
> + } else if (__ns_match(mnt_ns_id)) {
> + item = t;
> + ns_proc_entry = &ns_proc_entries[PROC_NS_MNT];
> + break;
> + }
> + }
More information about the CRIU
mailing list