[Pkg-sysvinit-commits] r1472 - in sysvinit/trunk/debian: . startpar startpar/patches

Kel Modderman kelmo-guest at alioth.debian.org
Sat Jul 18 15:42:53 UTC 2009


Author: kelmo-guest
Date: 2009-07-18 15:42:52 +0000 (Sat, 18 Jul 2009)
New Revision: 1472

Added:
   sysvinit/trunk/debian/startpar/patches/
   sysvinit/trunk/debian/startpar/patches/00_not_suse.patch
   sysvinit/trunk/debian/startpar/patches/01_dev_pts_workaround.patch
   sysvinit/trunk/debian/startpar/patches/02_posix_fadvise_kfreebsd.patch
   sysvinit/trunk/debian/startpar/patches/03_o_direct_undef.patch
   sysvinit/trunk/debian/startpar/patches/series
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/startpar/Makefile
   sysvinit/trunk/debian/startpar/makeboot.c
   sysvinit/trunk/debian/startpar/makeboot.h
   sysvinit/trunk/debian/startpar/startpar.c
Log:
Update startpar to version 0.53.1 upstream. Add Debian quilt patch series
to ./debian/startpar/patches, while they wait for inclusion upstream.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2009-07-18 15:32:50 UTC (rev 1471)
+++ sysvinit/trunk/debian/changelog	2009-07-18 15:42:52 UTC (rev 1472)
@@ -33,8 +33,10 @@
   [ Kel Modderman ]
   * Remove debian/startpar/README, it contains outdated information about
     the origin of startpar upstream.
+  * Update startpar to version 0.53.1 upstream. Add Debian quilt patch series
+    to ./debian/startpar/patches, while they wait for inclusion upstream.
 
- -- Kel Modderman <kel at otaku42.de>  Sun, 19 Jul 2009 01:31:39 +1000
+ -- Kel Modderman <kel at otaku42.de>  Sun, 19 Jul 2009 01:42:21 +1000
 
 sysvinit (2.86.ds1-65) unstable; urgency=low
 

Modified: sysvinit/trunk/debian/startpar/Makefile
===================================================================
--- sysvinit/trunk/debian/startpar/Makefile	2009-07-18 15:32:50 UTC (rev 1471)
+++ sysvinit/trunk/debian/startpar/Makefile	2009-07-18 15:42:52 UTC (rev 1472)
@@ -1,4 +1,4 @@
-VERSION = 0.52
+VERSION = 0.53.1
 ISSUSE	= -DNOTSUSE
 
 INSTALL		= install -m 755
@@ -15,17 +15,17 @@
 
 CC = gcc
 OPTFLAGS = -O2 -g -Wall -W
-CFLAGS = $(OPTFLAGS) -D_GNU_SOURCE $(ISSUSE)
+CFLAGS = $(OPTFLAGS) -D_GNU_SOURCE
 
 ifeq ($(MAKECMDGOALS),makeboot)
 CFLAGS += -DTEST
 endif
 
 .c.o:
-	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c $<
+	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(ISSUSE) -c $<
 
 startpar: $(OBJS)
-	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -o $@ $(OBJS)
+	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(ISSUSE) -o $@ $(OBJS)
 
 makeboot: makeboot.c
 

