*
*/
int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr,
- const char *file, snd_config_t **cfg)
+ const char *file, snd_config_t **cfg, bool optional)
{
char filename[PATH_MAX];
int err;
ucm_filename(filename, sizeof(filename), uc_mgr->conf_format,
file[0] == '/' ? NULL : uc_mgr->conf_dir_name,
file);
- err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg);
+ err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg, optional);
if (err < 0) {
- snd_error(UCM, "failed to open file %s: %d", filename, err);
+ if (!optional || (err != -ENOENT && err != -EACCES))
+ snd_error(UCM, "failed to open file %s: %d", filename, err);
return err;
}
return 0;
if (file) {
if (substfile) {
snd_config_t *cfg;
- err = uc_mgr_config_load_file(uc_mgr, file, &cfg);
+ err = uc_mgr_config_load_file(uc_mgr, file, &cfg, false);
if (err < 0)
return err;
err = uc_mgr_substitute_tree(uc_mgr, cfg);
ucm_filename(filename, sizeof(filename), uc_mgr->conf_format,
file[0] == '/' ? NULL : uc_mgr->conf_dir_name,
file);
- err = uc_mgr_config_load_into(uc_mgr->conf_format, filename, uc_mgr->local_config);
+ err = uc_mgr_config_load_into(uc_mgr->conf_format, filename, uc_mgr->local_config, false);
if (err < 0)
return err;
}
if (file) {
snd_config_t *cfg;
/* load config from file */
- err = uc_mgr_config_load_file(uc_mgr, file, &cfg);
+ err = uc_mgr_config_load_file(uc_mgr, file, &cfg, false);
if (err < 0)
goto __error;
/* parse the config */
snd_config_t *cfg;
const char *fname = vfile ? vfile : file;
/* load config from file */
- err = uc_mgr_config_load_file(uc_mgr, fname, &cfg);
+ err = uc_mgr_config_load_file(uc_mgr, fname, &cfg, false);
if (err >= 0) {
err = parse_verb_config(uc_mgr, id,
vcomment ? vcomment : comment,
return -ENOENT;
}
- err = uc_mgr_config_load(2, filename, &tcfg);
+ err = uc_mgr_config_load(2, filename, &tcfg, false);
if (err < 0)
goto __error;
if (err < 0)
goto __error;
- err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg);
+ err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg, false);
if (err < 0) {
snd_error(UCM, "could not parse configuration for card %s", uc_mgr->card_name);
goto __error;
#endif
continue;
- err = uc_mgr_config_load(2, filename, &cfg);
+ err = uc_mgr_config_load(2, filename, &cfg, false);
if (err < 0)
goto __err;
err = snd_config_search(cfg, "Syntax", &c);
const char *uc_mgr_sysfs_root(void);
const char *uc_mgr_config_dir(int format);
-int uc_mgr_config_load_into(int format, const char *file, snd_config_t *cfg);
-int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg);
-int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, const char *file, snd_config_t **cfg);
+int uc_mgr_config_load_into(int format, const char *file, snd_config_t *cfg, bool optional);
+int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg, bool optional);
+int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, const char *file, snd_config_t **cfg, bool optional);
int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
int uc_mgr_scan_master_configs(const char **_list[]);
return path;
}
-int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top)
+int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top, bool optional)
{
FILE *fp;
snd_input_t *in;
if (!fp) {
err = -errno;
__err_open:
- snd_error(UCM, "could not open configuration file %s", file);
+ if (!optional || (err != -ENOENT && err != -EACCES))
+ snd_error(UCM, "could not open configuration file %s", file);
+ else
+ snd_trace(UCM, "could not open configuration file %s", file);
return err;
}
err = snd_input_stdio_attach(&in, fp, 1);
return 0;
}
-int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg)
+int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg, bool optional)
{
snd_config_t *top;
int err;
err = snd_config_top(&top);
if (err < 0)
return err;
- err = uc_mgr_config_load_into(format, file, top);
+ err = uc_mgr_config_load_into(format, file, top, optional);
if (err < 0) {
snd_config_delete(top);
return err;