From owner-freebsd-bugs Mon Oct 14 14:20:28 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B32F37B401 for ; Mon, 14 Oct 2002 14:20:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1EA8B43EB7 for ; Mon, 14 Oct 2002 14:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9ELK0Co068243 for ; Mon, 14 Oct 2002 14:20:00 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9ELK0gH068242; Mon, 14 Oct 2002 14:20:00 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E029137B401 for ; Mon, 14 Oct 2002 14:11:59 -0700 (PDT) Received: from unicorn.europeonline.net (unicorn.europeonline.net [194.177.33.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id 24C8243EA3 for ; Mon, 14 Oct 2002 14:11:58 -0700 (PDT) (envelope-from jd@europeonline.net) Received: from io.europeonline.net (io.europeonline.net [194.177.40.155]) by unicorn.europeonline.net (8.11.6/8.11.6) with ESMTP id g9ELBfU00800 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified OK); Mon, 14 Oct 2002 23:11:46 +0200 (CEST) (envelope-from jd@europeonline.net) Received: (from root@localhost) by io.europeonline.net (8.12.6/8.12.6) id g9ELBflP017240; Mon, 14 Oct 2002 23:11:41 +0200 (CEST) (envelope-from jd) Message-Id: <200210142111.g9ELBflP017240@io.europeonline.net> Date: Mon, 14 Oct 2002 23:11:41 +0200 (CEST) From: jd@europeonline.net To: FreeBSD-gnats-submit@FreeBSD.org Cc: jd@europeonline.net X-Send-Pr-Version: 3.113 Subject: kern/44064: Linux IPC emulation fails for recent progs (patch included) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 44064 >Category: kern >Synopsis: Linux IPC emulation fails for recent progs (patch included) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Oct 14 14:20:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Joerg Dorchain >Release: FreeBSD 4.7-STABLE i386 >Organization: Europe Online >Environment: System: FreeBSD io.europeonline.net 4.7-STABLE FreeBSD 4.7-STABLE #1: Fri Oct 11 15:35:52 CEST 2002 root@io.europeonline.net:/usr/obj/mnt/src/sys/VALINUX-ZENDSHM i386 >Description: The attached semtest.c, compile on Linux to the attached semtest binary, is the most simplest program I can easily get to reproduce the problem: Linux kernel api changed and some fields are bigger now for IPC structures. >How-To-Repeat: Execute the attached semtest binary under the linux-emulation. The error is shown. >Fix: The attached patch is in a works-for-me-state and shows what has changed. It may need some beautyfication as I am completely new the FreeBSD kernel hacking (only done Linux before ;) --- semtest.c begins here --- # include # include # include #include #include #include union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short int *array; /* array for GETALL, SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; int main(int arc, char ** argv) { union semun ick; struct semid_ds buf; int sem_id; int i; /* acquire the semaphore */ sem_id = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); printf("semid %d\n",sem_id); if (sem_id < 0) { perror("semget"); exit(1); } ick.val = 1; if ((i=semctl(sem_id, 0, SETVAL, ick)) < 0) { perror("semctl(SETVAL)"); exit(1); } printf("setval return %d\n",i); if (1) { /* restrict it to use only by the appropriate user_id ... not that this * stops CGIs from acquiring it and dinking around with it. */ buf.sem_perm.uid = 99; buf.sem_perm.gid = 98; buf.sem_perm.mode = 0600; ick.buf = &buf; if ((i=semctl(sem_id, 0, IPC_SET, ick)) < 0) { perror("semctl(IPC_SET)"); exit(1); } printf("ipcset return %d\n",i); } return 0; } --- semtest.c ends here --- begin 644 semtest M?T5,1@$!`0,```````````(``P`!````4(0$"#0```"D;P```````#0`(``& M`"@`'@`;``8````T````-(`$"#2`!`C`````P`````4````$`````P```/0` M``#T@`0(](`$"!,````3````!`````$````!``````````"`!`@`@`0([`8` M`.P&```%`````!````$```#L!@``[)8$".R6!`CX````$`$```8`````$``` M`@```$0'``!$EP0(1)<$"*````"@````!@````0````$````"`$```B!!`@( M@00((````"`````$````!````"]L:6(O;&0M;&EN=7@N&%?9FEN86QI>F4`7U]D97)E9VES=&5R M7V9R86UE7VEN9F\`#_____)2"7!`AH"````.G0_____R4DEP0( M:!````#IP/____\E*)<$"&@8````Z;#_____)2R7!`AH(````.F@_____R4P MEP0(:"@```#ID/____\E-)<$"&@P````Z8#_____)3B7!`AH.````.EP____ M_R4\EP0(:$````#I8/___P``````````,>U>B>&#Y/!05%)H<(8$"&B0@P0( M459H4(4$".AW____](GV58GE4U#H`````%N!PY(2``"+@S````"%P'0"_]"+ M7?S)PXGVD)"0D)"0D)!5BQ7XE@0(B>6#[`B%TG5)BQ7TE@0(BP*%P'0:C70F M`(U"!*/TE@0(_Q*+%?26!`B+"H7)=>JXV(,$"(7`=!"#[`QH_)8$".CL_O__ M@\00N`$```"C^)8$"(GL7<.-=@!5B>6#[`B)[%W#C;8`````58GEN+B#!`B# M[`B%P'05@^P(:.27!`AH_)8$".B'_O__@\00B>Q=PY"-M"8`````58GE@^P( MB>Q=PXVV`````%6)Y5.#[$AH@`,``&H!:@#HP_[__XG#6%I3:)B&!`CHA/[_ M_X/$$(7;>1F#[`QHHH8$".A`_O__QP0D`0```.B$_O__:@%J$&H`4^B8_O__ M@\00A53@^P$@_C_NP"7!`AT%HUV`(V\)P````"#ZP3_ MT(L#@_C_=?186UW#58GE@^P(B>Q=PXVV`````%6)Y5-2Z`````!;@<.6$``` MC78`Z!?^__^+7?S)PP```P````$``@!S96UI9"`E9`H` MA`0(+H0$"#Z$!`@``````0```!`````,````D(,$"`T```!PA@0(!````"B! M!`@%````+(($"`8```!L@00("@```)D````+````$````!4``````````P`` M`!"7!`@"````2````!0````1````%P```$B#!`@1````0(,$"!(````(```` M$P````@```#^__]O`(,$"/___V\!````\/__;^:"!`@```````````$````` M`.D!&4X```@```!D````=(0$"`$```!D````=(0$"#D````\`````````$@` M``"``````````'(```"``````````(P```"``````````+L```"````````` M`/,```"``````````#`!``"``````````($!``"``````````-(!``"````` M`````/T!``"``````````"P"``"``````````%8"``"``````````'\"``"` M`````````)D"``"``````````+0"``"``````````-4"``"```````````X# M``"``````````#$#``"``````````%8#``"``````````(`#``"````````` M`*D#``""`````````,,#``""``````````````"B``````````````"B```` M``````D$``""````8U8``"0$``""````[UL!`$P$``""`````````&($``"" M`````````'D$``""``````````````"B``````````````"B```````````` M``"B`````````(T$``""````V`0``,8$``"``,<```````````"B```````` M`-H$``"``"```````/$$``"``"$```````@%``"``"(``````!T%``"``",` M`````#,%``"``"4``````$L%``"``"8``````&$%``"``#$``````'@%``"` M`#(``````)`%``"``#,``````*<%``"``#0``````,`%``"``#4``````-@% M``"``#8``````/$%``"``#@```````D&``"``#D``````"(&``"``#L````` M`$(&``"``#T``````%@&``"``#X``````&X&``"``#\``````(0&``"``$`` M`````)H&``"``$$``````+$&``"``$(``````,D&``"``$,``````-\&``"` M`$0``````/8&``"``$4```````P'``"``$8``````"0'``"``$<``````#L' M``"``$@``````%0'``"``$D``````&D'``"``$X``````,\'``"``%$````` M`.<'``"``%(```````<(``"``%,``````!X(``"``%0``````#D(``"``%4` M`````%4(``"``%8``````&T(``"``%@``````(4(``"``%L``````)\(``"` M`%X``````+<(``"``&4``````,T(``"``&@``````.<(``"``&P```````$) M``"``'$``````!H)``"``'(``````#4)``"``'4``````%`)``"``'8````` M`&T)``"``'D``````(@)``"``'H``````*4)``"``'T``````+T)``"``(`` M`````-8)``"``(,``````/$)``"``(0```````T*``"``(<``````"8*``"` M`(H``````$`*``""````RY0!`'0*``""````1A```)P*``"````````````` M``"B`````````-(*``"``````````!H+``"``",``````%8+``"````````` M`%D,``"``#0``````'4,``"``#P``````,(,``"``$,``````/H,``"``$8` M`````!8-``"``%,``````*D-``"``%H``````.<-``"``%X```````0.``"` M`````````-D.``"``&P``````/D.``"``'0``````$T/``"``'D``````&X/ M``"``($``````/8/``"``(8``````#00``"``(P```````````"B```````` M``````"B`````````(T$``""````$0H``$P0``"``!\!`````&(0``"``#@! M``````````"B`````````'<0``""`````````(H0``""````8A\``(T$``"" M``````````````"B`````````)P0``""``````````````"B`````````,D0 M``"``$L```````````"B``````````````"B`````````$P1``"``!X````` M`(\1``"``",``````-01``""`````````.<1``""````-<$!`$P$``#"```` M`````'<0``#"`````````(H0``""`````````(T$``#"`````````)P0``#" M``````````````"B`````````(T$``#"`````````/@1``"``````````-<2 M``"```````````X3``"``$@``````#@3``"``$L``````&<3``"``$P````` M`)@3``"``%4``````,L3``"``%H```````84``"``%X``````#\4``"``&$` M`````'<4``"``&(``````*\4``"``````````%P5``"```````````47``"` M`````````/L7``"``````````'(8``"``*T```````````"B```````````` M``"B`````````)88``"``#4```````D9``"``#<``````"$9``"``#@````` M`#D9``"``#D``````%,9``"``#H```````````"B`````````&T9```@`!D` M``````````!D````=(0$"(,9``!D````4(4$"(D9``!D````4(4$"#D````\ M`````````$@```"``````````'(```"``````````(P```"``````````+L` M``"``````````/,```"``````````#`!``"``````````($!``"````````` M`-(!``"``````````/T!``"``````````"P"``"``````````%8"``"````` M`````'\"``"``````````)D"``"``````````+0"``"``````````-4"``"` M``````````X#``"``````````#$#``"``````````%8#``"``````````(`# M``"``````````),9``""````K[P``*P9``""`````````,09``""```````` M``````"B`````````-T9``""``````````````"B``````````````"B```` M`````/89``""````[UL!`*P9``#"`````````(T$``#"````V`0``!`:``"` M`"```````"<:``"``"$``````#X:``"``"(``````%,:``"``",``````&D: M``"``"4``````($:``"``"8``````)<:``"``#$``````*X:``"``#(````` M`,8:``"``#,``````-T:``"``#0``````/8:``"``#4```````X;``"``#8` M`````"<;``"``#@``````#\;``"``#D``````%@;``"``#L``````'@;``"` M`#T``````(X;``"``#X``````*0;``"``#\``````+H;``"``$```````-`; M``"``$$``````.<;``"``$(``````/\;``"``$,``````!4<``"``$0````` M`"P<``"``$4``````$(<``"``$8``````%H<``"``$<``````'$<``"``$@` M`````(H<``"``$D``````)\<``"``$X```````4=``"``%$``````!T=``"` M`%(``````#T=``"``%,``````%0=``"``%0``````&\=``"``%4``````(L= M``"``%8``````*,=``"``%@``````+L=``"``%L``````-4=``"``%X````` M`.T=``"``&4```````,>``"``&@``````!T>``"``&P``````#<>``"``'$` M`````%`>``"``'(``````&L>``"``'4``````(8>``"``'8``````*,>``"` M`'D``````+X>``"``'H``````-L>``"``'T``````/,>``"``(````````P? M``"``(,``````""!I;G0Z="@P M+#$U*3US.')E86PZ*#`L,2DL,"PS,CMI;6%G.B@P+#$I+#,R+#,R.SL`8V]M M<&QE>"!F;&]A=#IT*#`L,38I/7(H,"PQ-BD[.#LP.P!C;VUP;&5X(&1O=6)L M93IT*#`L,3"!L;VYG(&1O=6)L93IT M*#`L,3@I/7(H,"PQ."D[,C0[,#L`7U]B=6EL=&EN7W9A7VQI"]C;VYF:67-D97!S+V=N=2]?1U]C;VYF M:67-D97!S+W5N:7@O"]B:71S+W1Y<&5S+F@` M+BXO:6YC;'5D92]F96%T=7)E7,O8V1E9G,N:``O=7-R+VQI8B]G8V,M;&EB+VDS.#8M7!E"]S>7-V+VQI;G5X+V)I=',O3HH,"PQ*2PS,BPS,CM?7W-C:&5D<&%R M86TZ*#$P+#$I+#8T+#,R.U]?:6YH97)I='-C:&5D.B@P+#$I+#DV+#,R.U]? MF4Z*#@L,2DL,C4V+#,R.SL`<'1H5]T.G0H.2PQ,2D]*#`L-"D` M<'1H%]T.G0H.2PQ,BD]*#DL,3,I/7,R-%]?;5]R97-E&%T=')?=#IT*#DL,30I/2@Y+#$U M*3US-%]?;75T97AK:6YD.B@P+#$I+#`L,S([.P!P=&AR96%D7V]N8V5?=#IT M*#DL,38I/2@P+#$I`%]P=&AR96%D7W)W;&]C:U]T.E0H.2PQ-RD]7-D97!S+W5N:7@O"]I,S@V+V)I=',O=V-H87(N M:`!?7VUB5]F8W0Z M="@Q-RPQ."D]*#$W+#$Y*3TJ*#$W+#(P*3UF*#`L,2D`7U]G8V]N=E]T'-?7V=C;VYV7VQO861E9%]O8FIE8W0Z+#`L,S([ M7U]M;V1N86UE.B@Q-RPS,BD]*B@P+#(I+#,R+#,R.U]?8V]U;G1E7!E'-?<'1H7,OCHH,"PQ*2PR,C0L,S(['1?9F-T.G0H-#@L,34I/2@T."PQ-BD] M*B@T."PQ-RD]9B@P+#$I`%]?9V-O;G9?=')A;G-?<75E%]N965D961?9G)O;3HH,"PQ*2PR.#@L M,S([7U]M:6Y?;F5E9&5D7W1O.B@P+#$I+#,R,"PS,CM?7VUA>%]N965D961? M=&\Z*#`L,2DL,S4R+#,R.U]?7!E.B@P+#$I+#DV+#,R.W)A;F1?9&5G M.B@P+#$I+#$R."PS,CMR86YD7W-E<#HH,"PQ*2PQ-C`L,S([96YD7W!T```````````````$`````````(P````!`````@```)"&!`B0!@`` M7```````````````!`````````"4`````0````,```#LE@0([`8``!`````` M``````````0`````````F@````$````#````_)8$"/P&```$```````````` M```$`````````*0````!`````P````"7!`@`!P``"```````````````!``` M``````"K`````0````,````(EP0("`<```@```````````````0````````` ML@````$````#````$)<$"!`'```T```````````````$````!````+<````& M`````P```$27!`A$!P``H`````4`````````!`````@```#``````0````$` M``#DEP0(Y`<```````````````````$`````````Q@````@````#````Y)<$ M".0'```8```````````````$`````````,L````!``````````````#D!P`` M^!8``!@`````````!`````P```#1`````P``````````````W!X``!E.```` M``````````$`````````V@````$``````````````/5L``!-`0`````````` M```!`````````.,````'``````````````!";@``>````````````````0`` M```````1`````P``````````````NFX``.D```````````````$````````` M`0````(``````````````%1T```0!0``'0```#H````$````$`````D````# M``````````````!D>0``=`(``````````````0`````````````````````` M`````````````/2`!`@``````P`!```````(@00(``````,``@``````*($$ M"``````#``,``````&R!!`@``````P`$```````L@@0(``````,`!0`````` MYH($"``````#``8```````"#!`@``````P`'``````!`@P0(``````,`"``` M````2(,$"``````#``D``````)"#!`@``````P`*``````"H@P0(``````,` M"P``````4(0$"``````#``P``````'"&!`@``````P`-``````"0A@0(```` M``,`#@``````[)8$"``````#``\``````/R6!`@``````P`0````````EP0( M``````,`$0``````")<$"``````#`!(``````!"7!`@``````P`3``````!$ MEP0(``````,`%```````Y)<$"``````#`!4``````.27!`@``````P`6```` M``````````````,`%P`````````````````#`!@``````````````````P`9 M``````````````````,`&@`````````````````#`!L````````````````` M`P`<``````````````````,`'0`!```````````````$`/'_#````'2$!`@` M```````,`!L```!TA`0(``````(`#``K```````````````$`/'_,@`````` M````````!`#Q_PP```"@A`0(````````#``]````])8$"``````!``\`00`` M``B7!`@``````0`2`$\```#XE@0(``````$`#P!;````H(0$"``````"``P` M<0```/R6!`@``````0`0`(0`````A00(``````(`#`"/````Y)<$"!@````! M`!8`F````!"%!`@``````@`,`*0```!`A00(``````(`#`"O````_)8$"``` M```!``\`O0````"7!`@``````0`1`#(```````````````0`\?\,````,(8$ M"`````````P`RP```#"&!`@``````@`,`.$````$EP0(``````$`$0"D```` M8(8$"``````"``P`KP```/R6!`@``````0`/`.X````,EP0(``````$`$@#[ M````_)8$"``````!`!```0``````````````!`#Q_PP```!PA@0(```````` M#``)`0`````````````$`/'_$P$``$27!`@`````$0`4`!P!``"X@P0(@0`` M`"(````]`0``D(8$"`0````0``X`1`$``,B#!`CI`0``$@```%8!``"0@P0( M`````!(`"@!<`0``V(,$"*P````B````?P$``%"$!`@`````$@`,`(8!``#D MEP0(`````!$`\?^2`0``4(4$"-@````2``P`EP$``.B#!`C&````$@```+0! M``#LE@0(`````"``#P"_`0``^(,$""X````2````T0$``'"&!`@`````$@`- M`-`!?7T-43U)?14Y$7U\`7U]$5$]2 M7T5.1%]?`%]?1E)!345?14Y$7U\`seq = lpp->seq; } +static void +linux_to_bsd_ipc64_perm(struct l_ipc64_perm *lpp, struct ipc_perm *bpp) +{ + bpp->key = lpp->key; + bpp->uid = lpp->uid; + bpp->gid = lpp->gid; + bpp->cuid = lpp->cuid; + bpp->cgid = lpp->cgid; + bpp->mode = lpp->mode; + bpp->seq = lpp->seq; +} + static void bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp) @@ -105,6 +131,18 @@ lpp->seq = bpp->seq; } +static void +bsd_to_linux_ipc64_perm(struct ipc_perm *bpp, struct l_ipc64_perm *lpp) +{ + lpp->key = bpp->key; + lpp->uid = bpp->uid; + lpp->gid = bpp->gid; + lpp->cuid = bpp->cuid; + lpp->cgid = bpp->cgid; + lpp->mode = bpp->mode; + lpp->seq = bpp->seq; +} + struct l_semid_ds { struct l_ipc_perm sem_perm; l_time_t sem_otime; @@ -116,6 +154,17 @@ l_ushort sem_nsems; }; +struct l_semid64_ds { + struct l_ipc64_perm sem_perm; + l_time_t sem_otime; + l_time_t sem_ctime; + void *sem_base; + void *sem_pending; + void *sem_pending_last; + void *undo; + l_ushort sem_nsems; +}; + struct l_shmid_ds { struct l_ipc_perm shm_perm; l_int shm_segsz; @@ -130,6 +179,20 @@ void *private3; }; +struct l_shmid64_ds { + struct l_ipc64_perm shm_perm; + l_int shm_segsz; + l_time_t shm_atime; + l_time_t shm_dtime; + l_time_t shm_ctime; + l_ushort shm_cpid; + l_ushort shm_lpid; + l_short shm_nattch; + l_ushort private1; + void *private2; + void *private3; +}; + static void linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp) { @@ -141,6 +204,16 @@ } static void +linux_to_bsd_semid64_ds(struct l_semid64_ds *lsp, struct semid_ds *bsp) +{ + linux_to_bsd_ipc64_perm(&lsp->sem_perm, &bsp->sem_perm); + bsp->sem_otime = lsp->sem_otime; + bsp->sem_ctime = lsp->sem_ctime; + bsp->sem_nsems = lsp->sem_nsems; + bsp->sem_base = lsp->sem_base; +} + +static void bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp) { bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm); @@ -151,6 +224,16 @@ } static void +bsd_to_linux_semid64_ds(struct semid_ds *bsp, struct l_semid64_ds *lsp) +{ + bsd_to_linux_ipc64_perm(&bsp->sem_perm, &lsp->sem_perm); + lsp->sem_otime = bsp->sem_otime; + lsp->sem_ctime = bsp->sem_ctime; + lsp->sem_nsems = bsp->sem_nsems; + lsp->sem_base = bsp->sem_base; +} + +static void linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp) { linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm); @@ -163,6 +246,19 @@ bsp->shm_ctime = lsp->shm_ctime; bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */ } +static void +linux_to_bsd_shmid64_ds(struct l_shmid64_ds *lsp, struct shmid_ds *bsp) +{ + linux_to_bsd_ipc64_perm(&lsp->shm_perm, &bsp->shm_perm); + bsp->shm_segsz = lsp->shm_segsz; + bsp->shm_lpid = lsp->shm_lpid; + bsp->shm_cpid = lsp->shm_cpid; + bsp->shm_nattch = lsp->shm_nattch; + bsp->shm_atime = lsp->shm_atime; + bsp->shm_dtime = lsp->shm_dtime; + bsp->shm_ctime = lsp->shm_ctime; + bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */ +} static void bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp) @@ -178,6 +274,20 @@ lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */ } +static void +bsd_to_linux_shmid64_ds(struct shmid_ds *bsp, struct l_shmid64_ds *lsp) +{ + bsd_to_linux_ipc64_perm(&bsp->shm_perm, &lsp->shm_perm); + lsp->shm_segsz = bsp->shm_segsz; + lsp->shm_lpid = bsp->shm_lpid; + lsp->shm_cpid = bsp->shm_cpid; + lsp->shm_nattch = bsp->shm_nattch; + lsp->shm_atime = bsp->shm_atime; + lsp->shm_dtime = bsp->shm_dtime; + lsp->shm_ctime = bsp->shm_ctime; + lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */ +} + int linux_semop(struct proc *p, struct linux_semop_args *args) { @@ -212,6 +322,7 @@ linux_semctl(struct proc *p, struct linux_semctl_args *args) { struct l_semid_ds linux_semid; + struct l_semid64_ds linux_semid64; struct __semctl_args /* { int semid; int semnum; @@ -261,6 +372,15 @@ unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); linux_to_bsd_semid_ds(&linux_semid, unptr->buf); return __semctl(p, &bsd_args); + case LINUX_IPC_SET|LINUX_IPC_64: + bsd_args.cmd = IPC_SET; + error = copyin((caddr_t)args->arg.buf, &linux_semid64, + sizeof(linux_semid64)); + if (error) + return (error); + unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); + linux_to_bsd_semid64_ds(&linux_semid64, unptr->buf); + return __semctl(p, &bsd_args); case LINUX_IPC_STAT: bsd_args.cmd = IPC_STAT; unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); @@ -272,6 +392,17 @@ bsd_to_linux_semid_ds(unptr->buf, &linux_semid); return copyout(&linux_semid, (caddr_t)args->arg.buf, sizeof(linux_semid)); + case LINUX_IPC_STAT|LINUX_IPC_64: + bsd_args.cmd = IPC_STAT; + unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); + error = __semctl(p, &bsd_args); + if (error) + return error; + p->p_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid, + unptr->buf->sem_perm); + bsd_to_linux_semid64_ds(unptr->buf, &linux_semid64); + return copyout(&linux_semid64, (caddr_t)args->arg.buf, + sizeof(linux_semid64)); case LINUX_IPC_INFO: case LINUX_SEM_INFO: error = copyin((caddr_t)args->arg.buf, &linux_seminfo, @@ -421,6 +552,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args) { struct l_shmid_ds linux_shmid; + struct l_shmid64_ds linux_shmid64; struct shmctl_args /* { int shmid; int cmd; @@ -439,6 +571,15 @@ bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid); return copyout(&linux_shmid, (caddr_t)args->buf, sizeof(linux_shmid)); + case LINUX_IPC_STAT|LINUX_IPC_64: + bsd_args.shmid = args->shmid; + bsd_args.cmd = IPC_STAT; + bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); + if ((error = shmctl(p, &bsd_args))) + return error; + bsd_to_linux_shmid64_ds(bsd_args.buf, &linux_shmid64); + return copyout(&linux_shmid64, (caddr_t)args->buf, sizeof(linux_shmid64)); + case LINUX_IPC_SET: if ((error = copyin((caddr_t)args->buf, &linux_shmid, sizeof(linux_shmid)))) @@ -449,6 +590,16 @@ bsd_args.cmd = IPC_SET; return shmctl(p, &bsd_args); + case LINUX_IPC_SET|LINUX_IPC_64: + if ((error = copyin((caddr_t)args->buf, &linux_shmid64, + sizeof(linux_shmid64)))) + return error; + bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); + linux_to_bsd_shmid64_ds(&linux_shmid64, bsd_args.buf); + bsd_args.shmid = args->shmid; + bsd_args.cmd = IPC_SET; + return shmctl(p, &bsd_args); + case LINUX_IPC_RMID: bsd_args.shmid = args->shmid; bsd_args.cmd = IPC_RMID; @@ -460,6 +611,20 @@ return error; bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf); + } + return shmctl(p, &bsd_args); + + case LINUX_IPC_RMID|LINUX_IPC_64: + bsd_args.shmid = args->shmid; + bsd_args.cmd = IPC_RMID; + if (args->buf == NULL) + bsd_args.buf = NULL; + else { + if ((error = copyin((caddr_t)args->buf, &linux_shmid64, + sizeof(linux_shmid64)))) + return error; + bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); + linux_to_bsd_shmid64_ds(&linux_shmid64, bsd_args.buf); } return shmctl(p, &bsd_args); --- linux_ipc.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message