linux_ipc.c (185337) | linux_ipc.c (194910) |
---|---|
1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ipc.c 185337 2008-11-26 16:38:43Z rdivacky $"); | 30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ipc.c 194910 2009-06-24 21:10:52Z jhb $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/syscallsubr.h> 35#include <sys/sysproto.h> 36#include <sys/proc.h> 37#include <sys/limits.h> 38#include <sys/msg.h> --- 186 unchanged lines hidden (view full) --- 225 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm); 226 bsp->shm_segsz = lsp->shm_segsz; 227 bsp->shm_lpid = lsp->shm_lpid; 228 bsp->shm_cpid = lsp->shm_cpid; 229 bsp->shm_nattch = lsp->shm_nattch; 230 bsp->shm_atime = lsp->shm_atime; 231 bsp->shm_dtime = lsp->shm_dtime; 232 bsp->shm_ctime = lsp->shm_ctime; | 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/syscallsubr.h> 35#include <sys/sysproto.h> 36#include <sys/proc.h> 37#include <sys/limits.h> 38#include <sys/msg.h> --- 186 unchanged lines hidden (view full) --- 225 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm); 226 bsp->shm_segsz = lsp->shm_segsz; 227 bsp->shm_lpid = lsp->shm_lpid; 228 bsp->shm_cpid = lsp->shm_cpid; 229 bsp->shm_nattch = lsp->shm_nattch; 230 bsp->shm_atime = lsp->shm_atime; 231 bsp->shm_dtime = lsp->shm_dtime; 232 bsp->shm_ctime = lsp->shm_ctime; |
233 /* this goes (yet) SOS */ 234 bsp->shm_internal = PTRIN(lsp->private3); | |
235} 236 237static void 238bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp) 239{ 240 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm); | 233} 234 235static void 236bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp) 237{ 238 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm); |
241 lsp->shm_segsz = bsp->shm_segsz; | 239 if (bsp->shm_segsz > INT_MAX) 240 lsp->shm_segsz = INT_MAX; 241 else 242 lsp->shm_segsz = bsp->shm_segsz; |
242 lsp->shm_lpid = bsp->shm_lpid; 243 lsp->shm_cpid = bsp->shm_cpid; | 243 lsp->shm_lpid = bsp->shm_lpid; 244 lsp->shm_cpid = bsp->shm_cpid; |
244 lsp->shm_nattch = bsp->shm_nattch; | 245 if (bsp->shm_nattch > SHRT_MAX) 246 lsp->shm_nattch = SHRT_MAX; 247 else 248 lsp->shm_nattch = bsp->shm_nattch; |
245 lsp->shm_atime = bsp->shm_atime; 246 lsp->shm_dtime = bsp->shm_dtime; 247 lsp->shm_ctime = bsp->shm_ctime; | 249 lsp->shm_atime = bsp->shm_atime; 250 lsp->shm_dtime = bsp->shm_dtime; 251 lsp->shm_ctime = bsp->shm_ctime; |
248 /* this goes (yet) SOS */ 249 lsp->private3 = PTROUT(bsp->shm_internal); | 252 lsp->private3 = 0; |
250} 251 252static void 253linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp) 254{ 255 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm); 256 bsp->msg_cbytes = lsp->msg_cbytes; 257 bsp->msg_qnum = lsp->msg_qnum; --- 161 unchanged lines hidden (view full) --- 419 return (error); 420} 421 422static int 423linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr) 424{ 425 struct l_shmid64_ds linux_shmid64; 426 | 253} 254 255static void 256linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp) 257{ 258 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm); 259 bsp->msg_cbytes = lsp->msg_cbytes; 260 bsp->msg_qnum = lsp->msg_qnum; --- 161 unchanged lines hidden (view full) --- 422 return (error); 423} 424 425static int 426linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr) 427{ 428 struct l_shmid64_ds linux_shmid64; 429 |
430 /* 431 * XXX: This is backwards and loses information in shm_nattch 432 * and shm_segsz. We should probably either expose the BSD 433 * shmid structure directly and convert it to either the 434 * non-64 or 64 variant directly or the code should always 435 * convert to the 64 variant and then truncate values into the 436 * non-64 variant if needed since the 64 variant has more 437 * precision. 438 */ |
|
427 if (ver == LINUX_IPC_64) { 428 bzero(&linux_shmid64, sizeof(linux_shmid64)); 429 430 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm, 431 &linux_shmid64.shm_perm); 432 433 linux_shmid64.shm_segsz = linux_shmid->shm_segsz; 434 linux_shmid64.shm_atime = linux_shmid->shm_atime; --- 436 unchanged lines hidden --- | 439 if (ver == LINUX_IPC_64) { 440 bzero(&linux_shmid64, sizeof(linux_shmid64)); 441 442 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm, 443 &linux_shmid64.shm_perm); 444 445 linux_shmid64.shm_segsz = linux_shmid->shm_segsz; 446 linux_shmid64.shm_atime = linux_shmid->shm_atime; --- 436 unchanged lines hidden --- |