linux/ipc/compat_mq.c
<<
v3.17v3.17v3//spa229v3/spa2 class="lxr_search">v3.1 2="+search" method="post" onsubmit="return do_search(this);">v3.17.ihidden" nam>.inavtarget" 2n>.i">v3.17.itext" nam>.isearch" id.isearch">v3.17typ>.isubmit">Searchv3.17v3//spa229.17< 2="ajax+*" method="post" onsubmit="return false;">v3/input typ>.ihidden" nam>.iajax_lookup" id.iajax_lookup" 2n>.i">v.17< 9 /div id.ifile_contents"2
.iL1">< <1//a>/spa2 class="comment">/*//spa229.iL2">< <2//a>/spa2 class="comment"> *  ipc/compat_mq.c//spa229.iL3">< <3//a>/spa2 class="comment"> *   <32 bit emulatio2>for POSIX message queue system calls//spa229.iL4">< <4//a>/spa2 class="comment"> *//spa229.iL5">< <5//a>/spa2 class="comment"> *   .iL6">< <6//a>/spa2 class="comment"> *   .iL7">< <7//a>/spa2 class="comment"> *///spa229.iL8">< <8//a>v.iL9">< <9//a>#include <linux/compat.h//a>>v.iL10"><   v3a>#include <linux/fs.h//a>>v.iL11">< 11v3a>#include <linux/kernel.h//a>>v.iL12">< 12v3a>#include <linux/mqueue.h//a>>v.iL13">< 13v3a>#include <linux/syscalls.h//a>>v.iL14">< 14//a>v.iL15">< 15v3a>#include <asm/uaccess.h//a>>v.iL16">< 16//a>v.iL17">< 17//a>structcompat_mq_attr//a> {v.iL18">< 18//a>        /a href="+code=compat_long_t" class="sref">compat_long_t//a> /a href="+code=mq_flags" class="sref">mq_flags//a>;      /spa2 class="comment">/* message queue flags                  *///spa229.iL19">< 19//a>        /a href="+code=compat_long_t" class="sref">compat_long_t//a> /a href="+code=mq_maxmsg" class="sref">mq_maxmsg//a>;     /spa2 class="comment">/* maximum number of messages           *///spa229.iL20">< 20//a>        /a href="+code=compat_long_t" class="sref">compat_long_t//a> /a href="+code=mq_msgsize" class="sref">mq_msgsize//a>;    /spa2 class="comment">/* maximum message size                 *///spa229.iL21">< 21//a>        /a href="+code=compat_long_t" class="sref">compat_long_t//a> /a href="+code=mq_curmsgs" class="sref">mq_curmsgs//a>;    /spa2 class="comment">/* number of messages currently queued  *///spa229.iL22">< 22//a>        /a href="+code=compat_long_t" class="sref">compat_long_t//a> /a href="+code=__reserved" class="sref">__reserved//a>[4]; /spa2 class="comment">/* ignored for input, zeroed for output *///spa229.iL23">< 23v3a>};v.iL24">< 24//a>v.iL25">< 25//a>static /a href="+code=inline" class="sref">inline//a> intget_compat_mq_attr//a>(structmq_attr//a> */a href="+code=attr" class="sref">attr//a>,v.iL26">< 26//a>                        const structcompat_mq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=uattr" class="sref">uattr//a>)v.iL27">< 27//a>{v.iL28">< 28//a>        if (!/a href="+code=access_ok" class="sref">access_ok//a>(/a href="+code=VERIFY_READ" class="sref">VERIFY_READ//a>, /a href="+code=uattr" class="sref">uattr//a>, sizeof */a href="+code=uattr" class="sref">uattr//a>))v.iL29">< 29//a>                return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL30">< 30//a>v.iL31">< 31//a>        return /a href="+code=__get_user" class="sref">__get_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_flags" class="sref">mq_flags//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_flags" class="sref">mq_flags//a>)v.iL32">< 32//a>                | /a href="+code=__get_user" class="sref">__get_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_maxmsg" class="sref">mq_maxmsg//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_maxmsg" class="sref">mq_maxmsg//a>)v.iL33">< 33//a>                | /a href="+code=__get_user" class="sref">__get_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_msgsize" class="sref">mq_msgsize//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_msgsize" class="sref">mq_msgsize//a>)v.iL34">< 34//a>                | /a href="+code=__get_user" class="sref">__get_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_curmsgs" class="sref">mq_curmsgs//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_curmsgs" class="sref">mq_curmsgs//a>);9.iL35">< 35//a>}9.iL36">< 36//a>v.iL37">< 37//a>static /a href="+code=inline" class="sref">inline//a> intput_compat_mq_attr//a>(const structmq_attr//a> */a href="+code=attr" class="sref">attr//a>,v.iL38">< 38//a>                        structcompat_mq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=uattr" class="sref">uattr//a>)v.iL39">< 39//a>{v.iL40">< 40//a>        if (/a href="+code=clear_user" class="sref">clear_user//a>(/a href="+code=uattr" class="sref">uattr//a>, sizeof */a href="+code=uattr" class="sref">uattr//a>))v.iL41">< 41//a>                return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL42">< 42//a>v.iL43">< 43//a>        return /a href="+code=__put_user" class="sref">__put_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_flags" class="sref">mq_flags//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_flags" class="sref">mq_flags//a>)v.iL44">< 44//a>                | /a href="+code=__put_user" class="sref">__put_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_maxmsg" class="sref">mq_maxmsg//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_maxmsg" class="sref">mq_maxmsg//a>)v.iL45">< 45//a>                | /a href="+code=__put_user" class="sref">__put_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_msgsize" class="sref">mq_msgsize//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_msgsize" class="sref">mq_msgsize//a>)v.iL46">< 46//a>                | /a href="+code=__put_user" class="sref">__put_user//a>(/a href="+code=attr" class="sref">attr//a>->/a href="+code=mq_curmsgs" class="sref">mq_curmsgs//a>, &/a href="+code=uattr" class="sref">uattr//a>->/a href="+code=mq_curmsgs" class="sref">mq_curmsgs//a>);9.iL47">< 47//a>}9.iL48">< 48//a>v.iL49">< 49//a>/a href="+code=asmlinkage" class="sref">asmlinkage//a> longcompat_sys_mq_open//a>(const char /a href="+code=__user" class="sref">__user//a> */a href="+code=u_nam>" class="sref">u_nam>//a>,v.iL50">< 50//a>                        intoflag//a>, /a href="+code=compat_mode_t" class="sref">compat_mode_t//a> /a href="+code=mode" class="sref">mode//a>,v.iL51">< 51//a>                        structcompat_mq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_attr" class="sref">u_attr//a>)v.iL52">< 52//a>{v.iL53">< 53//a>        void /a href="+code=__user" class="sref">__user//a> */a href="+code=p" class="sref">p//a> = /a href="+code=NULL" class="sref">NULL//a>;9.iL54">< 54//a>        if (/a href="+code=u_attr" class="sref">u_attr//a> &&oflag//a> &O_CREAT//a>) {v.iL55">< 55//a>                structmq_attr//a> /a href="+code=attr" class="sref">attr//a>;9.iL56">< 56//a>v.iL57">< 57//a>                /a href="+code=memset" class="sref">memset//a>(&/a href="+code=attr" class="sref">attr//a>, 0, sizeof(/a href="+code=attr" class="sref">attr//a>));9.iL58">< 58//a>v.iL59">< 59//a>                /a href="+code=p" class="sref">p//a> = /a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space//a>(sizeof(/a href="+code=attr" class="sref">attr//a>));9.iL60">< 60//a>                if (/a href="+code=get_compat_mq_attr" class="sref">get_compat_mq_attr//a>(&/a href="+code=attr" class="sref">attr//a>, /a href="+code=u_attr" class="sref">u_attr//a>) ||9.iL61">< 61//a>                    /a href="+code=copy_to_user" class="sref">copy_to_user//a>(/a href="+code=p" class="sref">p//a>, &/a href="+code=attr" class="sref">attr//a>, sizeof(/a href="+code=attr" class="sref">attr//a>)))v.iL62">< 62//a>                        return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL63">< 63//a>        }9.iL64">< 64//a>        return /a href="+code=sys_mq_open" class="sref">sys_mq_open//a>(/a href="+code=u_nam>" class="sref">u_nam>//a>,oflag//a>, /a href="+code=mode" class="sref">mode//a>, /a href="+code=p" class="sref">p//a>);9.iL65">< 65//a>}9.iL66">< 66//a>v.iL67">< 67//a>static intcompat_prepare_timeout//a>(structtimespec//a> /a href="+code=__user" class="sref">__user//a> * */a href="+code=p" class="sref">p//a>,v.iL68">< 68//a>                                  const structcompat_timespec//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u" class="sref">u//a>)v.iL69">< 69//a>{v.iL70">< 70//a>        structtimespec//a> /a href="+code=ts" class="sref">ts//a>;9.iL71">< 71//a>        if (!/a href="+code=u" class="sref">u//a>) {v.iL72">< 72//a>                */a href="+code=p" class="sref">p//a> = /a href="+code=NULL" class="sref">NULL//a>;9.iL73">< 73//a>                return 0;9.iL74">< 74//a>        }9.iL75">< 75//a>        */a href="+code=p" class="sref">p//a> = /a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space//a>(sizeof(/a href="+code=ts" class="sref">ts//a>));9.iL76">< 76//a>        if (/a href="+code=get_compat_timespec" class="sref">get_compat_timespec//a>(&/a href="+code=ts" class="sref">ts//a>, /a href="+code=u" class="sref">u//a>) || /a href="+code=copy_to_user" class="sref">copy_to_user//a>(*/a href="+code=p" class="sref">p//a>, &/a href="+code=ts" class="sref">ts//a>, sizeof(/a href="+code=ts" class="sref">ts//a>)))v.iL77">< 77//a>                return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL78">< 78//a>        return 0;9.iL79">< 79//a>}9.iL80">< 80//a>v.iL81">< 81//a>/a href="+code=asmlinkage" class="sref">asmlinkage//a> longcompat_sys_mq_timedsend//a>(/a href="+code=mqd_t" class="sref">mqd_t//a> /a href="+code=mqdes" class="sref">mqdes//a>,v.iL82">< 82//a>                        const char /a href="+code=__user" class="sref">__user//a> */a href="+code=u_msg_ptr" class="sref">u_msg_ptr//a>,v.iL83">< 83//a>                        /a href="+code=size_t" class="sref">size_t//a> /a href="+code=msg_len" class="sref">msg_len//a>, unsigned intmsg_prio//a>,v.iL84">< 84//a>                        const structcompat_timespec//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_abs_timeout" class="sref">u_abs_timeout//a>)v.iL85">< 85//a>{v.iL86">< 86//a>        structtimespec//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_ts" class="sref">u_ts//a>;9.iL87">< 87//a>v.iL88">< 88//a>        if (/a href="+code=compat_prepare_timeout" class="sref">compat_prepare_timeout//a>(&/a href="+code=u_ts" class="sref">u_ts//a>, /a href="+code=u_abs_timeout" class="sref">u_abs_timeout//a>))v.iL89">< 89//a>                return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL90">< 90//a>v.iL91">< 91//a>        return /a href="+code=sys_mq_timedsend" class="sref">sys_mq_timedsend//a>(/a href="+code=mqdes" class="sref">mqdes//a>, /a href="+code=u_msg_ptr" class="sref">u_msg_ptr//a>, /a href="+code=msg_len" class="sref">msg_len//a>,v.iL92">< 92//a>                        /a href="+code=msg_prio" class="sref">msg_prio//a>, /a href="+code=u_ts" class="sref">u_ts//a>);9.iL93">< 93//a>}9.iL94">< 94//a>v.iL95">< 95//a>/a href="+code=asmlinkage" class="sref">asmlinkage//a> /a href="+code=ssize_t" class="sref">ssize_t//a> /a href="+code=compat_sys_mq_timedreceive" class="sref">compat_sys_mq_timedreceive//a>(/a href="+code=mqd_t" class="sref">mqd_t//a> /a href="+code=mqdes" class="sref">mqdes//a>,v.iL96">< 96//a>                        char /a href="+code=__user" class="sref">__user//a> */a href="+code=u_msg_ptr" class="sref">u_msg_ptr//a>,v.iL97">< 97//a>                        /a href="+code=size_t" class="sref">size_t//a> /a href="+code=msg_len" class="sref">msg_len//a>, unsigned int__user//a> */a href="+code=u_msg_prio" class="sref">u_msg_prio//a>,v.iL98">< 98//a>                        const structcompat_timespec//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_abs_timeout" class="sref">u_abs_timeout//a>)v.iL99">< 99//a>{v.iL100"><100//a>        structtimespec//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_ts" class="sref">u_ts//a>;9.iL101"><101//a>        if (/a href="+code=compat_prepare_timeout" class="sref">compat_prepare_timeout//a>(&/a href="+code=u_ts" class="sref">u_ts//a>, /a href="+code=u_abs_timeout" class="sref">u_abs_timeout//a>))v.iL102"><102//a>                return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL103"><103//a>v.iL104"><104//a>        return /a href="+code=sys_mq_timedreceive" class="sref">sys_mq_timedreceive//a>(/a href="+code=mqdes" class="sref">mqdes//a>, /a href="+code=u_msg_ptr" class="sref">u_msg_ptr//a>, /a href="+code=msg_len" class="sref">msg_len//a>,v.iL105"><105//a>                        /a href="+code=u_msg_prio" class="sref">u_msg_prio//a>, /a href="+code=u_ts" class="sref">u_ts//a>);9.iL106"><106//a>}9.iL107"><107//a>v.iL108"><108//a>/a href="+code=asmlinkage" class="sref">asmlinkage//a> longcompat_sys_mq_notify//a>(/a href="+code=mqd_t" class="sref">mqd_t//a> /a href="+code=mqdes" class="sref">mqdes//a>,v.iL109"><109//a>                        const structcompat_sigevent//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_notificatio2" class="sref">u_notificatio2//a>)v.iL110"><1  v3a>{v.iL111"><111//a>        structsigevent//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=p" class="sref">p//a> = /a href="+code=NULL" class="sref">NULL//a>;9.iL112"><112//a>        if (/a href="+code=u_notificatio2" class="sref">u_notificatio2//a>) {v.iL113"><113//a>                structsigevent//a> /a href="+code=2" class="sref">n//a>;9.iL114"><114//a>                /a href="+code=p" class="sref">p//a> = /a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space//a>(sizeof(*/a href="+code=p" class="sref">p//a>));9.iL115"><115//a>                if (/a href="+code=get_compat_sigevent" class="sref">get_compat_sigevent//a>(&/a href="+code=2" class="sref">n//a>, /a href="+code=u_notificatio2" class="sref">u_notificatio2//a>))v.iL116"><116//a>                        return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL117"><117//a>                if (/a href="+code=2" class="sref">n//a>./a href="+code=sigev_notify" class="sref">sigev_notify//a> == /a href="+code=SIGEV_THREAD" class="sref">SIGEV_THREAD//a>)v.iL118"><118//a>                        /a href="+code=2" class="sref">n//a>./a href="+code=sigev_  2n>" class="sref">sigev_  2n>//a>./a href="+code=si  2_ptr" class="sref">si  2_ptr//a> = /a href="+code=compat_ptr" class="sref">compat_ptr//a>(/a href="+code=2" class="sref">n//a>./a href="+code=sigev_  2n>" class="sref">sigev_  2n>//a>./a href="+code=si  2_int" class="sref">si  2_int//a>);9.iL119"><119//a>                if (/a href="+code=copy_to_user" class="sref">copy_to_user//a>(/a href="+code=p" class="sref">p//a>, &/a href="+code=2" class="sref">n//a>, sizeof(*/a href="+code=p" class="sref">p//a>)))v.iL120"><120//a>                        return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL121"><121//a>        }9.iL122"><122//a>        return /a href="+code=sys_mq_notify" class="sref">sys_mq_notify//a>(/a href="+code=mqdes" class="sref">mqdes//a>, /a href="+code=p" class="sref">p//a>);9.iL123"><123//a>}9.iL124"><124//a>v.iL125"><125//a>/a href="+code=asmlinkage" class="sref">asmlinkage//a> longcompat_sys_mq_getsetattr//a>(/a href="+code=mqd_t" class="sref">mqd_t//a> /a href="+code=mqdes" class="sref">mqdes//a>,v.iL126"><126//a>                        const structcompat_mq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_mqstat" class="sref">u_mqstat//a>,v.iL127"><127//a>                        structcompat_mq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=u_omqstat" class="sref">u_omqstat//a>)v.iL128"><128//a>{v.iL129"><129//a>        structmq_attr//a> /a href="+code=mqstat" class="sref">mqstat//a>;v.iL130"><130//a>        structmq_attr//a> /a href="+code=__user" class="sref">__user//a> */a href="+code=p" class="sref">p//a> = /a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space//a>(2 * sizeof(*/a href="+code=p" class="sref">p//a>));v.iL131"><131//a>        longret//a>;v.iL132"><132//a>v.iL133"><133//a>        /a href="+code=memset" class="sref">memset//a>(&/a href="+code=mqstat" class="sref">mqstat//a>, 0, sizeof(/a href="+code=mqstat" class="sref">mqstat//a>));v.iL134"><134//a>v.iL135"><135//a>        if (/a href="+code=u_mqstat" class="sref">u_mqstat//a>) {v.iL136"><136//a>                if (/a href="+code=get_compat_mq_attr" class="sref">get_compat_mq_attr//a>(&/a href="+code=mqstat" class="sref">mqstat//a>, /a href="+code=u_mqstat" class="sref">u_mqstat//a>) ||9.iL137"><137//a>                    /a href="+code=copy_to_user" class="sref">copy_to_user//a>(/a href="+code=p" class="sref">p//a>, &/a href="+code=mqstat" class="sref">mqstat//a>, sizeof(/a href="+code=mqstat" class="sref">mqstat//a>)))v.iL138"><138//a>                        return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL139"><139//a>        }9.iL140"><140//a>        /a href="+code=ret" class="sref">ret//a> = /a href="+code=sys_mq_getsetattr" class="sref">sys_mq_getsetattr//a>(/a href="+code=mqdes" class="sref">mqdes//a>,v.iL141"><141//a>                                /a href="+code=u_mqstat" class="sref">u_mqstat//a> ? /a href="+code=p" class="sref">p//a> : /a href="+code=NULL" class="sref">NULL//a>,v.iL142"><142//a>                                /a href="+code=u_omqstat" class="sref">u_omqstat//a> ? /a href="+code=p" class="sref">p//a> + 1 : /a href="+code=NULL" class="sref">NULL//a>);v.iL143"><143//a>        if (/a href="+code=ret" class="sref">ret//a>)v.iL144"><144//a>                return /a href="+code=ret" class="sref">ret//a>;v.iL145"><145//a>        if (/a href="+code=u_omqstat" class="sref">u_omqstat//a>) {v.iL146"><146//a>                if (/a href="+code=copy_from_user" class="sref">copy_from_user//a>(&/a href="+code=mqstat" class="sref">mqstat//a>, /a href="+code=p" class="sref">p//a> + 1, sizeof(/a href="+code=mqstat" class="sref">mqstat//a>)) ||9.iL147"><147//a>                    /a href="+code=put_compat_mq_attr" class="sref">put_compat_mq_attr//a>(&/a href="+code=mqstat" class="sref">mqstat//a>, /a href="+code=u_omqstat" class="sref">u_omqstat//a>))v.iL148"><148//a>                        return -/a href="+code=EFAULT" class="sref">EFAULT//a>;9.iL149"><149//a>        }9.iL150"><150//a>        return 0;9.iL151"><151//a>}9.iL152"><152//a>
The original LXR software by the LXR community//a>, this experimental versio2>by lxr@linux.no//a>. //div29/div class="subfooter"> lxr.linux.no kindly hosted>by Redpill Linpro AS//a>, provider of Linux consulting