diff options
author | thompsa <thompsa@FreeBSD.org> | 2009-02-16 02:42:17 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2009-02-16 02:42:17 +0000 |
commit | b0997d1a78f9a42ec76c4b8c54a334622e41518a (patch) | |
tree | 74963cb002aa75101f016a1f559db99f087afd9b /sys/boot/common/module.c | |
parent | c24b826e840d4b278e8a3e1ccb81a197d257f3ae (diff) | |
download | FreeBSD-src-b0997d1a78f9a42ec76c4b8c54a334622e41518a.zip FreeBSD-src-b0997d1a78f9a42ec76c4b8c54a334622e41518a.tar.gz |
Add a helper function for loading geli keys from the loader.
Diffstat (limited to 'sys/boot/common/module.c')
-rw-r--r-- | sys/boot/common/module.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index 6823294..098e39a 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -154,6 +154,44 @@ 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 |