Skip to content

Commit

Permalink
OS-7698 Add mkzpool -e for creating encrypted zpools (#885)
Browse files Browse the repository at this point in the history
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Pedro Palazón Candel <pedro@joyent.com>
Reviewed by: Brian Bennett <brian.bennett@joyent.com>
Approved by: Brian Bennett <brian.bennett@joyent.com>
  • Loading branch information
jasonbking committed Feb 26, 2020
1 parent dde2a7e commit da5a750
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 45 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -64,7 +64,6 @@ man/man/man1m/disklayout.1m
man/man/man1m/dsadm.1m
man/man/man1m/fwadm.1m
man/man/man1m/imgadm.1m
man/man/man1m/mkzpool.1m
man/man/man1m/nictagadm.1m
man/man/man1m/sysevent.1m
man/man/man1m/sysinfo.1m
Expand Down
41 changes: 41 additions & 0 deletions man/man/man1m/mkzpool.1m
@@ -0,0 +1,41 @@
.Dd February 26, 2020
.Dt MKZPOOL 1M
.Os
.Sh NAME
.Nm mkzpool
.Nd Create a zpool from a JSON specification
.Sh SYNOPSIS
.Cm mkzpool
.Op Fl ef
.Ar pool
.Ar file.json
.Sh DESCRIPTION
.Nm
functions as a wrapper around
.Xr zpool 1M .
It creates a pool named
.Ar pool
from a JSON specification in the file named
.Ar file.json
instead of command\-line arguments.
The input JSON must satisfy the schema described in the
.Xr disklayout 1M
output specification.
.Ss OPTIONS
.Bl -tag -width Fl
.It Fl e
Encrypt.
Create the zpool as an encrypted zpool.
A PIV token must be present on the system for the command to succeed.
.It Fl f
Force.
This flag has the same meaning as the same flag when passed to
.Cm zpool create .
.El
.Sh WARNINGS
Use of this command is subject to the same caveats and warnings as the
.Xr zpool 1M
create command.
.Sh "SEE ALSO"
.Xr disklayout 1M ,
.Xr zpool 1M
29 changes: 0 additions & 29 deletions man/src/mkzpool.1m.md

This file was deleted.

12 changes: 8 additions & 4 deletions src/mkzpool.js
@@ -1,7 +1,7 @@
#! /usr/node/bin/node

/*
* Copyright 2012 Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc. All rights reserved.
*/

var fs = require('fs');
Expand All @@ -27,11 +27,15 @@ var config;
var pool;

var option;
var opt_e = false;
var opt_f = false;
var parser = new getopt.BasicParser('f', process.argv);
var parser = new getopt.BasicParser('ef', process.argv);

while ((option = parser.getopt()) !== undefined && !option.error) {
switch (option.option) {
switch (option.option) {
case 'e':
opt_e = true;
break;
case 'f':
opt_f = true;
break;
Expand All @@ -51,7 +55,7 @@ pool = process.argv[parser.optind()];
json = fs.readFileSync(process.argv[parser.optind() + 1], 'utf8');
config = JSON.parse(json);

zfs.zpool.create(pool, config, opt_f, function (err) {
zfs.zpool.create(pool, config, opt_f, opt_e, function (err) {
if (err) {
fatal('pool creation failed: ' + err);
}
Expand Down
36 changes: 25 additions & 11 deletions src/node_modules/zfs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da5a750

Please sign in to comment.