Subject: Re: ipc errors/Linux Emulation NetBSD-3BETA using Oracle
To: Jose Luis Rodriguez Garcia <jose.l.rodriguez@getronics.com>
From: Chuck Silvers <chuq@chuq.com>
List: current-users
Date: 11/02/2005 08:10:06
--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Nov 02, 2005 at 03:18:29PM +0100, Jose Luis Rodriguez Garcia wrote:
> It fails in the same call(ipc):
> 741 oracle CALL ipc(0x18,0x90000,0x102,0,0xbfbfd8c0)
> 741 oracle RET ipc -1 errno -22 Invalid argument
ok, here's another patch that implements more of the linux shmctl functions.
it'll print the cmd ID on the console if the requested function is a newer one
that I still didn't write.
-Chuck
--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.linux-shm.2"
Index: src/sys/compat/linux/common/linux_ipc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_ipc.c,v
retrieving revision 1.31
diff -u -p -r1.31 linux_ipc.c
--- src/sys/compat/linux/common/linux_ipc.c 26 Feb 2005 23:10:19 -0000 1.31
+++ src/sys/compat/linux/common/linux_ipc.c 2 Nov 2005 16:08:55 -0000
@@ -469,11 +469,14 @@ linux_sys_shmctl(l, v, retval)
struct sys___shmctl13_args nua;
struct shmid_ds *bsp, bs;
struct linux_shmid_ds ls;
- int error;
+ struct linux_shminfo64 lsi64;
+ struct linux_shm_info lsi;
+ int error, i;
SCARG(&nua, shmid) = SCARG(uap, shmid);
switch (SCARG(uap, cmd)) {
case LINUX_IPC_STAT:
+ case LINUX_SHM_STAT:
sg = stackgap_init(p, 0);
bsp = stackgap_alloc(p, &sg, sizeof(struct shmid_ds));
SCARG(&nua, cmd) = IPC_STAT;
@@ -483,7 +486,12 @@ linux_sys_shmctl(l, v, retval)
if ((error = copyin(SCARG(&nua, buf), &bs, sizeof bs)))
return error;
bsd_to_linux_shmid_ds(&bs, &ls);
+ if (SCARG(uap, cmd) == LINUX_SHM_STAT) {
+ retval[0] = IXSEQ_TO_IPCID(bs.shm_perm._key,
+ bs.shm_perm);
+ }
return copyout(&ls, SCARG(uap, buf), sizeof ls);
+
case LINUX_IPC_SET:
if ((error = copyin(SCARG(uap, buf), &ls, sizeof ls)))
return error;
@@ -495,22 +503,47 @@ linux_sys_shmctl(l, v, retval)
SCARG(&nua, cmd) = IPC_SET;
SCARG(&nua, buf) = bsp;
break;
+
case LINUX_IPC_RMID:
SCARG(&nua, cmd) = IPC_RMID;
SCARG(&nua, buf) = NULL;
break;
+
case LINUX_SHM_LOCK:
SCARG(&nua, cmd) = SHM_LOCK;
SCARG(&nua, buf) = NULL;
break;
+
case LINUX_SHM_UNLOCK:
SCARG(&nua, cmd) = SHM_UNLOCK;
SCARG(&nua, buf) = NULL;
break;
+
case LINUX_IPC_INFO:
- case LINUX_SHM_STAT:
+ memset(&lsi64, 0, sizeof lsi64);
+ lsi64.l_shmmax = shminfo.shmmax;
+ lsi64.l_shmmin = shminfo.shmmin;
+ lsi64.l_shmmni = shminfo.shmmni;
+ lsi64.l_shmseg = shminfo.shmseg;
+ lsi64.l_shmall = shminfo.shmall;
+ return copyout(&lsi64, SCARG(uap, buf), sizeof lsi64);
+
case LINUX_SHM_INFO:
+ memset(&lsi, 0, sizeof lsi);
+ lsi.l_used_ids = shm_nused;
+ for (i = 0; i < shminfo.shmmni; i++) {
+ if (shmsegs[i].shm_perm.mode & 0x800) {
+ lsi.l_shm_tot += shmsegs[i].shm_segsz;
+ }
+ }
+ lsi.l_shm_rss = 0;
+ lsi.l_shm_swp = 0;
+ lsi.l_swap_attempts = 0;
+ lsi.l_swap_successes = 0;
+ return copyout(&lsi, SCARG(uap, buf), sizeof lsi);
+
default:
+ printf("linux_sys_shmctl cmd %d\n", SCARG(uap, cmd));
return EINVAL;
}
return sys___shmctl13(l, &nua, retval);
Index: src/sys/compat/linux/common/linux_shm.h
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_shm.h,v
retrieving revision 1.6
diff -u -p -r1.6 linux_shm.h
--- src/sys/compat/linux/common/linux_shm.h 28 Sep 2004 19:05:19 -0000 1.6
+++ src/sys/compat/linux/common/linux_shm.h 2 Nov 2005 16:08:56 -0000
@@ -58,6 +58,27 @@ struct linux_shmid_ds {
void *l_private3;
};
+struct linux_shminfo64 {
+ u_long l_shmmax;
+ u_long l_shmmin;
+ u_long l_shmmni;
+ u_long l_shmseg;
+ u_long l_shmall;
+ u_long l___unused1;
+ u_long l___unused2;
+ u_long l___unused3;
+ u_long l___unused4;
+};
+
+struct linux_shm_info {
+ int l_used_ids;
+ u_long l_shm_tot;
+ u_long l_shm_rss;
+ u_long l_shm_swp;
+ u_long l_swap_attempts;
+ u_long l_swap_successes;
+};
+
#define LINUX_SHM_RDONLY 0x1000
#define LINUX_SHM_RND 0x2000
#define LINUX_SHM_REMAP 0x4000
--CE+1k2dSO48ffgeK--