linux/kernel/pid_namespace.c
<<
>>
Prefs
   1/*
   2 * Pid namespaces
   3 *
   4 * Authors:
   5 *    (C) 2007 Pavel Emelyanov <xemul@openvz.org>, OpenVZ, SWsoft Inc.
   6 *    (C) 2007 Sukadev Bhattiprolu <sukadev@us.ibm.com>, IBM
   7 *     Many thanks to Oleg Nesterov for comments and help
   8 *
   9 */
  10
  11#include <linux/pid.h>
  12e="v2.6.32.>
  3309.6.25.14"
	  >
 L10"ion value="v2.6.27ption0n2v2.6.25.a hr1er>linux/pid.h>
 href="k1ernel/pid_namespace.c#L13" id1410"ion value="v2.6.27ption0n2v2.6.25.a hsyscalls.h>
rnel/pid1_namespace.c#L4" id="L41" cla1510"ion value="v2.6.27ption0n2v2.6.25.a herr.h>
span cla1ss="comment"> *    (C) 12007 1610"ion value="v2.6.27ption0n2v2.6.25.a hacct.h>
>   61 *   1710"ion value="v2.6.27ption0n2v2.6.25.a hslab.h>
name="L71">   7 href="k1ernel/pid_namespace.c#L18" id19; */
   9  cacheajax_lookua hre">  cache;   9
2L10"i        int *    (C) 22007 2610"i        struct   62 *   2710"i}2" id="L12" class="line" name="L12"2name="L72">   7   9  caches_lh;  caches_mutexajax_lookua hre">  caches_mutex; */
   9
3e" name="L2">   2  createibmhe kmem cachebm.callocate 43fs from" id="L5" class="line" name="L5">   5<3rnel/pid3_namespace.c#L4" id="L43" cla3s="line" name="L4">   4   5<3span cla3ss="comment"> *    (C) 32007 3avel Emelyanov <xemul@open  8 *
   63 *   37class="line" name="L9">   9   7  cachepajax_lookua hrecreate_">  cachep;   9   9  cache; */
   9
4L10"i        input typecode=mutex_lockajax_lookua hremutex_lock;  caches_mutex;  caches_lh;   9   9 *    (C) 42007 4610"i                        gom.cinput typecode=outajax_lookua hreout10"i2" id="L12" class="line" name="L12"4>   64 *   47class="line" name="L9">   9   7  cache;   9 */
   9"">  %d" 8<, input typecode=nr_idsajax_lookua hrenr_ids10"i)2" id="L12" class="line" name="L12"5id_names5pace.c#L2" id="L2" clas5	  >
5L10"i        input typecode=cachepajax_lookua hrecachep10"i = 10"i) + (input typecode=nr_idsajax_lookua hrenr_ids10"i - 1) ajax_lookua hreu"> 10"i)," id="L12" class="line" name="L12"5rnel/pid__namespace.c#L4" id="L4"" cla5510"i                        0, input typecode=SLAB_HWCACHE_ALIGNajax_lookua hreSLAB_HWCACHE_ALIGN; *    (C) 52007 5610"i        if (input typecode=cachepajax_lookua hrecachep10"i ==   9   65 *   5710"i                gom.cinput typecode=err_cachepajax_lookua hreerr_cachep10"i2" id="L12" class="line" name="L12"5name="L75">   7   9 */
  caches_lh;
6L10"i        input typecode=mutex_unlockajax_lookua hremutex_unlock;  caches_mutex;   9 *    (C) 22007 66L1" cnput typecode=err_cachepajax_lookua hreerr_cachep10"i:" id="L12" class="line" name="L12"6>   66 *   6710"i        input typecode=kfreeajax_lookua hrekfree;   7  caches_mutex; */
   9
73;   9   9 *    (C) 72007 7610"i        input typecode="lines_release_"rocajax_lookua hre"lines_release_"roc;   6>  *   7710"i}" id="L12" class="line" name="L12"7name="L77">   7   9limitingpsize of 'struct<"> 'en  8 *
 *
 */
   9   9   9   9linux/pidajax_lookua hreu1er>linux/pid10"i *input typecode=u1er>lsajax_lookua hreu1er>ls10"i," id="L12" class="line" name="L12"8id_names8pace.c#L2" id="L2" clas8	  >
8310"i        struct   sajax_lookua hrepar="L_">   s;   9   9 *    (C) 82007 8610"i        unsignedsint   sajax_lookua hrepar="L_">   s;   68 *   8710"i        int   7   9   9 */

9310"i        }" id="L12" class="line" name="L12"9 href="k9ernel/pid_namespace.c#L93" id94class="line" name="L9">   9 *    (C) 92007 9610"i        input typecode=nsajax_lookua hrens10"i =   69 *   9710"i        if (input typecode=nsajax_lookua hrens10"i ==   9   7   9 */
   9  11#incl02="Lid210"i                gom.cinput typecode=out_freeajax_lookua hreout_free10"i2" id="L12" class="line" name="L12"10  12e="v20.6.32.>
  3309.6.25.14"
03="Lid3class="line" name="L9">   9  cachepajax_lookua hrecreate_">  cachep;   9 *    (C) 106n"Lid610"i                gom.cinput typecode=out_free_mapajax_lookua hreout_free_map10"i2" id="L12" class="line" name="L12"10>   6107n"Lid7class="line" name="L9">   9   7   9 */
   9  11#incllude 11210"i        input typecode=kt t_initajax_lookua hrekt t_init;  12e="v22.6.32.>
  3309.6.25.14"

	  >11L10"i        input typecode=nsajax_lookua hrens10"i-#L12input typecode=levelajax_lookua hrelevel10"i = href="k11ernel/pid_namespace.c#L113" i11410"i        input typecode=nsajax_lookua hrens10"i-#L12input typecode="ar="Lajax_lookua hrepar="L10"i =   sajax_lookua hregeL_">   s;   sajax_lookua hrepar="L_">   s;5href="k11_namespace.c#L4" id="L411" cl11510"i        input typecode=nsajax_lookua hrens10"i-#L12input typecode=u1er>lsajax_lookua hreu1er>ls10"i =lsajax_lookua hregeL_u1er>ls;lsajax_lookua hreu1er>ls10"i)2" id="L12" class="line" name="L12"1>span cla11ss="comment"> *    (C) 11200711610"i        input typecode=nsajax_lookua hrens10"i-#L12input typecode=nr_hashe=ajax_lookua hrenr_hashe=10"i =>   611 *  11710"i        input typecode=INIT_WORKajax_lookua hreINIT_WORK;name="L711">   7   9 href="k11ernel/pid_namespace.c#L118" i11910"i        input typecode=seL_bitajax_lookua hreseL_bit; */
   9  11#incluude 12210"i        pan>(input typecode=iajax_lookua hrei10"i =<12 input typecode=iajax_lookua hrei10"i "v2.   912L10"i                input typecode=atomic_setajax_lookua hreatomic_set;   9 *    (C) 12200712610"i" id="L12" class="line" name="L12"12>   612 *  12710"iinput typecode=out_free_mapajax_lookua hreout_free_map10"i:" id="L12" class="line" name="L12"12name="L712">   7 */
