Subject: cygipc ENOSYS patch (was Re: cygipc-1.13pre1)
From: Jason Tishler <[email-masked]>
To: Charles Wilson <[email-masked]>
Cc: Cygwin <[email-masked]>
Date: Wed, 13 Nov 2002 09:09:46 -0500

Chuck,

On Tue, Nov 12, 2002 at 02:44:45PM -0500, Charles Wilson wrote:
> The attached src tarball contains cygipc-1.13pre1.  It has been
> reverted to the 32bit key_t treatment (e.g. pre-1.12), but other
> improvements in 1.12 remain.  Please generate your ENOSYS patches --
> if there are more beyond has been posted on the list -- against this.
> That'll make my job easier.

My patch (against cygipc-1.13pre1) changes the following cygipc
functions to return ENOSYS instead of EACCES if ipc-daemon is not
running:

    msgctl()
    msgget()
    msgrcv()
    msgsnd()

    semctl()
    semget()
    semop()

    shmat()
    shmctl()
    shmget()
    shmdt()

Since I could only (easily) test semget() and shmget() under PostgreSQL,
I decided to write a simply test program, cygtest.cc, to exercise all of
my cygipc changes.

Attached are the following files:

    o cygipc-1.13pre1.patch: ENOSYS patch
    o cygipc-1.13pre1.ChangeLog: corresponding ChangeLog entry
    o cygtest.cc: test program
    o cygtest.out: test program output before patch
    o cygtest2.out: test program output after patch

