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

Petter Reinholdtsen pere at alioth.debian.org
Fri Jul 24 19:07:36 UTC 2009


Author: pere
Date: 2009-07-24 19:07:35 +0000 (Fri, 24 Jul 2009)
New Revision: 1536

Added:
   sysvinit/trunk/debian/patches/50_bootlogd_devsubdir.dpatch
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/patches/00list
Log:
New patch 50_bootlogd_devsubdir to change bootlogd to recursively
search /dev/ for the correct terminal device (Closes: #376406).

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2009-07-24 18:14:21 UTC (rev 1535)
+++ sysvinit/trunk/debian/changelog	2009-07-24 19:07:35 UTC (rev 1536)
@@ -49,6 +49,8 @@
     - Drop patch 95_halt-name now included upstream.
   * Modify shutdown(8) manual page to make it more clear when -c
     work (Closes: #374038).  Based on text proposal from Dan Jacobson.
+  * New patch 50_bootlogd_devsubdir to change bootlogd to recursively
+    search /dev/ for the correct terminal device (Closes: #376406).
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri, 24 Jul 2009 11:26:26 +0200
 

Modified: sysvinit/trunk/debian/patches/00list
===================================================================
--- sysvinit/trunk/debian/patches/00list	2009-07-24 18:14:21 UTC (rev 1535)
+++ sysvinit/trunk/debian/patches/00list	2009-07-24 19:07:35 UTC (rev 1536)
@@ -5,6 +5,7 @@
 14_doc_fsf_addr
 21_ifdown_kfreebsd
 46_pidof_symlinkman
+50_bootlogd_devsubdir
 54_bootlogd_findptyfail
 62_init_freebsdterm
 #68_init_quiet

Added: sysvinit/trunk/debian/patches/50_bootlogd_devsubdir.dpatch
===================================================================
--- sysvinit/trunk/debian/patches/50_bootlogd_devsubdir.dpatch	                        (rev 0)
+++ sysvinit/trunk/debian/patches/50_bootlogd_devsubdir.dpatch	2009-07-24 19:07:35 UTC (rev 1536)
@@ -0,0 +1,117 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_bootlogd_devsubdir.dpatch by Petter Reinholdtsen
+
+Rewrite findtty() in bootlogd to recursively search /dev/ for the
+correct device, to handle terminal devices for example in /dev/pty/.
+
+BTS:    #376406
+Status: not sent upstream yet
+
+ at DPATCH@
+Index: a/src/bootlogd.c
+===================================================================
+--- a/src/bootlogd.c	(revision 1485)
++++ b/src/bootlogd.c	(working copy)
+@@ -98,41 +98,60 @@
+ 
+ /*
+  *	Scan /dev and find the device name.
+- *	Side-effect: directory is changed to /dev
+- *
+- *	FIXME: scan subdirectories for devfs support ?
+  */
+-int findtty(char *res, int rlen, dev_t dev)
++static int findtty(char *res, const char *startdir, int rlen, dev_t dev)
+ {
+ 	DIR		*dir;
+ 	struct dirent	*ent;
+ 	struct stat	st;
+-	int		r = 0;
++	int		r = -1;
++        char *olddir = getcwd(NULL, 0);
+ 
+-	if (chdir("/dev") < 0 || (dir = opendir(".")) == NULL) {
+-		perror("bootlogd: /dev");
++	if (chdir(startdir) < 0 || (dir = opendir(".")) == NULL) {
++		int msglen = strlen(startdir) + 11;
++		char *msg = malloc(msglen);
++		snprintf(msg, msglen, "bootlogd: %s", startdir);
++		perror(msg);
++		free(msg);
++		chdir(olddir);
+ 		return -1;
+ 	}
+ 	while ((ent = readdir(dir)) != NULL) {
+ 		if (lstat(ent->d_name, &st) != 0)
+ 			continue;
++                if (S_ISDIR(st.st_mode)
++                    && 0 != strcmp(".", ent->d_name)
++                    && 0 != strcmp("..", ent->d_name)) {
++			char *path = malloc(rlen);
++			snprintf(path, rlen, "%s/%s", startdir, ent->d_name);
++			r = findtty(res, path, rlen, dev);
++			free(path);
++			if (0 == r) { /* device found, return */
++				closedir(dir);
++				chdir(olddir);
++				return 0;
++			}
++			continue;
++                }
+ 		if (!S_ISCHR(st.st_mode))
+ 			continue;
+ 		if (st.st_rdev == dev) {
+-			break;
++			if (strlen(ent->d_name) + strlen(startdir) + 1 >= rlen) {
++				fprintf(stderr, "bootlogd: console device name too long\n");
++				closedir(dir);
++				chdir(olddir);
++				return -1;
++			} else {
++				snprintf(res, rlen, "%s/%s", startdir, ent->d_name);
++				closedir(dir);
++				chdir(olddir);
++				return 0;
++			}
+ 		}
+ 	}
+-	if (ent == NULL) {
+-		fprintf(stderr, "bootlogd: cannot find console device "
+-			"%d:%d in /dev\n", major(dev), minor(dev));
+-		r = -1;
+-	} else if (strlen(ent->d_name) + 5 >= rlen) {
+-		fprintf(stderr, "bootlogd: console device name too long\n");
+-		r = -1;
+-	} else
+-		snprintf(res, rlen, "/dev/%s", ent->d_name);
+ 	closedir(dir);
+ 
++	chdir(olddir);
+ 	return r;
+ }
+ 
+@@ -227,12 +246,21 @@
+ 		/*
+ 		 *	Old kernel, can find real device easily.
+ 		 */
+-		return findtty(res, rlen, st.st_rdev);
++		int r = findtty(res, "/dev", rlen, st.st_rdev);
++		if (0 != r)
++			fprintf(stderr, "bootlogd: cannot find console device "
++				"%d:%d under /dev\n", major(st.st_rdev), minor(st.st_rdev));
++		return r;
+ 	}
+ 
+ #ifdef TIOCGDEV
+-	if (ioctl(0, TIOCGDEV, &kdev) == 0)
+-		return findtty(res, rlen, (dev_t)kdev);
++	if (ioctl(0, TIOCGDEV, &kdev) == 0) {
++		int r = findtty(res, "/dev", rlen, (dev_t)kdev);
++		if (0 != r)
++			fprintf(stderr, "bootlogd: cannot find console device "
++				"%d:%d under /dev\n", major(kdev), minor(kdev));
++		return r;
++	}
+ 	if (errno != ENOIOCTLCMD) return -1;
+ #endif
+ 


Property changes on: sysvinit/trunk/debian/patches/50_bootlogd_devsubdir.dpatch
___________________________________________________________________
Added: svn:executable
   + *




More information about the Pkg-sysvinit-commits mailing list