sysv_msg.c (140839) | sysv_msg.c (141471) |
---|---|
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 140839 2005-01-26 00:46:36Z sobomax $"); | 51__FBSDID("$FreeBSD: head/sys/kern/sysv_msg.c 141471 2005-02-07 18:44:55Z jhb $"); |
52 53#include "opt_sysvipc.h" 54#include "opt_mac.h" 55 56#include <sys/param.h> 57#include <sys/systm.h> 58#include <sys/sysproto.h> 59#include <sys/kernel.h> --- 332 unchanged lines hidden (view full) --- 392int 393msgctl(td, uap) 394 struct thread *td; 395 register struct msgctl_args *uap; 396{ 397 int msqid = uap->msqid; 398 int cmd = uap->cmd; 399 struct msqid_ds msqbuf; | 52 53#include "opt_sysvipc.h" 54#include "opt_mac.h" 55 56#include <sys/param.h> 57#include <sys/systm.h> 58#include <sys/sysproto.h> 59#include <sys/kernel.h> --- 332 unchanged lines hidden (view full) --- 392int 393msgctl(td, uap) 394 struct thread *td; 395 register struct msgctl_args *uap; 396{ 397 int msqid = uap->msqid; 398 int cmd = uap->cmd; 399 struct msqid_ds msqbuf; |
400 struct msqid_ds *msqptr; | |
401 int error; 402 403 DPRINTF(("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, uap->buf)); 404 if (cmd == IPC_SET && 405 (error = copyin(uap->buf, &msqbuf, sizeof(msqbuf))) != 0) 406 return (error); | 400 int error; 401 402 DPRINTF(("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, uap->buf)); 403 if (cmd == IPC_SET && 404 (error = copyin(uap->buf, &msqbuf, sizeof(msqbuf))) != 0) 405 return (error); |
407 error = kern_msgctl(td, msqid, cmd, &msqbuf, &msqptr); | 406 error = kern_msgctl(td, msqid, cmd, &msqbuf); |
408 if (cmd == IPC_STAT && error == 0) | 407 if (cmd == IPC_STAT && error == 0) |
409 error = copyout(msqptr, uap->buf, sizeof(struct msqid_ds)); | 408 error = copyout(&msqbuf, uap->buf, sizeof(struct msqid_ds)); |
410 return (error); 411} 412 413int | 409 return (error); 410} 411 412int |
414kern_msgctl(td, msqid, cmd, msqbuf, msqptr) | 413kern_msgctl(td, msqid, cmd, msqbuf) |
415 struct thread *td; 416 int msqid; 417 int cmd; 418 struct msqid_ds *msqbuf; | 414 struct thread *td; 415 int msqid; 416 int cmd; 417 struct msqid_ds *msqbuf; |
419 struct msqid_ds **msqptr; | |
420{ 421 int rval, error, msqix; 422 register struct msqid_kernel *msqkptr; 423 424 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 425 return (ENOSYS); 426 427 msqix = IPCID_TO_IX(msqid); --- 112 unchanged lines hidden (view full) --- 540 msqkptr->u.msg_ctime = time_second; 541 break; 542 543 case IPC_STAT: 544 if ((error = ipcperm(td, &msqkptr->u.msg_perm, IPC_R))) { 545 DPRINTF(("requester doesn't have read access\n")); 546 goto done2; 547 } | 418{ 419 int rval, error, msqix; 420 register struct msqid_kernel *msqkptr; 421 422 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 423 return (ENOSYS); 424 425 msqix = IPCID_TO_IX(msqid); --- 112 unchanged lines hidden (view full) --- 538 msqkptr->u.msg_ctime = time_second; 539 break; 540 541 case IPC_STAT: 542 if ((error = ipcperm(td, &msqkptr->u.msg_perm, IPC_R))) { 543 DPRINTF(("requester doesn't have read access\n")); 544 goto done2; 545 } |
548 *msqptr = &(msqkptr->u); | 546 *msqbuf = msqkptr->u; |
549 break; 550 551 default: 552 DPRINTF(("invalid command %d\n", cmd)); 553 error = EINVAL; 554 goto done2; 555 } 556 557 if (error == 0) 558 td->td_retval[0] = rval; 559done2: 560 mtx_unlock(&msq_mtx); | 547 break; 548 549 default: 550 DPRINTF(("invalid command %d\n", cmd)); 551 error = EINVAL; 552 goto done2; 553 } 554 555 if (error == 0) 556 td->td_retval[0] = rval; 557done2: 558 mtx_unlock(&msq_mtx); |
561 return(error); | 559 return (error); |
562} 563 564#ifndef _SYS_SYSPROTO_H_ 565struct msgget_args { 566 key_t key; 567 int msgflg; 568}; 569#endif --- 755 unchanged lines hidden --- | 560} 561 562#ifndef _SYS_SYSPROTO_H_ 563struct msgget_args { 564 key_t key; 565 int msgflg; 566}; 567#endif --- 755 unchanged lines hidden --- |