]>
Commit | Line | Data |
---|---|---|
3d9156a7 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | #include <unistd.h> | |
24 | #include <stdarg.h> | |
25 | #include <sys/msg.h> | |
3d9156a7 A |
26 | |
27 | /* | |
28 | * Stub function to account for the differences in the ipc_perm structure, | |
29 | * while maintaining binary backward compatibility. | |
224c7076 A |
30 | * |
31 | * This is only the legacy behavior. | |
3d9156a7 | 32 | */ |
224c7076 A |
33 | extern int __msgctl(int, int, struct msqid_ds *); |
34 | ||
3d9156a7 A |
35 | int |
36 | msgctl(int msqid, int cmd, struct msqid_ds *ds) | |
37 | { | |
224c7076 | 38 | struct __msqid_ds_old *ds_old = (struct __msqid_ds_old *)ds; |
3d9156a7 A |
39 | struct __msqid_ds_new ds2; |
40 | struct __msqid_ds_new *ds_new = &ds2; | |
41 | int rv; | |
42 | ||
43 | #define _UP_CVT(x) ds_new-> x = ds_old-> x | |
44 | #define _DN_CVT(x) ds_old-> x = ds_new-> x | |
45 | ||
46 | if (cmd == IPC_SET) { | |
47 | /* convert before call */ | |
48 | _UP_CVT(msg_perm.uid); | |
49 | _UP_CVT(msg_perm.gid); | |
50 | _UP_CVT(msg_perm.cuid); | |
51 | _UP_CVT(msg_perm.cgid); | |
52 | _UP_CVT(msg_perm.mode); | |
53 | ds_new->msg_perm._seq = ds_old->msg_perm.seq; | |
54 | ds_new->msg_perm._key = ds_old->msg_perm.key; | |
55 | _UP_CVT(msg_first); | |
56 | _UP_CVT(msg_last); | |
57 | _UP_CVT(msg_cbytes); | |
58 | _UP_CVT(msg_qnum); | |
59 | _UP_CVT(msg_qbytes); | |
60 | _UP_CVT(msg_lspid); | |
61 | _UP_CVT(msg_lrpid); | |
62 | _UP_CVT(msg_stime); | |
63 | _UP_CVT(msg_pad1); /* binary compatibility */ | |
64 | _UP_CVT(msg_rtime); | |
65 | _UP_CVT(msg_pad2); /* binary compatibility */ | |
66 | _UP_CVT(msg_ctime); | |
67 | _UP_CVT(msg_pad3); /* binary compatibility */ | |
68 | _UP_CVT(msg_pad4[0]); /* binary compatibility */ | |
69 | _UP_CVT(msg_pad4[1]); /* binary compatibility */ | |
70 | _UP_CVT(msg_pad4[2]); /* binary compatibility */ | |
71 | _UP_CVT(msg_pad4[3]); /* binary compatibility */ | |
72 | } | |
73 | ||
224c7076 | 74 | rv = __msgctl(msqid, cmd, ds_new); |
3d9156a7 A |
75 | |
76 | if (cmd == IPC_STAT) { | |
77 | /* convert after call */ | |
78 | _DN_CVT(msg_perm.uid); /* warning! precision loss! */ | |
79 | _DN_CVT(msg_perm.gid); /* warning! precision loss! */ | |
80 | _DN_CVT(msg_perm.cuid); /* warning! precision loss! */ | |
81 | _DN_CVT(msg_perm.cgid); /* warning! precision loss! */ | |
82 | _DN_CVT(msg_perm.mode); | |
224c7076 A |
83 | ds_old->msg_perm.seq = ds_new->msg_perm._seq; |
84 | ds_old->msg_perm.key = ds_new->msg_perm._key; | |
3d9156a7 A |
85 | _DN_CVT(msg_first); |
86 | _DN_CVT(msg_last); | |
87 | _DN_CVT(msg_cbytes); | |
88 | _DN_CVT(msg_qnum); | |
89 | _DN_CVT(msg_qbytes); | |
90 | _DN_CVT(msg_lspid); | |
91 | _DN_CVT(msg_lrpid); | |
92 | _DN_CVT(msg_stime); | |
93 | _DN_CVT(msg_pad1); /* binary compatibility */ | |
94 | _DN_CVT(msg_rtime); | |
95 | _DN_CVT(msg_pad2); /* binary compatibility */ | |
96 | _DN_CVT(msg_ctime); | |
97 | _DN_CVT(msg_pad3); /* binary compatibility */ | |
98 | _DN_CVT(msg_pad4[0]); /* binary compatibility */ | |
99 | _DN_CVT(msg_pad4[1]); /* binary compatibility */ | |
100 | _DN_CVT(msg_pad4[2]); /* binary compatibility */ | |
101 | _DN_CVT(msg_pad4[3]); /* binary compatibility */ | |
102 | } | |
103 | ||
104 | return (rv); | |
3d9156a7 | 105 | } |