svn commit: r308535 - head/sys/boot/common

Stephen J. Kiernan stevek at FreeBSD.org
Fri Nov 11 17:41:18 UTC 2016


Author: stevek
Date: Fri Nov 11 17:41:17 2016
New Revision: 308535
URL: https://svnweb.freebsd.org/changeset/base/308535

Log:
  Add support for LOADER_RC setting in the pkgfs manifest (defaults to
  /loader.rc) to specify a Forth file to read from the pkgfs tarball and
  process by Ficl.
  
  This allows for the tarball to do runtime things like load a
  platform-specific FDT blob, among other things.
  
  Reviewed by:	imp
  Approved by:	sjg (mentor)
  MFC after:	2 weeks
  Sponsored by:	Juniper Networks, Inc.
  Differential Revision:	https://reviews.freebsd.org/D8494

Modified:
  head/sys/boot/common/install.c

Modified: head/sys/boot/common/install.c
==============================================================================
--- head/sys/boot/common/install.c	Fri Nov 11 16:59:26 2016	(r308534)
+++ head/sys/boot/common/install.c	Fri Nov 11 17:41:17 2016	(r308535)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 
 #include "bootstrap.h"
 
-extern struct in_addr rootip;
 extern struct in_addr servip;
 
 extern int pkgfs_init(const char *, struct fs_ops *);
@@ -50,6 +49,7 @@ COMMAND_SET(install, "install", "install
 static char *inst_kernel;
 static char **inst_modules;
 static char *inst_rootfs;
+static char *inst_loader_rc;
 
 static int
 setpath(char **what, char *val)
@@ -146,6 +146,8 @@ read_metatags(int fd)
 			error = setmultipath(&inst_modules, val);
 		else if (strcmp(tag, "ROOTFS") == 0)
 			error = setpath(&inst_rootfs, val);
+		else if (strcmp(tag, "LOADER_RC") == 0)
+			error = setpath(&inst_loader_rc, val);
 
 		tag = p;
 	}
@@ -173,6 +175,10 @@ cleanup(void)
 		free(inst_rootfs);
 		inst_rootfs = NULL;
 	}
+	if (inst_loader_rc != NULL) {
+		free(inst_loader_rc);
+		inst_loader_rc = NULL;
+	}
 	pkgfs_cleanup();
 }
 
@@ -275,6 +281,16 @@ install(char *pkgname)
 		goto fail;
 	}
 
+	/* If there is a loader.rc in the package, execute it */
+	s = (inst_loader_rc == NULL) ? "/loader.rc" : inst_loader_rc;
+	fd = open(s, O_RDONLY);
+	if (fd != -1) {
+		close(fd);
+		error = include(s);
+		if (error == CMD_ERROR)
+			goto fail;
+	}
+
 	i = 0;
 	while (inst_modules != NULL && inst_modules[i] != NULL) {
 		error = mod_loadkld(inst_modules[i], 0, NULL);


More information about the svn-src-all mailing list