Patch to libcluster to handle upcoming change in system call numbers

John Hughes <[email protected]> Thu, 22 Jan 2009 11:06:43 +0100
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
Starting with kernel 2.6.13 we're going to have to change the syscall 
numbers we use - the ssisys syscall number is now used by one of the 
inotify calls in the base kernel.

To ease the pain of the transition here is a patch to libcluster to make 
it try the new numbers, and if they don't work fall back to the old ones.

This would allow us to install a new kernel, and if necessary fall back 
to an older one without being required to reinstall the system.

(It's actually a patch to CI code, but the relationship between CI and 
OpenSSI is nothing if not incestuous).

(To make this work we would have something in unistd.h like:

/* BEGIN CLUSTER SYSTEM CALLS */
#define __NR_old_ssisys         290	/* conflict with __NR_ioprio_get */
#define __NR_old_rfork          291
#define __NR_old_rexecve        292
#define __NR_old_migrate        293

#define __NR_ssisys             400	/* Real number to be decided later */
#define __NR_rfork              401
#define __NR_rexecve            402
#define __NR_migrate            403

The actual numbers to used must be big enough to last some time.  By 
2.6.23 the base system has got up to 324!)

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
libcluster-syscall-number.patch (text/x-patch, 3.2 KB)
Index: cluster-tools/libcluster/migrate.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/ci/cluster-tools/libcluster/migrate.c,v
retrieving revision 1.3
diff -u -r1.3 migrate.c
--- cluster-tools/libcluster/migrate.c	30 Nov 2004 22:19:09 -0000	1.3
+++ cluster-tools/libcluster/migrate.c	21 Jan 2009 14:33:08 -0000
@@ -24,7 +24,10 @@
 #include <linux/cluster.h>
 #include <errno.h>
 
+extern int _nr_ssisys;
+
 int migrate(clusternode_t node)
 {
-	return syscall(__NR_migrate, node);
+	if (_nr_ssisys == -1 && clusternode_num () == -1) return -1;
+	return syscall(_nr_ssisys + (__NR_migrate - __NR_ssisys), node);
 }
Index: cluster-tools/libcluster/rexecve.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/ci/cluster-tools/libcluster/rexecve.c,v
retrieving revision 1.4
diff -u -r1.4 rexecve.c
--- cluster-tools/libcluster/rexecve.c	30 Nov 2004 22:19:09 -0000	1.4
+++ cluster-tools/libcluster/rexecve.c	21 Jan 2009 15:01:43 -0000
@@ -36,9 +36,12 @@
 #include <linux/unistd.h>
 #include <linux/cluster.h>  
 
+extern int _nr_ssisys;
+
 int rexecve( const char *path, char *const argv[], char* const envp[], clusternode_t node)
 {
-	return syscall(__NR_rexecve, path, argv, envp, node);
+	if (_nr_ssisys == -1 && clusternode_num () == -1) return -1;
+	return syscall(_nr_ssisys + (__NR_rexecve - __NR_ssisys), path, argv, envp, node);
 }
 	
 
Index: cluster-tools/libcluster/rfork.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/ci/cluster-tools/libcluster/rfork.c,v
retrieving revision 1.3
diff -u -r1.3 rfork.c
--- cluster-tools/libcluster/rfork.c	30 Nov 2004 22:19:09 -0000	1.3
+++ cluster-tools/libcluster/rfork.c	21 Jan 2009 14:31:35 -0000
@@ -24,8 +24,10 @@
 #include <linux/cluster.h>
 #include <errno.h>
 
+extern int _nr_ssisys;
 int rfork(clusternode_t node)
 {
-	return syscall(__NR_rfork, node);
+	if (_nr_ssisys == -1 && clusternode_num () == -1) return -1;
+	return syscall(_nr_ssisys + (__NR_rfork - __NR_ssisys), node);
 }
 
Index: cluster-tools/libcluster/ssisys.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/ci/cluster-tools/libcluster/ssisys.c,v
retrieving revision 1.3
diff -u -r1.3 ssisys.c
--- cluster-tools/libcluster/ssisys.c	30 Nov 2004 22:19:09 -0000	1.3
+++ cluster-tools/libcluster/ssisys.c	22 Jan 2009 09:40:05 -0000
@@ -23,7 +23,37 @@
 #include <unistd.h>
 #include <errno.h>
 
+#ifdef __NR_old_ssisys
+
+/* Tortuous messing around to cope with changes to syscall number */
+
+int _nr_ssisys = -1;
+
+long ssisys( char *ts_udata, long ts_udata_len)
+{
+
+	if (_nr_ssisys == -1) {
+		long ret;
+		int call;
+
+		for (call = __NR_ssisys; call >= __NR_old_ssisys; call -= (__NR_ssisys - __NR_old_ssisys)) {
+			if ((ret = syscall (call, ts_udata, ts_udata_len)) != -1 || errno != ENOSYS) {
+				_nr_ssisys = call;
+				break;
+			}
+		}
+		return ret;
+	}
+	else {
+		return syscall(_nr_ssisys, ts_udata, ts_udata_len);
+	}
+}
+#else
+
+int _nr_ssisys = __NR_ssisys;
+
 long ssisys( char *ts_udata, long ts_udata_len)
 {
 	return syscall(__NR_ssisys, ts_udata, ts_udata_len);
 }
+#endif