linux/ipc/compat_mq.c
<<
v">Search v">e 1div id vfile_contents"u
. .11/a>1spal class="comment">/*1/spalue. .21/a>1spal class="comment"> *  ipc/compat_mq.c1/spalue. .31/a>1spal class="comment"> *   .32 bit emula12"
	for POSIX message queue system calls1/spalue. .41/a>1spal class="comment"> *1/spalue. .51/a>1spal class="comment"> *   .Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corpora12"
1/spalue. .61/a>1spal class="comment"> *   .Author: Arnd Bergmann <arnd@arndb.de>1/spalue. .71/a>1spal class="comment"> */1/spalue. .81/a><. .91/a>#include <linux/compat.h1/a>><.  #include <linux/fs.h1/a>><. 11opa>#include <linux/kernel.h1/a>><. 12opa>#include <linux/mqueue.h1/a>><. 13opa>#include <linux/syscalls.h1/a>><. 141/a><. 15opa>#include <asm/uaccess.h1/a>><. 161/a><. 171/a>struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> {<. 181/a>        1a href="+code=compat_long_t" class="sref">compat_long_t1/a> 1a href="+code=mq_flags" class="sref">mq_flags1/a>;      1spal class="comment">/* message queue flags                  */1/spalue. 191/a>        1a href="+code=compat_long_t" class="sref">compat_long_t1/a> 1a href="+code=mq_maxmsg" class="sref">mq_maxmsg1/a>;     1spal class="comment">/* maximum number of messages           */1/spalue. 201/a>        1a href="+code=compat_long_t" class="sref">compat_long_t1/a> 1a href="+code=mq_msgsize" class="sref">mq_msgsize1/a>;    1spal class="comment">/* maximum message size                 */1/spalue. 211/a>        1a href="+code=compat_long_t" class="sref">compat_long_t1/a> 1a href="+code=mq_curmsgs" class="sref">mq_curmsgs1/a>;    1spal class="comment">/* number of messages currently queued  */1/spalue. 221/a>        1a href="+code=compat_long_t" class="sref">compat_long_t1/a> 1a href="+code=__reserved" class="sref">__reserved1/a>[4]; 1spal class="comment">/* ignored for input, zeroed for output */1/spalue. 23opa>};<. 241/a><. 251/a>static 1a href="+code=inline" class="sref">inline1/a> int.1a href="+code=get_compat_mq_attr" class="sref">get_compat_mq_attr1/a>(struct.1a href="+code=mq_attr" class="sref">mq_attr1/a> *1a href="+code=attr" class="sref">attr1/a>,<. 261/a>                        const struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=uattr" class="sref">uattr1/a>)<. 271/a>{<. 281/a>        if (!1a href="+code=access_ok" class="sref">access_ok1/a>(1a href="+code=VERIFY_READ" class="sref">VERIFY_READ1/a>, 1a href="+code=uattr" class="sref">uattr1/a>, sizeof *1a href="+code=uattr" class="sref">uattr1/a>))<. 291/a>                return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e. 301/a><. 311/a>        return 1a href="+code=__get_user" class="sref">__get_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_flags" class="sref">mq_flags1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_flags" class="sref">mq_flags1/a>)<. 321/a>                | 1a href="+code=__get_user" class="sref">__get_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_maxmsg" class="sref">mq_maxmsg1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_maxmsg" class="sref">mq_maxmsg1/a>)<. 331/a>                | 1a href="+code=__get_user" class="sref">__get_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_msgsize" class="sref">mq_msgsize1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_msgsize" class="sref">mq_msgsize1/a>)<. 341/a>                | 1a href="+code=__get_user" class="sref">__get_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_curmsgs" class="sref">mq_curmsgs1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_curmsgs" class="sref">mq_curmsgs1/a>);e. 351/a>}e. 361/a><. 371/a>static 1a href="+code=inline" class="sref">inline1/a> int.1a href="+code=put_compat_mq_attr" class="sref">put_compat_mq_attr1/a>(const struct.1a href="+code=mq_attr" class="sref">mq_attr1/a> *1a href="+code=attr" class="sref">attr1/a>,<. 381/a>                        struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=uattr" class="sref">uattr1/a>)<. 391/a>{<. 401/a>        if (1a href="+code=clear_user" class="sref">clear_user1/a>(1a href="+code=uattr" class="sref">uattr1/a>, sizeof *1a href="+code=uattr" class="sref">uattr1/a>))<. 411/a>                return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e. 421/a><. 431/a>        return 1a href="+code=__put_user" class="sref">__put_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_flags" class="sref">mq_flags1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_flags" class="sref">mq_flags1/a>)<. 441/a>                | 1a href="+code=__put_user" class="sref">__put_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_maxmsg" class="sref">mq_maxmsg1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_maxmsg" class="sref">mq_maxmsg1/a>)<. 451/a>                | 1a href="+code=__put_user" class="sref">__put_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_msgsize" class="sref">mq_msgsize1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_msgsize" class="sref">mq_msgsize1/a>)<. 461/a>                | 1a href="+code=__put_user" class="sref">__put_user1/a>(1a href="+code=attr" class="sref">attr1/a>->1a href="+code=mq_curmsgs" class="sref">mq_curmsgs1/a>, &1a href="+code=uattr" class="sref">uattr1/a>->1a href="+code=mq_curmsgs" class="sref">mq_curmsgs1/a>);e. 471/a>}e. 481/a><. 491/a>1a href="+code=asmlinkage" class="sref">asmlinkage1/a> long.1a href="+code=compat_sys_mq_open" class="sref">compat_sys_mq_open1/a>(const char 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_nam " class="sref">u_nam 1/a>,<. 501/a>                        int.1a href="+code=oflag" class="sref">oflag1/a>, 1a href="+code=compat_mode_t" class="sref">compat_mode_t1/a> 1a href="+code=mode" class="sref">mode1/a>,<. 511/a>                        struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_attr" class="sref">u_attr1/a>)<. 521/a>{<. 531/a>        void 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=p" class="sref">p1/a> = 1a href="+code=NULL" class="sref">NULL1/a>;e. 541/a>        if (1a href="+code=u_attr" class="sref">u_attr1/a> &&.1a href="+code=oflag" class="sref">oflag1/a> &.1a href="+code=O_CREAT" class="sref">O_CREAT1/a>) {<. 551/a>                struct.1a href="+code=mq_attr" class="sref">mq_attr1/a> 1a href="+code=attr" class="sref">attr1/a>;e. 561/a><. 571/a>                1a href="+code=memset" class="sref">memset1/a>(&1a href="+code=attr" class="sref">attr1/a>, 0, sizeof(1a href="+code=attr" class="sref">attr1/a>));e. 581/a><. 591/a>                1a href="+code=p" class="sref">p1/a> = 1a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space1/a>(sizeof(1a href="+code=attr" class="sref">attr1/a>));e. 601/a>                if (1a href="+code=get_compat_mq_attr" class="sref">get_compat_mq_attr1/a>(&1a href="+code=attr" class="sref">attr1/a>, 1a href="+code=u_attr" class="sref">u_attr1/a>) ||e. 611/a>                    1a href="+code=copy_to_user" class="sref">copy_to_user1/a>(1a href="+code=p" class="sref">p1/a>, &1a href="+code=attr" class="sref">attr1/a>, sizeof(1a href="+code=attr" class="sref">attr1/a>)))<. 621/a>                        return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e. 631/a>        }e. 641/a>        return 1a href="+code=sys_mq_open" class="sref">sys_mq_open1/a>(1a href="+code=u_nam " class="sref">u_nam 1/a>,.1a href="+code=oflag" class="sref">oflag1/a>, 1a href="+code=mode" class="sref">mode1/a>, 1a href="+code=p" class="sref">p1/a>);e. 651/a>}e. 661/a><. 671/a>static int.1a href="+code=compat_prepare_timeout" class="sref">compat_prepare_timeout1/a>(struct.1a href="+code=timespec" class="sref">timespec1/a> 1a href="+code=__user" class="sref">__user1/a> * *1a href="+code=p" class="sref">p1/a>,<. 681/a>                                  const struct.1a href="+code=compat_timespec" class="sref">compat_timespec1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u" class="sref">u1/a>)<. 691/a>{<. 701/a>        struct.1a href="+code=timespec" class="sref">timespec1/a> 1a href="+code=ts" class="sref">ts1/a>;e. 711/a>        if (!1a href="+code=u" class="sref">u1/a>) {<. 721/a>                *1a href="+code=p" class="sref">p1/a> = 1a href="+code=NULL" class="sref">NULL1/a>;e. 731/a>                return 0;e. 741/a>        }e. 751/a>        *1a href="+code=p" class="sref">p1/a> = 1a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space1/a>(sizeof(1a href="+code=ts" class="sref">ts1/a>));e. 761/a>        if (1a href="+code=get_compat_timespec" class="sref">get_compat_timespec1/a>(&1a href="+code=ts" class="sref">ts1/a>, 1a href="+code=u" class="sref">u1/a>) || 1a href="+code=copy_to_user" class="sref">copy_to_user1/a>(*1a href="+code=p" class="sref">p1/a>, &1a href="+code=ts" class="sref">ts1/a>, sizeof(1a href="+code=ts" class="sref">ts1/a>)))<. 771/a>                return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e. 781/a>        return 0;e. 791/a>}e. 801/a><. 811/a>1a href="+code=asmlinkage" class="sref">asmlinkage1/a> long.1a href="+code=compat_sys_mq_timedsend" class="sref">compat_sys_mq_timedsend1/a>(1a href="+code=mqd_t" class="sref">mqd_t1/a> 1a href="+code=mqdes" class="sref">mqdes1/a>,<. 821/a>                        const char 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_msg_ptr" class="sref">u_msg_ptr1/a>,<. 831/a>                        1a href="+code=size_t" class="sref">size_t1/a> 1a href="+code=msg_len" class="sref">msg_len1/a>, unsigned int.1a href="+code=msg_prio" class="sref">msg_prio1/a>,<. 841/a>                        const struct.1a href="+code=compat_timespec" class="sref">compat_timespec1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_abs_timeout" class="sref">u_abs_timeout1/a>)<. 851/a>{<. 861/a>        struct.1a href="+code=timespec" class="sref">timespec1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_ts" class="sref">u_ts1/a>;e. 871/a><. 881/a>        if (1a href="+code=compat_prepare_timeout" class="sref">compat_prepare_timeout1/a>(&1a href="+code=u_ts" class="sref">u_ts1/a>, 1a href="+code=u_abs_timeout" class="sref">u_abs_timeout1/a>))<. 891/a>                return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e. 901/a><. 911/a>        return 1a href="+code=sys_mq_timedsend" class="sref">sys_mq_timedsend1/a>(1a href="+code=mqdes" class="sref">mqdes1/a>, 1a href="+code=u_msg_ptr" class="sref">u_msg_ptr1/a>, 1a href="+code=msg_len" class="sref">msg_len1/a>,<. 921/a>                        1a href="+code=msg_prio" class="sref">msg_prio1/a>, 1a href="+code=u_ts" class="sref">u_ts1/a>);e. 931/a>}e. 941/a><. 951/a>1a href="+code=asmlinkage" class="sref">asmlinkage1/a> 1a href="+code=ssize_t" class="sref">ssize_t1/a> 1a href="+code=compat_sys_mq_timedreceive" class="sref">compat_sys_mq_timedreceive1/a>(1a href="+code=mqd_t" class="sref">mqd_t1/a> 1a href="+code=mqdes" class="sref">mqdes1/a>,<. 961/a>                        char 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_msg_ptr" class="sref">u_msg_ptr1/a>,<. 971/a>                        1a href="+code=size_t" class="sref">size_t1/a> 1a href="+code=msg_len" class="sref">msg_len1/a>, unsigned int.1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_msg_prio" class="sref">u_msg_prio1/a>,<. 981/a>                        const struct.1a href="+code=compat_timespec" class="sref">compat_timespec1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_abs_timeout" class="sref">u_abs_timeout1/a>)<. 991/a>{<.1001/a>        struct.1a href="+code=timespec" class="sref">timespec1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_ts" class="sref">u_ts1/a>;e.1011/a>        if (1a href="+code=compat_prepare_timeout" class="sref">compat_prepare_timeout1/a>(&1a href="+code=u_ts" class="sref">u_ts1/a>, 1a href="+code=u_abs_timeout" class="sref">u_abs_timeout1/a>))<.1021/a>                return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e.1031/a><.1041/a>        return 1a href="+code=sys_mq_timedreceive" class="sref">sys_mq_timedreceive1/a>(1a href="+code=mqdes" class="sref">mqdes1/a>, 1a href="+code=u_msg_ptr" class="sref">u_msg_ptr1/a>, 1a href="+code=msg_len" class="sref">msg_len1/a>,<.1051/a>                        1a href="+code=u_msg_prio" class="sref">u_msg_prio1/a>, 1a href="+code=u_ts" class="sref">u_ts1/a>);e.1061/a>}e.1071/a><.1081/a>1a href="+code=asmlinkage" class="sref">asmlinkage1/a> long.1a href="+code=compat_sys_mq_notify" class="sref">compat_sys_mq_notify1/a>(1a href="+code=mqd_t" class="sref">mqd_t1/a> 1a href="+code=mqdes" class="sref">mqdes1/a>,<.1091/a>                        const struct.1a href="+code=compat_sigevent" class="sref">compat_sigevent1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_notifica12"
" class="sref">u_notifica12"
1/a>)<.1 {<.1111/a>        struct.1a href="+code=sigevent" class="sref">sigevent1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=p" class="sref">p1/a> = 1a href="+code=NULL" class="sref">NULL1/a>;e.1121/a>        if (1a href="+code=u_notifica12"
" class="sref">u_notifica12"
1/a>) {<.1131/a>                struct.1a href="+code=sigevent" class="sref">sigevent1/a> 1a href="+code=
" class="sref">n1/a>;e.1141/a>                1a href="+code=p" class="sref">p1/a> = 1a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space1/a>(sizeof(*1a href="+code=p" class="sref">p1/a>));e.1151/a>                if (1a href="+code=get_compat_sigevent" class="sref">get_compat_sigevent1/a>(&1a href="+code=
" class="sref">n1/a>, 1a href="+code=u_notifica12"
" class="sref">u_notifica12"
1/a>))<.1161/a>                        return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e.1171/a>                if (1a href="+code=
" class="sref">n1/a>.1a href="+code=sigev_notify" class="sref">sigev_notify1/a> == 1a href="+code=SIGEV_THREAD" class="sref">SIGEV_THREAD1/a>)<.1181/a>                        1a href="+code=
" class="sref">n1/a>.1a href="+code=sigev_  >
 " class="sref">sigev_  >
 1/a>.1a href="+code=si  >_ptr" class="sref">si  >_ptr1/a> = 1a href="+code=compat_ptr" class="sref">compat_ptr1/a>(1a href="+code=
" class="sref">n1/a>.1a href="+code=sigev_  >
 " class="sref">sigev_  >
 1/a>.1a href="+code=si  >_int" class="sref">si  >_int1/a>);e.1191/a>                if (1a href="+code=copy_to_user" class="sref">copy_to_user1/a>(1a href="+code=p" class="sref">p1/a>, &1a href="+code=
" class="sref">n1/a>, sizeof(*1a href="+code=p" class="sref">p1/a>)))<.1201/a>                        return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e.1211/a>        }e.1221/a>        return 1a href="+code=sys_mq_notify" class="sref">sys_mq_notify1/a>(1a href="+code=mqdes" class="sref">mqdes1/a>, 1a href="+code=p" class="sref">p1/a>);e.1231/a>}e.1241/a><.1251/a>1a href="+code=asmlinkage" class="sref">asmlinkage1/a> long.1a href="+code=compat_sys_mq_getsetattr" class="sref">compat_sys_mq_getsetattr1/a>(1a href="+code=mqd_t" class="sref">mqd_t1/a> 1a href="+code=mqdes" class="sref">mqdes1/a>,<.1261/a>                        const struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_mqstat" class="sref">u_mqstat1/a>,<.1271/a>                        struct.1a href="+code=compat_mq_attr" class="sref">compat_mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=u_omqstat" class="sref">u_omqstat1/a>)<.1281/a>{<.1291/a>        struct.1a href="+code=mq_attr" class="sref">mq_attr1/a> 1a href="+code=mqstat" class="sref">mqstat1/a>;<.1301/a>        struct.1a href="+code=mq_attr" class="sref">mq_attr1/a> 1a href="+code=__user" class="sref">__user1/a> *1a href="+code=p" class="sref">p1/a> = 1a href="+code=compat_alloc_user_space" class="sref">compat_alloc_user_space1/a>(2 * sizeof(*1a href="+code=p" class="sref">p1/a>));<.1311/a>        long.1a href="+code=ret" class="sref">ret1/a>;<.1321/a><.1331/a>        1a href="+code=memset" class="sref">memset1/a>(&1a href="+code=mqstat" class="sref">mqstat1/a>, 0, sizeof(1a href="+code=mqstat" class="sref">mqstat1/a>));<.1341/a><.1351/a>        if (1a href="+code=u_mqstat" class="sref">u_mqstat1/a>) {<.1361/a>                if (1a href="+code=get_compat_mq_attr" class="sref">get_compat_mq_attr1/a>(&1a href="+code=mqstat" class="sref">mqstat1/a>, 1a href="+code=u_mqstat" class="sref">u_mqstat1/a>) ||e.1371/a>                    1a href="+code=copy_to_user" class="sref">copy_to_user1/a>(1a href="+code=p" class="sref">p1/a>, &1a href="+code=mqstat" class="sref">mqstat1/a>, sizeof(1a href="+code=mqstat" class="sref">mqstat1/a>)))<.1381/a>                        return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e.1391/a>        }e.1401/a>        1a href="+code=ret" class="sref">ret1/a> = 1a href="+code=sys_mq_getsetattr" class="sref">sys_mq_getsetattr1/a>(1a href="+code=mqdes" class="sref">mqdes1/a>,<.1411/a>                                1a href="+code=u_mqstat" class="sref">u_mqstat1/a> ? 1a href="+code=p" class="sref">p1/a> : 1a href="+code=NULL" class="sref">NULL1/a>,<.1421/a>                                1a href="+code=u_omqstat" class="sref">u_omqstat1/a> ? 1a href="+code=p" class="sref">p1/a> + 1 : 1a href="+code=NULL" class="sref">NULL1/a>);<.1431/a>        if (1a href="+code=ret" class="sref">ret1/a>)<.1441/a>                return 1a href="+code=ret" class="sref">ret1/a>;<.1451/a>        if (1a href="+code=u_omqstat" class="sref">u_omqstat1/a>) {<.1461/a>                if (1a href="+code=copy_from_user" class="sref">copy_from_user1/a>(&1a href="+code=mqstat" class="sref">mqstat1/a>, 1a href="+code=p" class="sref">p1/a> + 1, sizeof(1a href="+code=mqstat" class="sref">mqstat1/a>)) ||e.1471/a>                    1a href="+code=put_compat_mq_attr" class="sref">put_compat_mq_attr1/a>(&1a href="+code=mqstat" class="sref">mqstat1/a>, 1a href="+code=u_omqstat" class="sref">u_omqstat1/a>))<.1481/a>                        return -1a href="+code=EFAULT" class="sref">EFAULT1/a>;e.1491/a>        }e.1501/a>        return 0;e.1511/a>}e.1521/a>
The original LXR software by the LXR community1/a>, this experimental vers2" by lxr@linux.no1/a>. 1/divue1div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS1/a>, provider of Linux consulting.and opera12" s services since 1995. 1/divue 1/bodyue1/htmlue