From: Herbert Poetzl (herbert_at_13thfloor.at)
Date: Fri 26 Sep 2003 - 14:41:08 BST
On Fri, Sep 26, 2003 at 06:25:18AM +0300, Alex Lyashkov wrote:
> >
> > Another problem is that 'vserver XXX enter' can not be used anymore. Or
> > does there exist a way to enter the namespace of foreign processes?
> > Doing the mounts on every 'enter' seems to be expensive on the first
> > glance.
> In kernel not have parts for enter to the namaspace of foregin processes but 
> add very easy. that sample working code.
thought about that, but wasn't sure it is 
required for 'visiting' processes, which 
could do with a 'wrong' namespace ...
but you are right, this is obviously the
best solution ...
thanks,
Herbert
> static inline void switch_namespace(task_t *task, struct s_context 
> *new_context)
> {
>    struct fs_struct *fs;
>    #define ns new_context->vroot.names
>    struct namespace *old_ns;
> #ifdef S_CONTEXT_DEBUG_VROOT
>    printk("switch_namespace ctx #%u new_root %s\n", new_context->id, 
> ns.root->mnt_root->d_name.name);
>    printk("n_ns %p o_ns %p \n", ns.root, task->namespace);
> #endif
> 
>    task_lock(task);
>    fs = task->fs;
>    old_ns = task->namespace;
>    get_namespace(&ns);
>    task->namespace=&ns;
>    put_namespace(old_ns);
>    task_unlock(task);
> 
>    set_fs_root(fs, ns.root, ns.root->mnt_root);
>    set_fs_altroot();
>    set_fs_pwd(task->fs, ns.root, ns.root->mnt_root);
> 
>    #undef ns
> }
> it`s not need do mounts every "enter"
> 
> -- 
> With best regards,
> Alex