Deleted Added
full compact
sysv_msg.c (194894) sysv_msg.c (194910)
1/*-
2 * Implementation of SVID messages
3 *
4 * Author: Daniel Boulet
5 *
6 * Copyright 1993 Daniel Boulet and RTMX Inc.
7 *
8 * This system call was implemented by Daniel Boulet under contract from RTMX.

--- 34 unchanged lines hidden (view full) ---

43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 */
49
50#include <sys/cdefs.h>
1/*-
2 * Implementation of SVID messages
3 *
4 * Author: Daniel Boulet
5 *
6 * Copyright 1993 Daniel Boulet and RTMX Inc.
7 *
8 * This system call was implemented by Daniel Boulet under contract from RTMX.

--- 34 unchanged lines hidden (view full) ---

43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 */
49
50#include <sys/cdefs.h>
51__FBSDID("$FreeBSD: head/sys/kern/sysv_msg.c 194894 2009-06-24 20:01:13Z jhb $");
51__FBSDID("$FreeBSD: head/sys/kern/sysv_msg.c 194910 2009-06-24 21:10:52Z jhb $");
52
53#include "opt_compat.h"
54#include "opt_sysvipc.h"
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/sysproto.h>
59#include <sys/kernel.h>

--- 1195 unchanged lines hidden (view full) ---

1255SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
1256 "Number of message segments");
1257SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD,
1258 NULL, 0, sysctl_msqids, "", "Message queue IDs");
1259
1260#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
1261 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
1262SYSCALL_MODULE_HELPER(msgsys);
52
53#include "opt_compat.h"
54#include "opt_sysvipc.h"
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/sysproto.h>
59#include <sys/kernel.h>

--- 1195 unchanged lines hidden (view full) ---

1255SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
1256 "Number of message segments");
1257SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD,
1258 NULL, 0, sysctl_msqids, "", "Message queue IDs");
1259
1260#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
1261 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
1262SYSCALL_MODULE_HELPER(msgsys);
1263SYSCALL_MODULE_HELPER(freebsd7_msgctl);
1263
1264/* XXX casting to (sy_call_t *) is bogus, as usual. */
1265static sy_call_t *msgcalls[] = {
1264
1265/* XXX casting to (sy_call_t *) is bogus, as usual. */
1266static sy_call_t *msgcalls[] = {
1266 (sy_call_t *)msgctl, (sy_call_t *)msgget,
1267 (sy_call_t *)freebsd7_msgctl, (sy_call_t *)msgget,
1267 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv
1268};
1269
1270/*
1271 * Entry point for all MSG calls.
1272 */
1273int
1274msgsys(td, uap)

--- 13 unchanged lines hidden (view full) ---

1288 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
1289 return (ENOSYS);
1290 if (uap->which < 0 ||
1291 uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
1292 return (EINVAL);
1293 error = (*msgcalls[uap->which])(td, &uap->a2);
1294 return (error);
1295}
1268 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv
1269};
1270
1271/*
1272 * Entry point for all MSG calls.
1273 */
1274int
1275msgsys(td, uap)

--- 13 unchanged lines hidden (view full) ---

1289 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
1290 return (ENOSYS);
1291 if (uap->which < 0 ||
1292 uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
1293 return (EINVAL);
1294 error = (*msgcalls[uap->which])(td, &uap->a2);
1295 return (error);
1296}
1297
1298#define CP(src, dst, fld) do { (dst).fld = (src).fld; } while (0)
1299
1300#ifndef _SYS_SYSPROTO_H_
1301struct freebsd7_msgctl_args {
1302 int msqid;
1303 int cmd;
1304 struct msqid_ds_old *buf;
1305};
1306#endif
1307int
1308freebsd7_msgctl(td, uap)
1309 struct thread *td;
1310 struct freebsd7_msgctl_args *uap;
1311{
1312 struct msqid_ds_old msqold;
1313 struct msqid_ds msqbuf;
1314 int error;
1315
1316 DPRINTF(("call to freebsd7_msgctl(%d, %d, %p)\n", uap->msqid, uap->cmd,
1317 uap->buf));
1318 if (uap->cmd == IPC_SET) {
1319 error = copyin(uap->buf, &msqold, sizeof(msqold));
1320 if (error)
1321 return (error);
1322 ipcperm_old2new(&msqold.msg_perm, &msqbuf.msg_perm);
1323 CP(msqold, msqbuf, msg_first);
1324 CP(msqold, msqbuf, msg_last);
1325 CP(msqold, msqbuf, msg_cbytes);
1326 CP(msqold, msqbuf, msg_qnum);
1327 CP(msqold, msqbuf, msg_qbytes);
1328 CP(msqold, msqbuf, msg_lspid);
1329 CP(msqold, msqbuf, msg_lrpid);
1330 CP(msqold, msqbuf, msg_stime);
1331 CP(msqold, msqbuf, msg_rtime);
1332 CP(msqold, msqbuf, msg_ctime);
1333 }
1334 error = kern_msgctl(td, uap->msqid, uap->cmd, &msqbuf);
1335 if (error)
1336 return (error);
1337 if (uap->cmd == IPC_STAT) {
1338 bzero(&msqold, sizeof(msqold));
1339 ipcperm_new2old(&msqbuf.msg_perm, &msqold.msg_perm);
1340 CP(msqbuf, msqold, msg_first);
1341 CP(msqbuf, msqold, msg_last);
1342 CP(msqbuf, msqold, msg_cbytes);
1343 CP(msqbuf, msqold, msg_qnum);
1344 CP(msqbuf, msqold, msg_qbytes);
1345 CP(msqbuf, msqold, msg_lspid);
1346 CP(msqbuf, msqold, msg_lrpid);
1347 CP(msqbuf, msqold, msg_stime);
1348 CP(msqbuf, msqold, msg_rtime);
1349 CP(msqbuf, msqold, msg_ctime);
1350 error = copyout(&msqold, uap->buf, sizeof(struct msqid_ds_old));
1351 }
1352 return (error);
1353}
1354
1355#undef CP
1356
1296#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 ||
1297 COMPAT_FREEBSD7 */
1357#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 ||
1358 COMPAT_FREEBSD7 */