View | Details | Raw Unified | Return to bug 244640 | Differences between
and this patch

Collapse All | Expand All

(-)stand/lua/cli.lua (-4 / +1 lines)
Lines 127-136 Link Here
127
127
128
cli['read-conf'] = function(...)
128
cli['read-conf'] = function(...)
129
	local _, argv = cli.arguments(...)
129
	local _, argv = cli.arguments(...)
130
	-- Don't trigger a reload of previously loaded loader_conf_files, in
130
	config.readConf(assert(core.popFrontTable(argv)))
131
	-- case this config file doesn't set it.
132
	loader.setenv("loader_conf_files", "")
133
	config.readConfFiles(assert(core.popFrontTable(argv)), {})
134
end
131
end
135
132
136
cli['reload-conf'] = function(...)
133
cli['reload-conf'] = function(...)
(-)stand/lua/config.lua (-34 / +41 lines)
Lines 460-496 Link Here
460
	return status
460
	return status
461
end
461
end
462
462
463
function config.readConfFiles(files, loaded_files)
463
function config.readConf(file, loaded_files)
464
	if files ~= nil then
464
	if loaded_files == nil then
465
		-- The caller may not have passed in loader_conf_files; we could
465
		loaded_files = {}
466
		-- have instead gotten some other string of files.  We don't
466
	end
467
		-- want to trigger any redundant re-read/loads based on this.
468
		local prefiles = loader.getenv("loader_conf_files")
469
		for name in files:gmatch("([%w%p]+)%s*") do
470
			if loaded_files[name] ~= nil then
471
				goto continue
472
			end
473
467
474
			print("Loading " .. name)
468
	if loaded_files[file] ~= nil then
475
			-- These may or may not exist, and that's ok. Do a
469
		return
476
			-- silent parse so that we complain on parse errors but
470
	end
477
			-- not for them simply not existing.
478
			if not config.processFile(name, true) then
479
				print(MSG_FAILPARSECFG:format(name))
480
			end
481
471
482
			loaded_files[name] = true
472
	print("Loading " .. file)
483
			local newfiles = loader.getenv("loader_conf_files")
473
484
			if prefiles ~= newfiles then
474
	-- Make sure that we can detect if "loader_conf_files" is set by
485
				-- Recurse; process the new files immediately.
475
	-- file by ensuring that 'env_changed' for this variable is not
486
				-- If we come back and it turns out we've
476
	-- set before processing the file. We do this to be able to
487
				-- already loaded the rest of what was in the
477
	-- distinguish the case where "loader_conf_files" is overriden in
488
				-- original loader_conf_files, no big deal.
478
	-- the to-read file with the same value that it currently has (in
489
				config.readConfFiles(newfiles, loaded_files)
479
	-- which case files must be loaded) from the case where it is not
490
				prefiles = newfiles
480
	-- specified (in which case no file is to be loaded). We'll have
491
			end
481
	-- to restore the state if not overwritten (see below).
492
			::continue::
482
	local saved_lcf_env_changed = env_changed["loader_conf_files"]
483
	if saved_lcf_env_changed ~= nil then
484
		env_changed["loader_conf_files"] = nil
485
	end
486
487
	-- These may or may not exist, and that's ok. Do a
488
	-- silent parse so that we complain on parse errors but
489
	-- not for them simply not existing.
490
	if not config.processFile(file, true) then
491
		print(MSG_FAILPARSECFG:format(file))
492
	end
493
494
	loaded_files[file] = true
495
496
	-- Going to process "loader_conf_files" extra-files
497
	local loader_conf_files = env_changed["loader_conf_files"]
498
	if loader_conf_files ~= nil then
499
		for name in loader_conf_files:gmatch("[%w%p]+") do
500
			config.readConf(name, loaded_files)
493
		end
501
		end
502
	else
503
		-- Restore back the original "loader_conf_files" value in
504
		-- "env_changed" if it was not overriden in the meantime.
505
		env_changed["loader_conf_files"] = saved_lcf_env_changed
494
	end
506
	end
495
end
507
end
496
508
Lines 602-614 Link Here
602
		file = "/boot/defaults/loader.conf"
614
		file = "/boot/defaults/loader.conf"
603
	end
615
	end
604
616
605
	if not config.processFile(file) then
617
	config.readConf(file)
606
		print(MSG_FAILPARSECFG:format(file))
607
	end
608
618
609
	local loaded_files = {file = true}
610
	config.readConfFiles(loader.getenv("loader_conf_files"), loaded_files)
611
612
	checkNextboot()
619
	checkNextboot()
613
620
614
	local verbose = loader.getenv("verbose_loading") or "no"
621
	local verbose = loader.getenv("verbose_loading") or "no"
(-)stand/lua/config.lua.8 (-7 / +16 lines)
Lines 59-73 Link Here
59
A lookup will be done as needed to determine what value
59
A lookup will be done as needed to determine what value
60
.Ev idx
60
.Ev idx
61
actually corresponds to.
61
actually corresponds to.
62
.It Fn config.readConfFiles files loaded_files
62
.It Fn config.readConf file loaded_files
63
Process
63
Process
64
.Ev files
64
.Pa file
65
as if it were
65
as a configuration file
66
.Ev loader_conf_files .
66
.Po e.g., as
67
The caller should pass in a table as the
67
.Pa loader.conf
68
.Pc
69
and then processing files listed in
70
.Ev loader_conf_files
71
variable
72
.Po see
73
.Xr loader.conf 5
74
.Pc .
75
The caller may optionally pass in a table as the
68
.Ev loaded_files
76
.Ev loaded_files
69
argument, which uses filenames as keys and any non-nil value to indicate that
77
argument, which uses filenames as keys and any non-nil value to
70
the file named by the key has been loaded.
78
indicate that the file named by the key has already been loaded and
79
should not be loaded again.
71
.It Fn config.processFile name silent
80
.It Fn config.processFile name silent
72
Process and parse
81
Process and parse
73
.Ev name
82
.Ev name

Return to bug 244640