CHROMIUM: automatically mount tmpfs at /tmp at boot

We have a small pre-startup shell script that mounts /tmp.  This
is relatively expensive for what is 1 syscall.  Since we consider
/tmp to be absolutely required as part of the system, and we always
want it to be tmpfs, move the setup to upstart itself to simplify.

BUG=chromium:1063545
TEST=CQ passes

Change-Id: Ib13881e08fb847ce510f69b4fb44b45daf780ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/upstart/+/2546467
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/init/main.c b/init/main.c
index 22798f8..67bf41c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -224,7 +224,7 @@
 	 * ourselves.
 	 */
 	if (system_mount ("proc", "/proc",
-			  MS_NODEV | MS_NOEXEC | MS_NOSUID) < 0) {
+			  MS_NODEV | MS_NOEXEC | MS_NOSUID, NULL) < 0) {
 		NihError *err;
 
 		err = nih_error_get ();
@@ -234,7 +234,7 @@
 	}
 
 	if (system_mount ("sysfs", "/sys",
-			  MS_NODEV | MS_NOEXEC | MS_NOSUID) < 0) {
+			  MS_NODEV | MS_NOEXEC | MS_NOSUID, NULL) < 0) {
 		NihError *err;
 
 		err = nih_error_get ();
@@ -243,6 +243,16 @@
 		nih_free (err);
 	}
 
+	if (system_mount ("tmpfs", "/tmp", MS_NOSUID | MS_NODEV | MS_NOEXEC,
+			  NULL) < 0) {
+		NihError *err;
+
+		err = nih_error_get ();
+		nih_warn ("%s: %s", _("Unable to mount /tmp filesystem"),
+			  err->message);
+		nih_free (err);
+	}
+
 #ifdef HAVE_SELINUX
 	if (!getenv ("SELINUX_INIT")) {
 		/*
@@ -253,7 +263,7 @@
 		 * selinuxfs.
 		 */
 		if (system_mount ("selinuxfs", "/sys/fs/selinux",
-				  MS_NOEXEC | MS_NOSUID) < 0) {
+				  MS_NOEXEC | MS_NOSUID, NULL) < 0) {
 			NihError *err;
 
 			err = nih_error_get ();
diff --git a/init/system.c b/init/system.c
index 3662180..a0f7a6b 100644
--- a/init/system.c
+++ b/init/system.c
@@ -176,7 +176,8 @@
 int
 system_mount (const char *type,
 	      const char *dir,
-	      unsigned int opts)
+	      unsigned int opts,
+	      const char *options)
 {
 	nih_local char *parent = NULL;
 	char *          ptr;
@@ -205,7 +206,7 @@
 		return 0;
 
 	/* Mount the filesystem */
-	if (mount (type, dir, type, opts, NULL) < 0)
+	if (mount (type, dir, type, opts, options) < 0)
 		nih_return_system_error (-1);
 
 	return 0;
diff --git a/init/system.h b/init/system.h
index a1a9238..e7957c4 100644
--- a/init/system.h
+++ b/init/system.h
@@ -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, unsigned int opts)
+int system_mount         (const char *type, const char *dir, unsigned int opts,
+			  const char *options)
 	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN