linux/ipc/ipcns_notifier.c
<<
> v/spa v/form va > href="../linux+v32.52/ipc/ipcns_notifier.c">> vimg src="../.static/gfx/right.png" alt=">>">> v/spa > vspa class="lxr_search">> > vinput typopthidden" namoptnavtarget" 11> vinput typopttext" namoptsearch" idptsearch">> vbutt22.typoptsubmit">Search vspa class="lxr_prefs" va href="+prefs?return=ipc/ipcns_notifier.c"> onclick="return ajax_prefs();">> Prefs v/a>> v/spa v/div vform ac11" ="ajax+*" method="post" onsubmit="return false;">> vinput typopthidden" namoptajax_lookup" idptajax_lookup" 11> v/form > vdiv class="headingbott2m">
vdiv idptfile_contents"
   1v/a>vspa
 class="comment">/*v/spa
	    2v/a>vspa
 class="comment"> * linux/ipc/ipcns_notifier.cv/spa
	    3v/a>vspa
 class="comment"> * Copyright (C) 2007 BULL SA. Nadia Derbeyv/spa
	    4v/a>vspa
 class="comment"> *v/spa
	    5v/a>vspa
 class="comment"> * Notifica6.22.mechanism for ipc namospaces:v/spa
	    6v/a>vspa
 class="comment"> * The callback routine registered i2.the memory chai2.invokes.the ipcnsv/spa
	    7v/a>vspa
 class="comment"> * notifier chai2.with.the IPCNS_MEMCHANGED event.v/spa
	    8v/a>vspa
 class="comment"> * Each callback routine registered i2.the ipcns namospace recomputes.msgmniv/spa
	    9v/a>vspa
 class="comment"> * for the owning namospace.v/spa
	   .6.2a>vspa
 class="comment"> */v/spa
	   11v/a>   12v/a>#include <linux/msg.hv/a>>   13v/a>#include <linux/rcupdate.hv/a>>   14v/a>#include <linux/notifier.hv/a>>   15v/a>#include <linux/nsproxy.hv/a>>   16v/a>#include <linux/ipc_namospace.hv/a>>   17v/a>   18v/a>#include "util.hv/a>"   19v/a>   20v/a>   21v/a>   22v/a>static va href="+code=BLOCKING_NOTIFIER_HEAD" class="sref">BLOCKING_NOTIFIER_HEADv/a>(va href="+code=ipcns_chai2" class="sref">ipcns_chai2v/a>);   23v/a>   24v/a>   25v/a>static int va href="+code=ipcns_callback" class="sref">ipcns_callbackv/a>(struct va href="+code=notifier_block" class="sref">notifier_blockv/a> *va href="+code=self" class="sref">selfv/a>,   26v/a>                                unsigned long va href="+code=ac11"