Modified: sysvinit/trunk/debian/startpar/makeboot.c
===================================================================
--- sysvinit/trunk/debian/startpar/makeboot.c	2009-07-18 15:32:50 UTC (rev 1471)
+++ sysvinit/trunk/debian/startpar/makeboot.c	2009-07-18 15:42:52 UTC (rev 1472)
@@ -52,18 +52,19 @@
  */
 static struct makenode *add_target(const char *name)
 {
-	struct makenode *node;
+	struct makenode *__restrict node;
 	struct makenode *prev, *t;
 
 	node = lookup_target(name);
 	if (node)
 		return node;
-	node = xcalloc(1, sizeof(*node));
-	node->name = strdup(name);
-	if (! node->name) {
+	if (posix_memalign((void*)&node, sizeof(void*), alignof(struct makenode)+strsize(name)) < 0) {
 		fprintf(stderr, "Can't malloc: %s\n", strerror(errno));
 		exit(1);
 	}
+	memset(node, 0, alignof(struct makenode)+strsize(name));
+	node->name = ((char*)node)+alignof(struct makenode);
+	strcpy(node->name, name);
 
 	/* append to the list in alphabetical order */
 	prev = NULL;
@@ -107,6 +108,7 @@
 /*
  * check whether the given target would create an infinte loop
  */
+static int loop;
 static int check_loop(struct makenode *dep, struct makenode *src)
 {
 	struct makelist *s;
@@ -115,6 +117,8 @@
 			fprintf(stderr, "loop exists %s in %s!\n", dep->name, src->name);
 			return 1;
 		}
+		if (loop++ > 999)
+			return 1;
 		if (check_loop(s->node, src))
 			return 1;
 	}
@@ -129,6 +133,7 @@
 	struct makenode *dep;
 
 	dep = add_target(dst);
+	loop = 0;
 	if (check_loop(dep, node))
 		return;
 	dep->select = new_list(node, dep->select);
@@ -289,8 +294,11 @@
 	if (ndirs >= 0) {
 		for (i = 0; i < ndirs; i++) {
 			t = lookup_target(dirlist[i]->d_name + 3);
-			if (t)
+			if (t) {
 				t->status = 1;
+				if (asprintf(&t->arg0, "%s/%s", path, dirlist[i]->d_name) < 0)
+					t->arg0 = (char*)0;
+			}
 			free(dirlist[i]);
 		}
 		free(dirlist);
@@ -528,8 +536,6 @@
 		goto out;
 	}
 
-	nodevec = xcalloc(1, sizeof(*nodevec));
-
 	snprintf(makefile, sizeof(makefile), "depend.%s", argv[1]);
 	parse_makefile(makefile);
 
@@ -538,7 +544,7 @@
 	check_run_files(argv[1], argv[2], argv[3]);
 out:
 	while ((nodevec = pickup_task())) {
-		fprintf(stdout, "%s\n", nodevec->name);
+		fprintf(stdout, "%s (%s)\n", nodevec->name, nodevec->arg0);
 		finish_task(nodevec);
 	}
 

Modified: sysvinit/trunk/debian/startpar/makeboot.h
===================================================================
--- sysvinit/trunk/debian/startpar/makeboot.h	2009-07-18 15:32:50 UTC (rev 1471)
+++ sysvinit/trunk/debian/startpar/makeboot.h	2009-07-18 15:42:52 UTC (rev 1472)
@@ -8,6 +8,7 @@
 /* target nodes */
 struct makenode {
 	char *name;
+	char *arg0;
 	int num_deps;
 	struct makelist *depend;
 	int num_sels;
@@ -33,3 +34,6 @@
 extern void finish_task(struct makenode *n);
 extern void *xcalloc(size_t nmemb, size_t size);
 extern void print_run_result(int *resvec, struct makenode **nodevec, const char *action);
+
+#define alignof(type)		((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1))
+#define strsize(string)		((strlen(string)+1)*sizeof(char))

Added: sysvinit/trunk/debian/startpar/patches/00_not_suse.patch
===================================================================
--- sysvinit/trunk/debian/startpar/patches/00_not_suse.patch	                        (rev 0)
+++ sysvinit/trunk/debian/startpar/patches/00_not_suse.patch	2009-07-18 15:42:52 UTC (rev 1472)
@@ -0,0 +1,13 @@
+Purpose: Disable the SUSE flag.
+Fixes:   None, made as part of Debian porting.
+Status:  Debian specific, showed to upstream.
+---
+--- a/Makefile
++++ b/Makefile
+@@ -1,5 +1,5 @@
+ VERSION = 0.53.1
+-ISSUSE	= -DSUSE
++ISSUSE	= -DNOTSUSE
+ 
+ INSTALL		= install -m 755
+ INSTALL_DATA	= install -m 644

Added: sysvinit/trunk/debian/startpar/patches/01_dev_pts_workaround.patch
===================================================================
--- sysvinit/trunk/debian/startpar/patches/01_dev_pts_workaround.patch	                        (rev 0)
+++ sysvinit/trunk/debian/startpar/patches/01_dev_pts_workaround.patch	2009-07-18 15:42:52 UTC (rev 1472)
@@ -0,0 +1,127 @@
+Purpose: Workaround case where /dev/pts is not mounted initially, but
+         is mounted during the lifetime of startpar process. Scripts
+	 must be treated as interactive until /dev/pts is mounted and
+	 getpt() is able open the pseudo-terminal master and return
+	 its file descriptor.
+
+	 Reimpliment __posix_openpt() from glibc, as it does not retry
+	 to open the pseudo-terminal master if it failed to do so earlier
+	 in the process lifetime.
+
+	 On SuSe /dev/pts is always mounted in very early boot and this
+	 hack is never needed.
+Fixes:   #457896
+Status:  Submitted to upstream.
+---
+--- a/startpar.c
++++ b/startpar.c
+@@ -33,6 +33,9 @@
+ #include <sys/un.h>
+ #include <sys/sysinfo.h>
+ #include <sys/stat.h>
++#ifndef SUSE
++#include <sys/vfs.h>
++#endif
+ #include <time.h>
+ #include <fcntl.h>
+ #include <errno.h>
+@@ -295,6 +298,70 @@ static inline int checkpar(const int par
+ 
+ #define SOCK_PATH "/dev/shm/preload_sock"
+ 
++#ifdef SUSE
++static int checkdevpts(void)
++{
++  /* /dev/pts is always mounted */
++  return 1;
++}
++#else
++/*
++ * Based on __posix_openpt() from glibc.  Reimplemented here to work
++ * around the problem with getpt() failing for the entire process life
++ * time if /dev/pts/ is missing the first time it is called but
++ * mounted while the process is running.  BSD style pts is not
++ * supported, but might be copied from glibc too if there is need.
++ */
++#define DEVFS_SUPER_MAGIC       0x1373
++#define DEVPTS_SUPER_MAGIC      0x1cd1
++
++static int startpar_getpt(void) {
++  int fd = open("/dev/ptmx", O_RDWR|O_NOCTTY);
++
++  if (fd != -1)
++    {
++      struct statfs fsbuf;
++
++      /* Check that the /dev/pts filesystem is mounted
++        or if /dev is a devfs filesystem (this implies /dev/pts).  */
++      if ((statfs ("/dev/pts", &fsbuf) == 0
++             && fsbuf.f_type == DEVPTS_SUPER_MAGIC)
++         || (statfs ("/dev", &fsbuf) == 0
++             && fsbuf.f_type == DEVFS_SUPER_MAGIC))
++        {
++          /* Everything is ok, switch to the getpt() in libc.  */
++          return fd;
++        }
++
++      /* If /dev/pts is not mounted then the UNIX98 pseudo terminals
++        are not usable.  */
++      close (fd);
++    }
++
++  return -1;
++}
++
++static int checkdevpts(void)
++{
++  int ptsfd = startpar_getpt();
++
++  if (ptsfd == -1)
++    {
++      return 0;
++    }
++  else if (ptsname(ptsfd) == 0 || grantpt(ptsfd) || unlockpt(ptsfd))
++    {
++      close(ptsfd);
++      return 0;
++    }
++  else
++    {
++      close(ptsfd);
++      return 1;
++    }
++}
++#endif
++
+ void run(struct prg *p)
+ {
+   char *m = 0;
+@@ -853,6 +920,7 @@ int main(int argc, char **argv)
+       pid_t pid = 0;
+       int r = 0, s;
+       long diff;
++      int devpts = 0;
+ 
+       gettimeofday(&now, 0);
+       FD_ZERO(&rset);
+@@ -874,6 +942,8 @@ int main(int argc, char **argv)
+       for (s = 0; s < par; s++)			/* never leave this with break!! */
+ 	{
+ 	account:				/* for the new process below */
++	  if (!devpts)
++	    devpts = checkdevpts();
+ 	  p = prgs + s;
+ 	  if (p == interactive_task)
+ 	    continue;				/* don't count this here */
+@@ -906,6 +976,11 @@ int main(int argc, char **argv)
+ 		  p->num = num++;
+ 		  if (interactive_task)
+ 		    continue;			/* don't start this here */
++		  if (!devpts)
++		    {
++		      interactive_task = p;	/* no /dev/pts, treat as interactive */
++		      continue;
++		    }
+ 		  run(p);
+ 		  if (p->pid == 0)
+ 		    {

Added: sysvinit/trunk/debian/startpar/patches/02_posix_fadvise_kfreebsd.patch
===================================================================
--- sysvinit/trunk/debian/startpar/patches/02_posix_fadvise_kfreebsd.patch	                        (rev 0)
+++ sysvinit/trunk/debian/startpar/patches/02_posix_fadvise_kfreebsd.patch	2009-07-18 15:42:52 UTC (rev 1472)
@@ -0,0 +1,18 @@
+Purpose: posix_fadvise() is not present in Debian/kfreebsd. Provide
+         compatibility define for platforms which do not support it
+	 and make it a no-op.
+Fixes:   #534337
+Status:  Submitted upstream.
+---
+--- a/makeboot.c
++++ b/makeboot.c
+@@ -17,6 +17,9 @@
+ # include <sys/types.h>
+ # include <sys/stat.h>
+ # include <fcntl.h>
++#ifndef POSIX_FADV_SEQUENTIAL
++#define posix_fadvise(fd, off, len, adv)	(-1)
++#endif
+ static int o_flags = O_RDONLY;
+ #endif
+ 

Added: sysvinit/trunk/debian/startpar/patches/03_o_direct_undef.patch
===================================================================
--- sysvinit/trunk/debian/startpar/patches/03_o_direct_undef.patch	                        (rev 0)
+++ sysvinit/trunk/debian/startpar/patches/03_o_direct_undef.patch	2009-07-18 15:42:52 UTC (rev 1472)
@@ -0,0 +1,16 @@
+Purpose: O_DIRECT is undefined on Debian/hurd.
+Fixes:   #534471
+Status:  Submitted upstream.
+---
+--- a/makeboot.c
++++ b/makeboot.c
+@@ -20,6 +20,9 @@
+ #ifndef POSIX_FADV_SEQUENTIAL
+ #define posix_fadvise(fd, off, len, adv)	(-1)
+ #endif
++#ifndef O_DIRECT
++#define O_DIRECT 0
++#endif
+ static int o_flags = O_RDONLY;
+ #endif
+ 

Added: sysvinit/trunk/debian/startpar/patches/series
===================================================================
--- sysvinit/trunk/debian/startpar/patches/series	                        (rev 0)
+++ sysvinit/trunk/debian/startpar/patches/series	2009-07-18 15:42:52 UTC (rev 1472)
@@ -0,0 +1,4 @@
+00_not_suse.patch
+01_dev_pts_workaround.patch
+02_posix_fadvise_kfreebsd.patch 
+03_o_direct_undef.patch 

Modified: sysvinit/trunk/debian/startpar/startpar.c
===================================================================
--- sysvinit/trunk/debian/startpar/startpar.c	2009-07-18 15:32:50 UTC (rev 1471)
+++ sysvinit/trunk/debian/startpar/startpar.c	2009-07-18 15:42:52 UTC (rev 1472)
@@ -29,9 +29,13 @@
 #include <sys/select.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 #include <sys/sysinfo.h>
 #include <sys/stat.h>
+#ifndef SUSE
 #include <sys/vfs.h>
+#endif
 #include <time.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -65,9 +69,12 @@
 static char *run_mode = NULL;
 static struct makenode **nodevec;
 
+static enum { Unknown, Preload, NoPreload } ispreload = Unknown;
+
 #define PBUF_SIZE	8192
 struct prg {
-  char *name;
+  const char *name;
+  const char *arg0;
   int num;
   int fd;
   pid_t pid;
@@ -82,6 +89,19 @@
 static int pidpipe[2];
 static double iorate = 800.0;
 
+void sighandler_nopreload(int x)
+{
+    (void)x;
+    ispreload = NoPreload;
+}
+
+
+void sighandler_preload(int x)
+{
+    (void)x;
+    ispreload = Preload;
+}
+
 void *xcalloc(size_t nmemb, size_t size)
 {
   void *r;
@@ -151,9 +171,9 @@
   close(pidpipe[1]);
 }
 
-void callsplash(int n, char *path, char *action)
+void callsplash(int n, const char *path, char *action)
 {
-  char *p;
+  const char *p;
   char sbuf[32];
   char tbuf[256];
   pid_t pid;
@@ -249,11 +269,15 @@
   if (read_proc(&prcs_run, &prcs_blked))
     return par;
 
+  /* if we have preload running, we expect I/O not to be a problem */
+  if (ispreload != NoPreload)
+    prcs_blked = 0;
+
   newpar  = (par*numcpu) - prcs_run + 1; 	/* +1 for startpar its self */
   newpar -= (int)(((double)prcs_blked)*iorate);	/* I/O load reduction */
 
 #if DEBUG
-  fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%u) %ld\n", par, newpar, prcs_run, time(0));
+  fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%lu) %ld\n", par, newpar, prcs_run, time(0));
   dump_status();
 #endif
   if (newpar <= 0)
@@ -272,6 +296,15 @@
   return checksystem(par, start, false);
 }
 
+#define SOCK_PATH "/dev/shm/preload_sock"
+
+#ifdef SUSE
+static int checkdevpts(void)
+{
+  /* /dev/pts is always mounted */
+  return 1;
+}
+#else
 /*
  * Based on __posix_openpt() from glibc.  Reimplemented here to work
  * around the problem with getpt() failing for the entire process life
@@ -327,10 +360,12 @@
       return 1;
     }
 }
+#endif
 
 void run(struct prg *p)
 {
   char *m = 0;
+  pid_t parent = getpid();
 
   p->len = 0;
   p->pid = (pid_t)0;
@@ -398,21 +433,71 @@
 
   closeall();
 
+  if (!strcmp(arg, "start")) 
+    { 
+      int s, t, len;
+      pid_t child;
+      struct sockaddr_un remote;
+      char str[100];
+
+      s = socket(AF_UNIX, SOCK_STREAM, 0);
+      if (s != -1) 
+	{
+	  memset(&remote, 0, sizeof(struct sockaddr_un));
+	  remote.sun_family = AF_UNIX;
+	  strcpy(remote.sun_path, SOCK_PATH);
+	  len = strlen(remote.sun_path) + sizeof(remote.sun_family);
+
+	  t = connect(s, (struct sockaddr *)&remote, len);
+	  if (t != -1) 
+	    {
+	      if (ispreload != Preload)
+		kill(parent, SIGUSR1);
+	      send(s, p->name, strlen(p->name), 0);
+	      recv(s, str, 100, 0);
+	    } 
+	  else if ( ispreload == Unknown) 
+	    {
+	      /*
+	       * if we connected to preload once, we know it ran.
+	       * In case we can't connect to it later, it means it did
+	       * its job and we can guess I/O is no longer a problem. 
+	       */
+	      kill(parent, SIGUSR2);
+	    }
+	  close(s);
+	  /*
+	   * if we use preload, we fork again to make bootcharts easier to read.
+	   * The reason is that the name of the init script will otherwise be used
+	   * when in reality the above code waited for preload. If we fork away
+	   * before the exec, the waiting code will be folded into startpar
+	   */
+	  child = fork();
+	  if (child) {
+		int status;
+		int ret = waitpid(child, &status, 0);
+		if (ret == -1)
+			perror("waitpid");
+		exit(WEXITSTATUS(status));
+	  }
+	}
+    }
+
   if (run_mode)
     {
       char path[128];
       snprintf(path, sizeof(path), "/etc/init.d/%s", p->name);
-      execlp(path, path, arg, (char *)0);
+      execlp(path, p->arg0, arg, (char *)0);
     }
   else if (arg)
-    execlp(p->name, p->name, arg, (char *)0);
+    execlp(p->name, p->arg0, arg, (char *)0);
   else
-    execlp(p->name, p->name, (char *)0);
+    execlp(p->name, p->arg0, (char *)0);
   perror(p->name);
   _exit(1);
 }
 
-int run_single(char *prg, int spl)
+int run_single(const char *prg, const char *arg0, int spl)
 {
   pid_t pid;
   int r;
@@ -439,12 +524,12 @@
 	{
 	  char path[128];
 	  snprintf(path, sizeof(path), "/etc/init.d/%s", prg);
-	  execlp(path, path, arg, (char *)0);
+	  execlp(path, arg0 ? arg0 : path, arg, (char *)0);
 	}
       else if (arg)
-	execlp(prg, prg, arg, (char *)0);
+	execlp(prg, arg0 ? arg0 : prg, arg, (char *)0);
       else
-	execlp(prg, prg, (char *)0);
+	execlp(prg, arg0 ? arg0 : prg, (char *)0);
       perror(prg);
       _exit(1);
     }
@@ -614,6 +699,9 @@
   char *run_level = getenv("RUNLEVEL");
   char *splashopt = 0;
 
+  (void)signal(SIGUSR1, sighandler_preload);
+  (void)signal(SIGUSR2, sighandler_nopreload);
+
   (void)signal(SIGCHLD, SIG_DFL);
   numcpu = sysconf(_SC_NPROCESSORS_ONLN);
   myname = argv[0];
@@ -767,11 +855,11 @@
 	{
 	  if ((*nodevec = pickup_task()))
 	  {
-	    *resvec = run_single((*nodevec)->name, calcsplash(0, 1, splashopt));
+	    *resvec = run_single((*nodevec)->name, (*nodevec)->arg0, calcsplash(0, 1, splashopt));
 	    finish_task(*nodevec);
 	  }
       } else
-	*resvec = run_single(*argv, calcsplash(0, 1, splashopt));
+	*resvec = run_single(*argv, *argv, calcsplash(0, 1, splashopt));
       goto finished;
     }
 
