函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:ipc\msg.c Create Date:2022-07-27 18:16:43
首页 Copyright©Brick

297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
static inline unsigned long
copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version)
{
    switch (version) {
    case IPC_64:
        return copy_to_user(buf, in, sizeof(*in));
    case IPC_OLD:
    {
        struct msqid_ds out;
 
        memset(&out, 0, sizeof(out));
 
        ipc64_perm_to_ipc_perm(&in->msg_perm, &out.msg_perm);
 
        out.msg_stime       = in->msg_stime;
        out.msg_rtime       = in->msg_rtime;
        out.msg_ctime       = in->msg_ctime;
 
        if (in->msg_cbytes > USHRT_MAX)
            out.msg_cbytes  = USHRT_MAX;
        else
            out.msg_cbytes  = in->msg_cbytes;
        out.msg_lcbytes     = in->msg_cbytes;
 
        if (in->msg_qnum > USHRT_MAX)
            out.msg_qnum    = USHRT_MAX;
        else
            out.msg_qnum    = in->msg_qnum;
 
        if (in->msg_qbytes > USHRT_MAX)
            out.msg_qbytes  = USHRT_MAX;
        else
            out.msg_qbytes  = in->msg_qbytes;
        out.msg_lqbytes     = in->msg_qbytes;
 
        out.msg_lspid       = in->msg_lspid;
        out.msg_lrpid       = in->msg_lrpid;
 
        return copy_to_user(buf, &out, sizeof(out));
    }
    default:
        return -EINVAL;
    }
}