loader additions

From: Andrew Thompson <thompsa_at_FreeBSD.org>
Date: Fri, 13 Feb 2009 18:24:49 -0800
Hi,


I added a load_geli command to loader(8) as I can never remember the
syntax to do it manually on the rare occasion I need to. Anyone have a
problem if I commit this? bloat?


Andrew


Index: module.c
===================================================================
--- module.c	(revision 188599)
+++ module.c	(working copy)
_at__at_ -154,6 +154,44 _at__at_ command_load(int argc, char *argv[])
     return (error == 0 ? CMD_OK : CMD_ERROR);
 }
 
+COMMAND_SET(load_geli, "load_geli", "load a geli key", command_load_geli);
+
+static int
+command_load_geli(int argc, char *argv[])
+{
+    char	typestr[80];
+    char	*cp;
+    int		ch, num;
+
+    if (argc < 3) {
+	    command_errmsg = "usage is [-n key#] <prov> <file>";
+	    return(CMD_ERROR);
+    }
+
+    num = 0;
+    optind = 1;
+    optreset = 1;
+    while ((ch = getopt(argc, argv, "n:")) != -1) {
+	switch(ch) {
+	case 'n':
+	    num = strtol(optarg, &cp, 0);
+	    if (cp == optarg) {
+		    sprintf(command_errbuf, "bad key index '%s'", optarg);
+		    return(CMD_ERROR);
+	    }
+	    break;
+	case '?':
+	default:
+	    /* getopt has already reported an error */
+	    return(CMD_OK);
+	}
+    }
+    argv += (optind - 1);
+    argc -= (optind - 1);
+    sprintf(typestr, "%s:geli_keyfile%d", argv[1], num);
+    return(file_loadraw(typestr, argv[2]));
+}
+
 COMMAND_SET(unload, "unload", "unload all modules", command_unload);
 
 static int
Received on Sat Feb 14 2009 - 01:24:54 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:42 UTC