Skip to content

Commit 64d7b6c

Browse files
impbehlendorf
authored andcommitted
Override default SPA config location via environment
When using zdb with non-default SPA config file it is not convenient to add -U <non-default-config-file-path> all the time. This commit introduces support for setting/overriding SPA config location via environment variable 'SPA_CONFIG_PATH'. If -U flag is specified in the command line it will override any other value as usual. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1545
1 parent 20c17b9 commit 64d7b6c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/zdb/zdb.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,12 +3059,22 @@ main(int argc, char **argv)
30593059
nvlist_t *policy = NULL;
30603060
uint64_t max_txg = UINT64_MAX;
30613061
int rewind = ZPOOL_NEVER_REWIND;
3062+
char *spa_config_path_env;
30623063

30633064
(void) setrlimit(RLIMIT_NOFILE, &rl);
30643065
(void) enable_extended_FILE_stdio(-1, -1);
30653066

30663067
dprintf_setup(&argc, argv);
30673068

3069+
/*
3070+
* If there is an environment variable SPA_CONFIG_PATH it overrides
3071+
* default spa_config_path setting. If -U flag is specified it will
3072+
* override this environment variable settings once again.
3073+
*/
3074+
spa_config_path_env = getenv("SPA_CONFIG_PATH");
3075+
if (spa_config_path_env != NULL)
3076+
spa_config_path = spa_config_path_env;
3077+
30683078
while ((c = getopt(argc, argv, "bcdhilmM:suCDRSAFLXevp:t:U:P")) != -1) {
30693079
switch (c) {
30703080
case 'b':

0 commit comments

Comments
 (0)