" class="sref">ac11"
v/a>, void *va href="+code=arg" class="sref">argv/a>)   27v/a>{   28v/a>        struct va href="+code=ipc_namospace" class="sref">ipc_namospacev/a> *va href="+code=ns" class="sref">nsv/a>;   29v/a>   30v/a>        switch (va href="+code=ac11"
" class="sref">ac11"
v/a>) {   31v/a>        case va href="+code=IPCNS_MEMCHANGED" class="sref">IPCNS_MEMCHANGEDv/a>:   vspa
 class="comment">/* amount of lowmem has changed */v/spa
	   32v/a>        case va href="+code=IPCNS_CREATED" class="sref">IPCNS_CREATEDv/a>:   33v/a>        case va href="+code=IPCNS_REMOVED" class="sref">IPCNS_REMOVEDv/a>:   34v/a>                vspa
 class="comment">/*v/spa
	   35v/a>vspa
 class="comment">                 * It's.time to recompute.msgmniv/spa
	   36v/a>vspa
 class="comment">                 */v/spa
	   37v/a>                va href="+code=ns" class="sref">nsv/a> = va href="+code=contai2er_of" class="sref">contai2er_ofv/a>(va href="+code=self" class="sref">selfv/a>, struct va href="+code=ipc_namospace" class="sref">ipc_namospacev/a>, va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>);   38v/a>                vspa
 class="comment">/*v/spa
	   39v/a>vspa
 class="comment">                 * No need to get a reference o2.the ns:.the 1st job ofv/spa
	   46.2a>vspa
 class="comment">                 * free_ipc_ns() is to unregister.the callback routine.v/spa
	   41v/a>vspa
 class="comment">                 * blocking_notifier_chai2_unregister.takes.the wr lock to dov/spa
	   42v/a>vspa
 class="comment">                 * it.v/spa
	   43v/a>vspa
 class="comment">                 * Whe2.this callback routine is called the rd lock is held byv/spa
	   44v/a>vspa
 class="comment">                 * blocking_notifier_call_chai2.v/spa
	   45v/a>vspa
 class="comment">                 * So.the ipc ns cannot be freed while we are here.v/spa
	   46v/a>vspa
 class="comment">                 */v/spa
	   47v/a>                va href="+code=recompute_msgmni" class="sref">recompute_msgmniv/a>(va href="+code=ns" class="sref">nsv/a>);   48v/a>                break;   49v/a>        default:   50v/a>                break;   51v/a>        }   52v/a>   53v/a>        return va href="+code=NOTIFY_OK" class="sref">NOTIFY_OKv/a>;   54v/a>}   55v/a>   56v/a>int va href="+code=register_ipcns_notifier" class="sref">register_ipcns_notifierv/a>(struct va href="+code=ipc_namospace" class="sref">ipc_namospacev/a> *va href="+code=ns" class="sref">nsv/a>)   57v/a>{   58v/a>        int va href="+code=rc" class="sref">rcv/a>;   59v/a>   60v/a>        va href="+code=memset" class="sref">memsetv/a>(&va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>, 0, sizeof(va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>));   61v/a>        va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>.va href="+code=notifier_call" class="sref">notifier_callv/a> = va href="+code=ipcns_callback" class="sref">ipcns_callbackv/a>;   62v/a>        va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>.va href="+code=priority" class="sref">priorityv/a> = va href="+code=IPCNS_CALLBACK_PRI" class="sref">IPCNS_CALLBACK_PRIv/a>;   63v/a>        va href="+code=rc" class="sref">rcv/a> = va href="+code=blocking_notifier_chai2_register" class="sref">blocking_notifier_chai2_registerv/a>(&va href="+code=ipcns_chai2" class="sref">ipcns_chai2v/a>, &va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>);   64v/a>        if (!va href="+code=rc" class="sref">rcv/a>)   65v/a>                va href="+code=ns" class="sref">nsv/a>->va href="+code=auto_msgmni" class="sref">auto_msgmniv/a> = 1;   66v/a>        return va href="+code=rc" class="sref">rcv/a>;   67v/a>}   68v/a>   69v/a>int va href="+code=cond_register_ipcns_notifier" class="sref">cond_register_ipcns_notifierv/a>(struct va href="+code=ipc_namospace" class="sref">ipc_namospacev/a> *va href="+code=ns" class="sref">nsv/a>)   70v/a>{   71v/a>        int va href="+code=rc" class="sref">rcv/a>;   72v/a>   73v/a>        va href="+code=memset" class="sref">memsetv/a>(&va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>, 0, sizeof(va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>));   74v/a>        va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>.va href="+code=notifier_call" class="sref">notifier_callv/a> = va href="+code=ipcns_callback" class="sref">ipcns_callbackv/a>;   75v/a>        va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>.va href="+code=priority" class="sref">priorityv/a> = va href="+code=IPCNS_CALLBACK_PRI" class="sref">IPCNS_CALLBACK_PRIv/a>;   76v/a>        va href="+code=rc" class="sref">rcv/a> = va href="+code=blocking_notifier_chai2_cond_register" class="sref">blocking_notifier_chai2_cond_registerv/a>(&va href="+code=ipcns_chai2" class="sref">ipcns_chai2v/a>,   77v/a>                                                        &va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>);   78v/a>        if (!va href="+code=rc" class="sref">rcv/a>)   79v/a>                va href="+code=ns" class="sref">nsv/a>->va href="+code=auto_msgmni" class="sref">auto_msgmniv/a> = 1;   80v/a>        return va href="+code=rc" class="sref">rcv/a>;   81v/a>}   82v/a>   83v/a>void va href="+code=unregister_ipcns_notifier" class="sref">unregister_ipcns_notifierv/a>(struct va href="+code=ipc_namospace" class="sref">ipc_namospacev/a> *va href="+code=ns" class="sref">nsv/a>)   84v/a>{   85v/a>        va href="+code=blocking_notifier_chai2_unregister" class="sref">blocking_notifier_chai2_unregisterv/a>(&va href="+code=ipcns_chai2" class="sref">ipcns_chai2v/a>, &va href="+code=ns" class="sref">nsv/a>->va href="+code=ipcns_nb" class="sref">ipcns_nbv/a>);   86v/a>        va href="+code=ns" class="sref">nsv/a>->va href="+code=auto_msgmni" class="sref">auto_msgmniv/a> = 0;   87v/a>}   88v/a>   89v/a>int va href="+code=ipcns_notify" class="sref">ipcns_notifyv/a>(unsigned long va href="+code=val" class="sref">valv/a>)   90v/a>{   91v/a>        return va href="+code=blocking_notifier_call_chai2" class="sref">blocking_notifier_call_chai2v/a>(&va href="+code=ipcns_chai2" class="sref">ipcns_chai2v/a>, va href="+code=val" class="sref">valv/a>, va href="+code=NULL" class="sref">NULLv/a>);   92v/a>}   93v/a>v/pre>
The original LXR software by.the LXR communityv/a>,.this experimental vers.22.by.lxr@linux.nov/a>. v/div vdiv class="subfooter"> lxr.linux.no kindly hosted.by.Redpill Linpro ASv/a>,.provider of Linux consulting and opera6.22s services since 1995. v/div v/body v/html