PERFORCE change 110179 for review
Jung-uk Kim
jkim at FreeBSD.org
Fri Nov 17 20:56:06 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=110179
Change 110179 by jkim at jkim_hammer on 2006/11/17 20:55:26
Add rudimentary IPC_INFO/MSG_INFO command support for linux_msgctl()
to pacify Linux ipcs(1).
Note: This patch and another fix from CVS fix msgctl08 and msgctl09.
Affected files ...
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#5 edit
Differences ...
==== //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#5 (text+ko) ====
@@ -83,6 +83,17 @@
l_ulong swap_successes;
};
+struct l_msginfo {
+ l_int msgpool;
+ l_int msgmap;
+ l_int msgmax;
+ l_int msgmnb;
+ l_int msgmni;
+ l_int msgssz;
+ l_int msgtql;
+ l_ushort msgseg;
+};
+
static void
bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp)
{
@@ -580,7 +591,7 @@
l_long lmtype;
int error;
- if ((l_long)args->msgsz < 0)
+ if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
return (EINVAL);
msgp = PTRIN(args->msgp);
if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
@@ -599,7 +610,7 @@
l_long lmtype;
int error;
- if ((l_long)args->msgsz < 0)
+ if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
return (EINVAL);
msgp = PTRIN(args->msgp);
if ((error = kern_msgrcv(td, args->msqid,
@@ -631,12 +642,39 @@
struct msqid_ds bsd_msqid;
bsd_cmd = args->cmd & ~LINUX_IPC_64;
- if (bsd_cmd == LINUX_IPC_SET) {
+ switch (bsd_cmd) {
+ case LINUX_IPC_INFO:
+ case LINUX_MSG_INFO: {
+ struct l_msginfo linux_msginfo;
+
+ /*
+ * XXX MSG_INFO uses the same data structure but returns different
+ * dynamic counters in msgpool, msgmap, and msgtql fields.
+ */
+ linux_msginfo.msgpool = (long)msginfo.msgmni *
+ (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
+ linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
+ linux_msginfo.msgmax = msginfo.msgmax;
+ linux_msginfo.msgmnb = msginfo.msgmnb;
+ linux_msginfo.msgmni = msginfo.msgmni;
+ linux_msginfo.msgssz = msginfo.msgssz;
+ linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
+ linux_msginfo.msgseg = msginfo.msgseg;
+ error = copyout(&linux_msginfo, PTRIN(args->buf),
+ sizeof(linux_msginfo));
+ if (error == 0)
+ td->td_retval[0] = msginfo.msgmni; /* XXX */
+
+ return (error);
+ }
+
+ case LINUX_IPC_SET:
error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
&linux_msqid, PTRIN(args->buf));
if (error)
return (error);
linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
+ break;
}
error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
More information about the p4-projects
mailing list