James Hunt has proposed merging lp:~jamesodhunt/upstart/bug-980917 into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~jamesodhunt/upstart/bug-980917/+merge/117863

* init/main.c:main(): Create /dev/ptmx and mount /dev and /dev/pts to
  handle scenario where Upstart boots in a non-initramfs environment
  (LP: #980917).
* init/system.c: system_mount(): Add flags parameter (to allow /dev and
  /dev/pts to be mounted without MS_NODEV).
* init/system.h: system_mount(): Updated prototype.

To test this, you will have to modify the boot command line via grub/uBoot. 
Specifically, ensure that:

- *NO* 'initrd=' entry is specified.
- A 'root=' boot entry is specified with the actual device, *NOT* a UUID.
- A 'rootfstype=' boot entry is specified if the FS type is not ext2/3.

For example, on a system with this version of Upstart booted:

$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-3.2.0-18-generic ro root=/dev/sda1 rootfstype=ext4
$ 

-- 
https://code.launchpad.net/~jamesodhunt/upstart/bug-980917/+merge/117863
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~jamesodhunt/upstart/bug-980917 into lp:upstart.
=== modified file 'init/main.c'
--- init/main.c	2011-12-15 16:26:34 +0000
+++ init/main.c	2012-08-02 10:33:43 +0000
@@ -28,6 +28,7 @@
 #include <sys/ioctl.h>
 #include <sys/reboot.h>
 #include <sys/resource.h>
+#include <sys/mount.h>
 
 #include <errno.h>
 #include <stdio.h>
@@ -271,9 +272,10 @@
 
 		/* Mount the /proc and /sys filesystems, which are pretty much
 		 * essential for any Linux system; not to mention used by
-		 * ourselves.
+		 * ourselves. Also mount /dev/pts to allow CONSOLE_LOG
+		 * to function if booted in an initramfs-less environment.
 		 */
-		if (system_mount ("proc", "/proc") < 0) {
+		if (system_mount ("proc", "/proc", (MS_NODEV | MS_NOEXEC | MS_NOSUID)) < 0) {
 			NihError *err;
 
 			err = nih_error_get ();
@@ -282,7 +284,7 @@
 			nih_free (err);
 		}
 
-		if (system_mount ("sysfs", "/sys") < 0) {
+		if (system_mount ("sysfs", "/sys", (MS_NODEV | MS_NOEXEC | MS_NOSUID)) < 0) {
 			NihError *err;
 
 			err = nih_error_get ();
@@ -290,6 +292,30 @@
 				err->message);
 			nih_free (err);
 		}
+		if (system_mount ("devtmpfs", "/dev", (MS_NOEXEC | MS_NOSUID)) < 0) {
+			NihError *err;
+
+			err = nih_error_get ();
+			nih_error ("%s: %s", _("Unable to mount /dev filesystem"),
+				err->message);
+			nih_free (err);
+		}
+
+		/* Required to exist before /dev/pts accessed */
+		if (mknod ("/dev/ptmx", makedev (5, 2), S_IFCHR) < 0 && errno != EEXIST)
+			nih_error ("Unable to create /dev/ptmx");
+
+		if (mkdir ("/dev/pts", 0755) < 0 && errno != EEXIST)
+			nih_error ("%s: %s", _("Cannot create directory"), "/dev/pts");
+
+		if (system_mount ("devpts", "/dev/pts", (MS_NOEXEC | MS_NOSUID)) < 0) {
+			NihError *err;
+
+			err = nih_error_get ();
+			nih_error ("%s: %s", _("Unable to mount /dev/pts filesystem"),
+				err->message);
+			nih_free (err);
+		}
 	} else {
 		nih_log_set_priority (NIH_LOG_DEBUG);
 		nih_debug ("Running with UID %d as PID %d (PPID %d)",

=== modified file 'init/system.c'
--- init/system.c	2011-12-09 14:07:11 +0000
+++ init/system.c	2012-08-02 10:33:43 +0000
@@ -164,9 +164,10 @@
 /**
  * system_mount:
  * @type: filesystem type,
- * @dir: mountpoint.
+ * @dir: mountpoint,
+ * @flags: mount flags.
  *
- * Mount the kernel filesystem @type at @dir, if not already mounted.  This
+ * Mount the kernel filesystem @type at @dir with @flags, if not already mounted.  This
  * is used to ensure that the proc and sysfs filesystems are always
  * available.
  *
@@ -177,7 +178,8 @@
  **/
 int
 system_mount (const char *type,
-	      const char *dir)
+	      const char *dir,
+	      unsigned long flags)
 {
 	nih_local char *parent = NULL;
 	char *          ptr;
@@ -206,8 +208,7 @@
 		return 0;
 
 	/* Mount the filesystem */
-	if (mount ("none", dir, type,
-		   MS_NODEV | MS_NOEXEC | MS_NOSUID, NULL) < 0)
+	if (mount ("none", dir, type, flags, NULL) < 0)
 		nih_return_system_error (-1);
 
 	return 0;

=== modified file 'init/system.h'
--- init/system.h	2011-05-12 20:42:28 +0000
+++ init/system.h	2012-08-02 10:33:43 +0000
@@ -35,7 +35,8 @@
 int system_setup_console (ConsoleType type, int reset)
 	__attribute__ ((warn_unused_result));
 
-int system_mount         (const char *type, const char *dir)
+int system_mount         (const char *type, const char *dir,
+			  unsigned long flags)
 	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to