svr4_ipc.c (159991) | svr4_ipc.c (159993) |
---|---|
1/*- 2 * Copyright (c) 1995 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Christos Zoulas. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 57 unchanged lines hidden (view full) --- 66 * to preprocessor conditionals). A nice project for a kernel hacking 67 * novice might be to MakeItGo, but I have more important fish to fry 68 * at present. 69 * 70 * Derived from: $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ 71 */ 72 73#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1995 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Christos Zoulas. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 57 unchanged lines hidden (view full) --- 66 * to preprocessor conditionals). A nice project for a kernel hacking 67 * novice might be to MakeItGo, but I have more important fish to fry 68 * at present. 69 * 70 * Derived from: $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ 71 */ 72 73#include <sys/cdefs.h> |
74__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_ipc.c 159991 2006-06-27 18:28:50Z jhb $"); | 74__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_ipc.c 159993 2006-06-27 18:31:36Z jhb $"); |
75 76#include "opt_sysvipc.h" 77 78#include <sys/param.h> 79#include <sys/ipc.h> 80#include <sys/msg.h> 81#include <sys/proc.h> 82#include <sys/sem.h> --- 562 unchanged lines hidden (view full) --- 645}; 646 647int 648svr4_shmctl(td, v) 649 struct thread *td; 650 void *v; 651{ 652 struct svr4_sys_shmctl_args *uap = v; | 75 76#include "opt_sysvipc.h" 77 78#include <sys/param.h> 79#include <sys/ipc.h> 80#include <sys/msg.h> 81#include <sys/proc.h> 82#include <sys/sem.h> --- 562 unchanged lines hidden (view full) --- 645}; 646 647int 648svr4_shmctl(td, v) 649 struct thread *td; 650 void *v; 651{ 652 struct svr4_sys_shmctl_args *uap = v; |
653 int error; 654 caddr_t sg = stackgap_init(); 655 struct shmctl_args ap; | |
656 struct shmid_ds bs; 657 struct svr4_shmid_ds ss; | 653 struct shmid_ds bs; 654 struct svr4_shmid_ds ss; |
655 size_t bufsize; 656 int cmd, error; |
|
658 | 657 |
659 ap.shmid = uap->shmid; 660 | |
661 if (uap->buf != NULL) { | 658 if (uap->buf != NULL) { |
662 ap.buf = stackgap_alloc(&sg, sizeof (struct shmid_ds)); | |
663 switch (uap->cmd) { 664 case SVR4_IPC_SET: 665 case SVR4_IPC_RMID: 666 case SVR4_SHM_LOCK: 667 case SVR4_SHM_UNLOCK: | 659 switch (uap->cmd) { 660 case SVR4_IPC_SET: 661 case SVR4_IPC_RMID: 662 case SVR4_SHM_LOCK: 663 case SVR4_SHM_UNLOCK: |
668 error = copyin(uap->buf, (caddr_t) &ss, 669 sizeof ss); | 664 error = copyin(uap->buf, &ss, sizeof(ss)); |
670 if (error) | 665 if (error) |
671 return error; | 666 return (error); |
672 svr4_to_bsd_shmid_ds(&ss, &bs); | 667 svr4_to_bsd_shmid_ds(&ss, &bs); |
673 error = copyout(&bs, ap.buf, sizeof bs); 674 if (error) 675 return error; | |
676 break; 677 default: | 668 break; 669 default: |
678 break; | 670 return (EINVAL); |
679 } 680 } | 671 } 672 } |
681 else 682 ap.buf = NULL; | |
683 | 673 |
684 | |
685 switch (uap->cmd) { 686 case SVR4_IPC_STAT: | 674 switch (uap->cmd) { 675 case SVR4_IPC_STAT: |
687 ap.cmd = IPC_STAT; 688 if ((error = shmctl(td, &ap)) != 0) 689 return error; 690 if (uap->buf == NULL) 691 return 0; 692 error = copyin(&bs, ap.buf, sizeof bs); 693 if (error) 694 return error; 695 bsd_to_svr4_shmid_ds(&bs, &ss); 696 return copyout(&ss, uap->buf, sizeof ss); 697 | 676 cmd = IPC_STAT; 677 break; |
698 case SVR4_IPC_SET: | 678 case SVR4_IPC_SET: |
699 ap.cmd = IPC_SET; 700 return shmctl(td, &ap); 701 | 679 cmd = IPC_SET; 680 break; |
702 case SVR4_IPC_RMID: | 681 case SVR4_IPC_RMID: |
682 cmd = IPC_RMID; 683 break; |
|
703 case SVR4_SHM_LOCK: | 684 case SVR4_SHM_LOCK: |
685 cmd = SHM_LOCK; 686 break; |
|
704 case SVR4_SHM_UNLOCK: | 687 case SVR4_SHM_UNLOCK: |
705 switch (uap->cmd) { 706 case SVR4_IPC_RMID: 707 ap.cmd = IPC_RMID; 708 break; 709 case SVR4_SHM_LOCK: 710 ap.cmd = SHM_LOCK; 711 break; 712 case SVR4_SHM_UNLOCK: 713 ap.cmd = SHM_UNLOCK; 714 break; 715 default: 716 return EINVAL; 717 } 718 return shmctl(td, &ap); 719 | 688 cmd = SHM_UNLOCK; 689 break; |
720 default: | 690 default: |
721 return EINVAL; | 691 return (EINVAL); |
722 } | 692 } |
693 694 error = kern_shmctl(td, uap->shmid, cmd, &bs, &bufsize); 695 if (error) 696 return (error); 697 698 switch (uap->cmd) { 699 case SVR4_IPC_STAT: 700 if (uap->buf != NULL) { 701 bsd_to_svr4_shmid_ds(&bs, &ss); 702 error = copyout(&ss, uap->buf, sizeof(ss)); 703 } 704 break; 705 } 706 707 return (error); |
|
723} 724 725int 726svr4_sys_shmsys(td, uap) 727 struct thread *td; 728 struct svr4_sys_shmsys_args *uap; 729{ 730 --- 18 unchanged lines hidden --- | 708} 709 710int 711svr4_sys_shmsys(td, uap) 712 struct thread *td; 713 struct svr4_sys_shmsys_args *uap; 714{ 715 --- 18 unchanged lines hidden --- |