X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fipc%2Fmsgctl.c;h=9c11440641a99060c7f297c99ab914a14c913724;hb=85050ac5a2677a8ebf2722e93b5c037ec675c036;hp=d50e395b2534cdbcee8e56407bc28557c9d89d67;hpb=c2cd25bff89c3581780e7eb267262cb8c4da0d38;p=musl diff --git a/src/ipc/msgctl.c b/src/ipc/msgctl.c index d50e395b..9c114406 100644 --- a/src/ipc/msgctl.c +++ b/src/ipc/msgctl.c @@ -1,12 +1,51 @@ #include +#include #include "syscall.h" #include "ipc.h" +#if __BYTE_ORDER != __BIG_ENDIAN +#undef SYSCALL_IPC_BROKEN_MODE +#endif + int msgctl(int q, int cmd, struct msqid_ds *buf) { -#ifdef SYS_msgctl - return syscall(SYS_msgctl, q, cmd, buf); +#if IPC_TIME64 + struct msqid_ds out, *orig; + if (cmd&IPC_TIME64) { + out = (struct msqid_ds){0}; + orig = buf; + buf = &out; + } +#endif +#ifdef SYSCALL_IPC_BROKEN_MODE + struct msqid_ds tmp; + if (cmd == IPC_SET) { + tmp = *buf; + tmp.msg_perm.mode *= 0x10000U; + buf = &tmp; + } +#endif +#ifndef SYS_ipc + int r = __syscall(SYS_msgctl, q, IPC_CMD(cmd), buf); #else - return syscall(SYS_ipc, IPCOP_msgctl, q, cmd, buf); + int r = __syscall(SYS_ipc, IPCOP_msgctl, q, IPC_CMD(cmd), 0, buf, 0); +#endif +#ifdef SYSCALL_IPC_BROKEN_MODE + if (r >= 0) switch (cmd | IPC_TIME64) { + case IPC_STAT: + case MSG_STAT: + case MSG_STAT_ANY: + buf->msg_perm.mode >>= 16; + } +#endif +#if IPC_TIME64 + if (r >= 0 && (cmd&IPC_TIME64)) { + buf = orig; + *buf = out; + IPC_HILO(buf, msg_stime); + IPC_HILO(buf, msg_rtime); + IPC_HILO(buf, msg_ctime); + } #endif + return __syscall_ret(r); }