@@ -878,15 +966,21 @@
 		      if (nodevec[num]->interactive)
 			interactive_task = p;
 		      p->name = nodevec[num]->name;
+		      p->arg0 = nodevec[num]->arg0 ? nodevec[num]->arg0 : nodevec[num]->name;
 		    }
-		  else
+		  else {
 		    p->name = *argv++;
+		    p->arg0 = p->name;
+		  }
 		  p->splashadd = calcsplash(num, argc, splashopt);
 		  p->num = num++;
-		  if (!devpts)			/* no /dev/pts, treat as interactive */
-		    interactive_task = p;
 		  if (interactive_task)
 		    continue;			/* don't start this here */
+		  if (!devpts)
+		    {
+		      interactive_task = p;	/* no /dev/pts, treat as interactive */
+		      continue;
+		    }
 		  run(p);
 		  if (p->pid == 0)
 		    {
@@ -917,7 +1011,7 @@
 	  if (active == 0)
 	    {
 	      p = interactive_task;
-	      resvec[p->num] = run_single(p->name, p->splashadd);
+	      resvec[p->num] = run_single(p->name, p->arg0, p->splashadd);
 	      if (run_mode)
 		finish_task(nodevec[p->num]);
 	      p->pid = 0;




More information about the Pkg-sysvinit-commits mailing list