Thanks,
Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
diff -rup cygipc-1.13pre1.orig/msg.c cygipc-1.13pre1/msg.c
--- cygipc-1.13pre1.orig/msg.c	2001-02-10 18:50:01.000000000 -0500
+++ cygipc-1.13pre1/msg.c	2002-11-13 07:44:19.000000000 -0500
@@ -168,8 +168,8 @@ static int findkey (key_t key)
 
 	if (msg_connect() == 0)
 	{
-debug_printf("findkey : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("findkey : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	} 
 	for (id = 0; id <= max_msqid; id++) { 
 		if (msgque[id] == IPC_UNUSED)
@@ -212,8 +212,8 @@ debug_printf("msgsnd : return -EFAULT\n"
 	LBloc = 0 ;
 	if (msg_connect() == 0)
 	{
-debug_printf("msgsnd : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("msgsnd : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	id = (unsigned int) msqid % MSGMNI;
@@ -251,8 +251,8 @@ slept:
 	{
 	 if (msg_connect() == 0)
 	 {
-debug_printf("msgsnd : return -EACCES\n");
- 	  CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("msgsnd : return -ENOSYS\n");
+ 	  CYGWIN_IPCNT_RETURN (-ENOSYS) ;
  	 }
 	}
 
@@ -339,8 +339,8 @@ debug_printf("msgrcv : return -EFAULT\n"
 	LBloc = 0 ;
 	if (msg_connect() == 0)
 	{
-debug_printf("msgrcv : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("msgrcv : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	id = (unsigned int) msqid % MSGMNI;
@@ -373,8 +373,8 @@ debug_printf("msgrcv : return -EIDRM\n")
 		{
 		 if (msg_connect() == 0)
 		 {
-debug_printf("msgrcv : return -EACCES\n");
-	 	  CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("msgrcv : return -ENOSYS\n");
+	 	  CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	 	 }
 		}
 
@@ -522,8 +522,8 @@ static int newque (key_t key, int msgflg
 debug_printf("newque : key=%X msgflg=%X\n",key,msgflg);
 	if (msg_connect() == 0)
 	{
-debug_printf("newque : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("newque : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	for (id = 0; id < MSGMNI; id++)
@@ -590,8 +590,8 @@ debug_printf("msgget : return -EEXIST\n"
 	}
 	if (msg_connect() == 0)
 	{
-debug_printf("newque : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("newque : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	msq = (struct msqid_ds *)
@@ -655,8 +655,8 @@ debug_printf("msgctl : return -EINVAL\n"
 
 	if (msg_connect() == 0)
 	{
-debug_printf("msgctl : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("msgctl : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	id = (unsigned int) msqid % MSGMNI;
diff -rup cygipc-1.13pre1.orig/sem.c cygipc-1.13pre1/sem.c
--- cygipc-1.13pre1.orig/sem.c	2001-11-26 18:41:32.000000000 -0500
+++ cygipc-1.13pre1/sem.c	2002-11-13 07:44:41.000000000 -0500
@@ -326,8 +326,8 @@ debug_printf("semget : return -EINVAL\n"
 
 	if (sem_connect() == 0)
 	{
-debug_printf("semget : return -EACCES\n");
-	    CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("semget : return -ENOSYS\n");
+	    CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	if (key == IPC_PRIVATE)
@@ -385,8 +385,8 @@ debug_printf("do_semop : sma=%p, sops=%p
 		{
 		    if (sem_connect() == 0)
 		    {
-debug_printf("do_semop : return -EACCES\n");
-			CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("do_semop : return -ENOSYS\n");
+			CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 		    }
     	    shareadrsem->current_nb[id].current_nb[sop->sem_num] +=
 				sop->sem_op ;
@@ -402,8 +402,8 @@ debug_printf("do_semop : return -EAGAIN\
 			}
 			if (sem_connect() == 0)
 			{
-debug_printf("do_semop : return -EACCES\n");
-			    CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("do_semop : return -ENOSYS\n");
+			    CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 			}
 	    		shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op;
 			sem_deconnect() ;
@@ -419,8 +419,8 @@ debug_printf("do_semop : return -EACCES\
  
 			if (sem_connect() == 0)
 			{
-debug_printf("do_semop : return -EACCES\n");
-			    CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("do_semop : return -ENOSYS\n");
+			    CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 			}
 			    shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op ;
 			    sem_deconnect() ;
@@ -488,8 +488,8 @@ debug_printf("semctl : return -EINVAL\n"
 
 	if (sem_connect() == 0)
 	{
-debug_printf("semctl : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("semctl : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	switch (cmd) {
@@ -740,8 +740,8 @@ debug_printf("semop : return -EFAULT\n")
 
 	if (sem_connect() == 0)
 	{
-debug_printf("semop : return -EACCES\n");
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("semop : return -ENOSYS\n");
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 	sem_deconnect() ;
 
diff -rup cygipc-1.13pre1.orig/shm.c cygipc-1.13pre1/shm.c
--- cygipc-1.13pre1.orig/shm.c	2001-02-10 18:50:01.000000000 -0500
+++ cygipc-1.13pre1/shm.c	2002-11-13 07:45:50.000000000 -0500
@@ -262,8 +262,8 @@ int shmget (key_t key, int size, int shm
 debug_printf("shmget : key=%p size=%X shmflg=%X\n",key,size,shmflg);	
 	if (shm_connect() == 0)
 	{
-debug_printf("shmget : return -EACCES\n");
-	    CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("shmget : return -ENOSYS\n");
+	    CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	if (size < 0 )
@@ -344,8 +344,8 @@ debug_printf("shmctl : return -EINVAL\n"
 
 	if (shm_connect() == 0)
 	{
-debug_printf("shmctl : return -EACCES\n");	
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("shmctl : return -ENOSYS\n");	
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	id = (unsigned int) shmid % SHMMNI;
@@ -508,11 +508,11 @@ char *shmat (int shmid, char *shmaddr, i
 debug_printf("shmat : shmid=%X shmaddr=%p shmflag=%X\n",shmid,shmaddr,shmflg);	
 	if (shm_connect() == 0)
 	{
-debug_printf("shmat : return -EACCESS\n");	
+debug_printf("shmat : return -ENOSYS\n");	
 #if SHMAT_LINUX
-	 CYGWIN_IPCNT_RETURN (-EACCES) ;
+	 CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 #else
-	 errno=EACCES;
+	 errno=ENOSYS;
 	 return (char *)-1;
 #endif
 	}
@@ -614,8 +614,8 @@ debug_printf("shmdt : shmaddr=%p\n",shma
 
 	if (shm_connect() == 0)
 	{
-debug_printf("shmdt : return -EACCES\n");	
-	    CYGWIN_IPCNT_RETURN (-EACCES) ;
+debug_printf("shmdt : return -ENOSYS\n");	
+	    CYGWIN_IPCNT_RETURN (-ENOSYS) ;
 	}
 
 	for (LId = 0; LId < SHMMNI; LId++)
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/