PATCH: [fix for] 2.3.14 continues to break perl with libc5 (or..)

Alan Cox (alan@lxorguk.ukuu.org.uk)
Tue, 24 Aug 1999 15:45:35 +0100 (BST)


Try this. Note that msqid_ds has to remain the name for the user space
structure for libc5. msqid_ds_kern is the kernel used structure.

diff -u --new-file --recursive --exclude-from ../exclude linux.15p2/include/linux/msg.h linux.ac/include/linux/msg.h
--- linux.15p2/include/linux/msg.h Mon Aug 23 15:15:56 1999
+++ linux.ac/include/linux/msg.h Tue Aug 24 15:23:52 1999
@@ -11,8 +11,10 @@
#define MSG_NOERROR 010000 /* no error if message is too big */
#define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/

+#ifdef __KERNEL__
+
/* one msqid structure for each queue on the system */
-struct msqid_ds {
+struct msqid_ds_kern {
struct ipc_perm msg_perm;
struct msg *msg_first; /* first message on queue */
struct msg *msg_last; /* last message in queue */
@@ -24,6 +26,24 @@
unsigned short msg_cbytes; /* current number of bytes on queue */
unsigned short msg_qnum; /* number of messages in queue */
unsigned short msg_qbytes; /* max number of bytes on queue */
+ __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */
+ __kernel_ipc_pid_t msg_lrpid; /* last receive pid */
+};
+
+#endif
+
+struct msqid_ds {
+ struct ipc_perm msg_perm;
+ struct msg *msg_first; /* first message on queue */
+ struct msg *msg_last; /* last message in queue */
+ __kernel_time_t msg_stime; /* last msgsnd time */
+ __kernel_time_t msg_rtime; /* last msgrcv time */
+ __kernel_time_t msg_ctime; /* last change time */
+ unsigned long msg_cbytes; /* Reuse junk fields for 32 bit */
+ unsigned long msg_qbytes; /* ditto */
+ unsigned short msg_cbytes_old; /* current number of bytes on queue */
+ unsigned short msg_qnum; /* number of messages in queue */
+ unsigned short msg_qbytes_old; /* max number of bytes on queue */
__kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */
__kernel_ipc_pid_t msg_lrpid; /* last receive pid */
};

diff -u --new-file --recursive --exclude-from ../exclude linux.15p2/ipc/msg.c linux.ac/ipc/msg.c
--- linux.15p2/ipc/msg.c Mon Aug 23 15:16:13 1999
+++ linux.ac/ipc/msg.c Tue Aug 24 15:29:34 1999
@@ -30,7 +30,7 @@
static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
#endif

-static struct msqid_ds *msgque[MSGMNI];
+static struct msqid_ds_kern *msgque[MSGMNI];
static int msgbytes = 0;
static int msghdrs = 0;
static unsigned short msg_seq = 0;
@@ -46,7 +46,7 @@
#endif

for (id = 0; id < MSGMNI; id++)
- msgque[id] = (struct msqid_ds *) IPC_UNUSED;
+ msgque[id] = (struct msqid_ds_kern *) IPC_UNUSED;
msgbytes = msghdrs = msg_seq = max_msqid = used_queues = 0;
init_waitqueue_head(&msg_lock);
#ifdef CONFIG_PROC_FS
@@ -59,7 +59,7 @@
static int real_msgsnd (int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg)
{
int id;
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;
struct ipc_perm *ipcp;
struct msg *msgh;
long mtype;
@@ -136,7 +136,7 @@

static int real_msgrcv (int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg)
{
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;
struct ipc_perm *ipcp;
struct msg *tmsg, *leastp = NULL;
struct msg *nmsg = NULL;
@@ -257,7 +257,7 @@
static int findkey (key_t key)
{
int id;
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;

for (id = 0; id <= max_msqid; id++) {
while ((msq = msgque[id]) == IPC_NOID)
@@ -273,20 +273,20 @@
static int newque (key_t key, int msgflg)
{
int id;
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;
struct ipc_perm *ipcp;

for (id = 0; id < MSGMNI; id++)
if (msgque[id] == IPC_UNUSED) {
- msgque[id] = (struct msqid_ds *) IPC_NOID;
+ msgque[id] = (struct msqid_ds_kern *) IPC_NOID;
goto found;
}
return -ENOSPC;

found:
- msq = (struct msqid_ds *) kmalloc (sizeof (*msq), GFP_KERNEL);
+ msq = (struct msqid_ds_kern *) kmalloc (sizeof (*msq), GFP_KERNEL);
if (!msq) {
- msgque[id] = (struct msqid_ds *) IPC_UNUSED;
+ msgque[id] = (struct msqid_ds_kern *) IPC_UNUSED;
wake_up (&msg_lock);
return -ENOMEM;
}
@@ -315,7 +315,7 @@
asmlinkage int sys_msgget (key_t key, int msgflg)
{
int id, ret = -EPERM;
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;

lock_kernel();
if (key == IPC_PRIVATE)
@@ -342,7 +342,7 @@

static void freeque (int id)
{
- struct msqid_ds *msq = msgque[id];
+ struct msqid_ds_kern *msq = msgque[id];
struct msg *msgp, *msgh;

msq->msg_perm.seq++;
@@ -350,7 +350,7 @@
msgbytes -= msq->msg_cbytes;
if (id == max_msqid)
while (max_msqid && (msgque[--max_msqid] == IPC_UNUSED));
- msgque[id] = (struct msqid_ds *) IPC_UNUSED;
+ msgque[id] = (struct msqid_ds_kern *) IPC_UNUSED;
used_queues--;
while (waitqueue_active(&msq->rwait) || waitqueue_active(&msq->wwait)) {
wake_up (&msq->rwait);
@@ -368,7 +368,7 @@
asmlinkage int sys_msgctl (int msqid, int cmd, struct msqid_ds *buf)
{
int id, err = -EINVAL;
- struct msqid_ds *msq;
+ struct msqid_ds_kern *msq;
struct msqid_ds tbuf;
struct ipc_perm *ipcp;

@@ -420,8 +420,10 @@
tbuf.msg_stime = msq->msg_stime;
tbuf.msg_rtime = msq->msg_rtime;
tbuf.msg_ctime = msq->msg_ctime;
+ tbuf.msg_cbytes_old = msq->msg_cbytes;
tbuf.msg_cbytes = msq->msg_cbytes;
tbuf.msg_qnum = msq->msg_qnum;
+ tbuf.msg_qbytes_old = msq->msg_qbytes;
tbuf.msg_qbytes = msq->msg_qbytes;
tbuf.msg_lspid = msq->msg_lspid;
tbuf.msg_lrpid = msq->msg_lrpid;
@@ -462,8 +464,10 @@
tbuf.msg_stime = msq->msg_stime;
tbuf.msg_rtime = msq->msg_rtime;
tbuf.msg_ctime = msq->msg_ctime;
+ tbuf.msg_cbytes_old = msq->msg_cbytes;
tbuf.msg_cbytes = msq->msg_cbytes;
tbuf.msg_qnum = msq->msg_qnum;
+ tbuf.msg_qbytes_old = msq->msg_qbytes;
tbuf.msg_qbytes = msq->msg_qbytes;
tbuf.msg_lspid = msq->msg_lspid;
tbuf.msg_lrpid = msq->msg_lrpid;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/