13e" na}" id="L12" class="line" name="L12"13 href="k13ernel/pid_namespace.c#L133" i134class="line" name="L9">   9   9   9   9 *    (C) 13200713avel {s="line" name="L9">   9   613 *  13710"i        int   7   9(input typecode=iajax_lookua hrei10"i =<02 input typecode=iajax_lookua hrei10"i "v2.   9 */
lsajax_lookua hrepuL_u1er>ls;lsajax_lookua hreu1er>ls10"i)2" id="L12" class="line" name="L12"14id_names14pace.c#L2" id="L2" clas14	  >14L10"i        input typecode=kmem cache_freeajax_lookua hrekmem cache_free;   9 *    (C) 14200714610"istruct   sajax_lookua hrecopy_">   s;   9   614 *  14710"i        structlinux/pidajax_lookua hreu1er>linux/pid10"i *input typecode=u1er>lsajax_lookua hreu1er>ls10"i, struct   9   7   9   9   sajax_lookua hregeL_">   s;rass="com15ent"> */
   sajax_lookua hretask_   s;   9rid_names15pace.c#L2" id="L2" clas15	  >15L10"i        ace.c"
input typecode=create_">   9   9lsajax_lookua hreu1er>ls10"i, input typecode=ol   sajax_lookua hreol   s10"i)2" id="L12" class="line" name="L12">r href="k15ernel/pid_namespace.c#L153" i15410"i}" id="L12" class="line" name="L12"15rnel/pid1__namespace.c#L4" id="L41"" cl155class="line" name="L9">   9 *    (C) 152007156="list v2. void
input typecode=free_">   sajax_lookua hrefree_">   s;   9   615 *  15710"i{s="line" name="L9">   9   7r href="k15ernel/pid_namespace.c#L158" i159class="line" name="L9">   9 */
   9   9163class="line" name="L9">   9   sajax_lookua hreput_">   s;   9   9 *    (C) 12200716610"i        struct   616 *  167class="line" name="L9">   9   7   sajax_lookua hreinit_">   s10"i) {s="line" name="L9">   9>ref="ker17el/pid_namespace.c#L9" 17d="L17010"i                if (!input typecode=kt t_putajax_lookua hrekt t_put;   sajax_lookua hrefree_">   s;   9 */
> href="k17ernel/pid_namespace.c#L17ude 17210"i                input typecode=nsajax_lookua hrens10"i =>id_names17pace.c#L2" id="L2" clas17	  >17310"i        }" id="L12" class="line" name="L12"17 href="k17ernel/pid_namespace.c#L173" i17410"i}" id="L12" class="line" name="L12"17rnel/pid17_namespace.c#L4" id="L417" cl17510"iinput typecode=EXPORT_SYMBOL_GPLajax_lookua hreEXPORT_SYMBOL_GPL;   sajax_lookua hreput_">   s; *    (C) 17200717610"i" id="L12" class="line" name="L12"17>   6>1  *  17710"ivoid
input typecode=zap_">   s_"rocessesajax_lookua hrezap_">   s_"rocesses;   7   9 */
 sajax_lookua hreinit_"> s10"i =183class="line" name="L9">   9   8 *
  allocationajax_lookua hredisable_">  allocation; *    (C) 18200718610"i" id="L12" class="line" name="L12"18>   618 *  18710"i        isass="line" name="L8"/* Ignore SIGCHLD causingpkadeverminated childr="bm.cautoreap>   8 *
   7 */
   9   219e" name="L2">   2  t tut ad inbmhe cgroup-init tut ad group is verminating" id="L5" class="line" name="L5">   5<19 href="k19ernel/pid_namespace.c#L193" i19"L3" class="line" name="L3">        * Find remainingpme="ts inbmhe L5">   5<, signalpkad wait pan>mhem id="L5" class="line" name="L5">   5<19rnel/pid19_namespace.c#L4" id="L419" cl19s="line" name="L4">   4<        * m.cexit" id="L5" class="line" name="L5">   5<19span cla19ss="comment"> *    (C) 19200719avel Emelyanov <xemul@ope        * id="L5" class="line" name="L5">   5<19>   619 *  19710"ine" name="L4">   4<        * Note:  This signals each tut ads inbmhe L5">   5< - ev="bmhosebmhat id="L5" class="line" name="L5">   5<19name="L719">   7   4<        *        belong   5<19 href="k1eernel/pid_namespace.c#L188" i19"L8" class="line" name="L8"<        *        tobwalkbmhe ="Lire tasklist lookingpk "rocesses in
fx/r id="L5" class="line" name="L5">   5<20ref="ker2eel/pid_namespace.c#L9" 2dd="L2dd10"iclass="line" name="L8"<        *        L5">   5<, butbmhat could be unnecessarilycexpensive if the id="L5" class="line" name="L5">   5<20ass="com20ent"> */
has just a few "rocesses. Or we need to id="L5" class="line" name="L5">   5<202ss="com20ernel/pid_namespace.c#L202="L2d210"iclass="line" name="L8"<        *        mainbac# a tasklist pan>each p1   5<20  12e="v20.6.32.>
  3309.6.25.14"203="L20e" name="L2">   2   5<204 12e="v20ernel/pid_namespace.c#L204="L20"L3" class="line" name="L3">        *  8 *
 *    (C) 206n"L20610"i        input typecode=nrajax_lookua hrenr10"i = mapajax_lookua hrenext_"> map;   6207n"L20710"i        while (input typecode=nrajax_lookua hrenr10"i #L12 0) {s="line" name="L9">   9   7   9 */
   9  11#inc2lude 21210"i                        input typecode=send_sig_infoajax_lookua hresend_sig_info;213class="line" name="L9">   9 href="k21ernel/pid_namespace.c#L213" i21410"i                input typecode=rcu_t ad_unlockajax_lookua hrercu_t ad_unlock;5href="k21_namespace.c#L4" id="L421" cl215class="line" name="L9">   9span cla21ss="comment"> *    (C) 21200721610"i                input typecode=nrajax_lookua hrenr10"i = mapajax_lookua hrenext_"> map;>   621 *  21710"i        }" id="L12" class="line" name="L12"2>name="L721">   7 href="k21ernel/pid_namespace.c#L218" i219class="line" name="L9">   9mhe EXIT_ZOMBIE childr="bwe may have. *  8 *
 */
   9  11#inc2uude 22210"i                input typecode=clear_tut ad_flagajax_lookua hreclear_tut ad_flag;22L10"i                input typecode=rcajax_lookua hrerc10"i =   9 *    (C) 22200722610"i        isass="line" name="L8"/* 8 *
   622 *  22710"ine" name="L4">   4<        * sys_wait4() above can'tcreap>mhe TASK_DEAD childr="" id="L5" class="line" name="L5">   5<22name="L722">   7   4<        * Make sure theycall go away, see free_"> ()" id="L5" class="line" name="L5">   5<22 href="k22ernel/pid_namespace.c#L228" i22"L8" class="line" name="L8"<        *  8 *
(;;) {s="line" name="L9">   9 */
 sajax_lookua hreinit_"> s10"i)s="line" name="L9">   923L10"i                        break2" id="L12" class="line" name="L12"23 href="k23ernel/pid_namespace.c#L233" i23410"i                input typecode=sche=ul.ajax_lookua hresche=ul.; *    (C) 23200723610"i        input typecode=__seL_curr="L_st v.ajax_lookua hre__seL_curr="L_st v.;   623 *  237class="line" name="L9">   9   7   9   s; */
24e" na}" id="L12" class="line" name="L12"24 href="k2eernel/pid_namespace.c#L233" i244class="line" name="L9">   9   9 *    (C) 242007246="list v2. int   s_ctl_han=lerajax_lookua hrep>   s_ctl_han=ler;   9   624 *  24710"i                void
input typecode=__u1erajax_lookua hre__u1er10"i *input typecode=bufferajax_lookua hrebuffer10"i, input typecode=size_tajax_lookua hresize_t10"i *input typecode=lenpajax_lookua hrelenp10"i, input typecode=loff_tajax_lookua hreloff_t10"i *input typecode=pposajax_lookua hreppos10"i)s="line" name="L9">   9   7   9   sajax_lookua hretask_   s; */
   9   925L10"i                ace.c"
-input typecode=EPERMajax_lookua hreEPERM10"i2" id="L12" class="line" name="L12"25 href="k25ernel/pid_namespace.c#L253" i254class="line" name="L9">   9 *
 *    (C) 25200725avel Emelyanov <xemul@ope        * Writingpdirectlycto ns'eov t_">  field is OK, since
fx/r field 8 *
   625 *  25710"ine" name="L4">   4<        * /r vol v2le c# a livingpa>anywaypkad a code writingpto id="L5" class="line" name="L5">   5<25name="L725">   7   4<        * it should synchronize its usage with extne"al means" id="L5" class="line" name="L5">   5<2r href="k25ernel/pid_namespace.c#L258" i25"L8" class="line" name="L8"<        *  8 *
 */
 ajax_lookua hrelv t_"> 10"i2" id="L12" class="line" name="L12"26 href="k26ernel/pid_namespace.c#L26ude 26210"i        ace.c"
input typecode="roc_dointvec_minmaxajax_lookua hreproc_dointvec_minmax;26e" na}" id="L12" class="line" name="L12"26 href="k26ernel/pid_namespace.c#L263" i264class="line" name="L9">   9  maxajax_lookua hrep>  max10"i2" id="L12" class="line" name="L12"26span cla2sss="comment"> *    (C) 222007266="list v2. int   626 *  267classt v2. struct   s_ctl_tableajax_lookua hrep>   s_ctl_table10"i[] =<{s="line" name="L9">   9   7   9" s_lv t_"> " 8<,s="line" name="L9">   9ref="ker27el/pid_namespace.c#L9" 27d="L27010"i                .input typecode=maxlenajax_lookua hremaxlen;   9ass="com27ent"> */
 *
 href="k27ernel/pid_namespace.c#L27ude 27210"i                .input typecode=proc_han=lerajax_lookua hreproc_han=ler;   s_ctl_han=ler;   9id_names27pace.c#L2" id="L2" clas27	  >27L10"i                .input typecode=extra1ajax_lookua hreextra1;   9 href="k27ernel/pid_namespace.c#L273" i27410"i                .input typecode=extra2ajax_lookua hreextra2;   9rnel/pid27_namespace.c#L4" id="L427" cl27510"i        },s="line" name="L9">   9span cla27ss="comment"> *    (C) 27200727610"i        { }" id="L12" class="line" name="L12"27>   6>2  *  27710"i}2" id="L12" class="line" name="L12"27name="L727">   7" class" 8<, }, { } }2" id="L12" class="line" name="L12"27 href="k27ernel/pid_namespace.c#L278" i27910"i#endif  isass="line" name="L8"/* CONFIG_CHECKPOINT_RESTORE *  8 *
 */
   sajax_lookua hrerebooL_">   s;   9   928L10"i        if (input typecode="linesajax_lookua hrep>   s;   sajax_lookua hreinit_">   s10"i)s="line" name="L9">   9   9 *    (C) 28200728610"i        switch (input typecode=cm ajax_lookua hrecm 10"i) {s="line" name="L9">   9   628 *  28710"i        case   7   s; */
   929310"i        case   s; *    (C) 29200729610"i        default:" id="L12" class="line" name="L12"29>   629 *  29710"i                ace.c"
-input typecode=EINVALajax_lookua hreEINVAL10"i2" id="L12" class="line" name="L12"29name="L729">   7   9 */
   s;   9   9 *    (C) 306n"L30610"i        isass="line" name="L8"/* Notcreache= *  8 *
   6307n"L30710"i        ace.c"
02" id="L12" class="line" name="L12"30name="L730">   7   9 ns_get;   9 */
   9  11#inc3lude 31210"i        struct313class="line" name="L9">   9 href="k31ernel/pid_namespace.c#L313" i31410"i        input typecode=rcu_t ad_lockajax_lookua hretcu_t ad_lock;5href="k31_namespace.c#L4" id="L431" cl31510"i        input typecode=nsajax_lookua hrens10"i =   sajax_lookua hregeL_">   s;   sajax_lookua hretask_   s;span cla31ss="comment"> *    (C) 31200731610"i        input typecode=rcu_t ad_unlockajax_lookua hrercu_t ad_unlock;>   631 *  317class="line" name="L9">   9name="L731">   7 */
 ns_put;   9  11#inc3uude 32210"i{s="line" name="L9">   932L10"i        input typecode="uL_">   sajax_lookua hreput_">   s;   9 *    (C) 322007326="list v2. int ns_inst llajax_lookua hrep> ns_inst ll;   9   632 *  32710"i{s="line" name="L9">   9   7   sajax_lookua hretask_   s; */
lsajax_lookua hreu1er>ls10"i, input typecode=CAP_SYS_ADMINajax_lookua hreCAP_SYS_ADMIN;   933L10"i                ace.c"
-input typecode=EPERMajax_lookua hreEPERM10"i2" id="L12" class="line" name="L12"33 href="k33ernel/pid_namespace.c#L333" i334class="line" name="L9">   9 *
 *    (C) 33200733avel Emelyanov <xemul@ope        * Onlycallow ul@eringpthe curr="L  *
   633 *  33710"ine" name="L4">   4<        * or a child ofpthe curr="L    5<33name="L733">   7   4<        * id="L5" class="line" name="L5">   5<33 href="k33ernel/pid_namespace.c#L338" i33"L8" class="line" name="L8"<        * This is required pan>pankcto ace.c"
a usable p1and 8 *
 *
 */
   5<34 href="k34ernel/pid_namespace.c#L34ude 34210"iclass="line" name="L8"<        *  8 *
34L10"i        if (input typecode=newajax_lookua hrenew10"i-#L12input typecode=levelajax_lookua hrelevel10"i < input typecode=ac hveajax_lookua hre   9   9 *    (C) 34200734610"i        input typecode=ancestorajax_lookua hreancestor10"i =   634 *  34710"i        while (input typecode=ancestorajax_lookua hreancestor10"i-#L12input typecode=levelajax_lookua hrelevel10"i > input typecode=ac hveajax_lookua hre   9   7   9 */
   9   sajax_lookua hreput_">   s;   s;35L10"i        input typecode=nsproxyajax_lookua hrensproxy10"i-#L12input typecode="e="esajax_lookua hrep>   s;   sajax_lookua hregeL_">   s; *    (C) 35200735610"i" id="L12" class="line" name="L12"35>   635 *  357classt v2. unsigned int ns_inumajax_lookua hrep> ns_inum;   9   7   9   s; */
36e" naconst struct ns_operationsajax_lookua hrep> ns_operations;   9"p> " 8<,s="line" name="L9">   9   9 *    (C) 32200736610"i        .input typecode=getajax_lookua hreget; ns_getajax_lookua hre"> ns_get;   9   636 *  36710"i        .input typecode=putajax_lookua hre"ut; ns_putajax_lookua hre"> ns_put;   9   7 ns_inst llajax_lookua hrep> ns_inst ll;   9 ns_inumajax_lookua hrep> ns_inum;   9ref="ker37el/pid_namespace.c#L9" 37d="L37010"i}2" id="L12" class="line" name="L12"3>ass="com37ent"> */
   9 href="k37ernel/pid_namespace.c#L37ude 37210"ist v2. input typecode=__initajax_lookua hre__init10"i int   9   9   9id_names37pace.c#L2" id="L2" clas37	  >37L10"i{s="line" name="L9">   9 href="k37ernel/pid_namespace.c#L373" i37410"i        input typecode=p>   s_cachepajax_lookua hrep>   s_cachep;rnel/pid37_namespace.c#L4" id="L437" cl375class="line" name="L9">   9span cla37ss="comment"> *    (C) 37200737610"i#ifdef   9   6>3  *  37710"i        input typecode=register_sysctl_pathsajax_lookua hreregister_sysctl_paths;   s_ctl_table10"i)2" id="L12" class="line" name="L12"3>name="L737">   7 href="k37ernel/pid_namespace.c#L378" i37910"i        ace.c"
02" id="L12" class="line" name="L12"38ref="ker38el/pid_namespace.c#L9" 38d="L38010"i}" id="L12" class="line" name="L12"38ass="com38ent"> */
   938L10"i


The origi"al LXR software bybmhe id="L12"http://sourceforge.net/projects/lxr">LXR nameunity10"i, fx/r experie="Lal version byb id="L12"mailto:lxr@ idux.no">lxr@ idux.no10"i.
lxr. idux.no kindly hosted byb id="L12"http://www.redpill- idpro.no">Redpill Lidpro AS10"i, provider ofpLidux consultingpkad operations servisps since 1995.