sysv_msg.c (194832) | sysv_msg.c (194894) |
---|---|
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 194832 2009-06-24 13:35:38Z jhb $"); | 51__FBSDID("$FreeBSD: head/sys/kern/sysv_msg.c 194894 2009-06-24 20:01:13Z jhb $"); |
52 | 52 |
53#include "opt_compat.h" |
|
53#include "opt_sysvipc.h" 54 55#include <sys/param.h> 56#include <sys/systm.h> 57#include <sys/sysproto.h> 58#include <sys/kernel.h> 59#include <sys/priv.h> 60#include <sys/proc.h> --- 19 unchanged lines hidden (view full) --- 80#ifdef MSG_DEBUG 81#define DPRINTF(a) printf a 82#else 83#define DPRINTF(a) (void)0 84#endif 85 86static void msg_freehdr(struct msg *msghdr); 87 | 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> 60#include <sys/priv.h> 61#include <sys/proc.h> --- 19 unchanged lines hidden (view full) --- 81#ifdef MSG_DEBUG 82#define DPRINTF(a) printf a 83#else 84#define DPRINTF(a) (void)0 85#endif 86 87static void msg_freehdr(struct msg *msghdr); 88 |
88/* XXX casting to (sy_call_t *) is bogus, as usual. */ 89static sy_call_t *msgcalls[] = { 90 (sy_call_t *)msgctl, (sy_call_t *)msgget, 91 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv 92}; 93 | |
94#ifndef MSGSSZ 95#define MSGSSZ 8 /* Each segment must be 2^N long */ 96#endif 97#ifndef MSGSEG 98#define MSGSEG 2048 /* must be less than 32767 */ 99#endif 100#define MSGMAX (MSGSSZ*MSGSEG) 101#ifndef MSGMNB --- 201 unchanged lines hidden (view full) --- 303} 304 305static moduledata_t sysvmsg_mod = { 306 "sysvmsg", 307 &sysvmsg_modload, 308 NULL 309}; 310 | 89#ifndef MSGSSZ 90#define MSGSSZ 8 /* Each segment must be 2^N long */ 91#endif 92#ifndef MSGSEG 93#define MSGSEG 2048 /* must be less than 32767 */ 94#endif 95#define MSGMAX (MSGSSZ*MSGSEG) 96#ifndef MSGMNB --- 201 unchanged lines hidden (view full) --- 298} 299 300static moduledata_t sysvmsg_mod = { 301 "sysvmsg", 302 &sysvmsg_modload, 303 NULL 304}; 305 |
311SYSCALL_MODULE_HELPER(msgsys); | |
312SYSCALL_MODULE_HELPER(msgctl); 313SYSCALL_MODULE_HELPER(msgget); 314SYSCALL_MODULE_HELPER(msgsnd); 315SYSCALL_MODULE_HELPER(msgrcv); 316 317DECLARE_MODULE(sysvmsg, sysvmsg_mod, SI_SUB_SYSV_MSG, SI_ORDER_FIRST); 318MODULE_VERSION(sysvmsg, 1); 319 | 306SYSCALL_MODULE_HELPER(msgctl); 307SYSCALL_MODULE_HELPER(msgget); 308SYSCALL_MODULE_HELPER(msgsnd); 309SYSCALL_MODULE_HELPER(msgrcv); 310 311DECLARE_MODULE(sysvmsg, sysvmsg_mod, SI_SUB_SYSV_MSG, SI_ORDER_FIRST); 312MODULE_VERSION(sysvmsg, 1); 313 |
320/* 321 * Entry point for all MSG calls. 322 */ 323int 324msgsys(td, uap) 325 struct thread *td; 326 /* XXX actually varargs. */ 327 struct msgsys_args /* { 328 int which; 329 int a2; 330 int a3; 331 int a4; 332 int a5; 333 int a6; 334 } */ *uap; 335{ 336 int error; 337 338 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) 339 return (ENOSYS); 340 if (uap->which < 0 || 341 uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0])) 342 return (EINVAL); 343 error = (*msgcalls[uap->which])(td, &uap->a2); 344 return (error); 345} 346 | |
347static void 348msg_freehdr(msghdr) 349 struct msg *msghdr; 350{ 351 while (msghdr->msg_ts > 0) { 352 short next; 353 if (msghdr->msg_spot < 0 || msghdr->msg_spot >= msginfo.msgseg) 354 panic("msghdr->msg_spot out of range"); --- 929 unchanged lines hidden (view full) --- 1284SYSCTL_INT(_kern_ipc, OID_AUTO, msgtql, CTLFLAG_RDTUN, &msginfo.msgtql, 0, 1285 "Maximum number of messages in the system"); 1286SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz, CTLFLAG_RDTUN, &msginfo.msgssz, 0, 1287 "Size of a message segment"); 1288SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0, 1289 "Number of message segments"); 1290SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLFLAG_RD, 1291 NULL, 0, sysctl_msqids, "", "Message queue IDs"); | 314static void 315msg_freehdr(msghdr) 316 struct msg *msghdr; 317{ 318 while (msghdr->msg_ts > 0) { 319 short next; 320 if (msghdr->msg_spot < 0 || msghdr->msg_spot >= msginfo.msgseg) 321 panic("msghdr->msg_spot out of range"); --- 929 unchanged lines hidden (view full) --- 1251SYSCTL_INT(_kern_ipc, OID_AUTO, msgtql, CTLFLAG_RDTUN, &msginfo.msgtql, 0, 1252 "Maximum number of messages in the system"); 1253SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz, CTLFLAG_RDTUN, &msginfo.msgssz, 0, 1254 "Size of a message segment"); 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); 1263 1264/* XXX casting to (sy_call_t *) is bogus, as usual. */ 1265static sy_call_t *msgcalls[] = { 1266 (sy_call_t *)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) 1275 struct thread *td; 1276 /* XXX actually varargs. */ 1277 struct msgsys_args /* { 1278 int which; 1279 int a2; 1280 int a3; 1281 int a4; 1282 int a5; 1283 int a6; 1284 } */ *uap; 1285{ 1286 int error; 1287 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} 1296#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 || 1297 COMPAT_FREEBSD7 */ |
|