mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Fail in bad disk layout version.
This commit is contained in:
parent
0f4779e2a0
commit
0b39d08d80
1 changed files with 11 additions and 4 deletions
13
data.c
13
data.c
|
@ -30,7 +30,7 @@ int srv_open(char *basedir)
|
||||||
cfg_file = xs_fmt("%s/server.json", basedir);
|
cfg_file = xs_fmt("%s/server.json", basedir);
|
||||||
|
|
||||||
if ((f = fopen(cfg_file, "r")) == NULL)
|
if ((f = fopen(cfg_file, "r")) == NULL)
|
||||||
error = xs_fmt("error opening '%s'", cfg_file);
|
error = xs_fmt("ERROR: cannot opening '%s'", cfg_file);
|
||||||
else {
|
else {
|
||||||
xs *cfg_data;
|
xs *cfg_data;
|
||||||
|
|
||||||
|
@ -41,18 +41,21 @@ int srv_open(char *basedir)
|
||||||
srv_config = xs_json_loads(cfg_data);
|
srv_config = xs_json_loads(cfg_data);
|
||||||
|
|
||||||
if (srv_config == NULL)
|
if (srv_config == NULL)
|
||||||
error = xs_fmt("cannot parse '%s'", cfg_file);
|
error = xs_fmt("ERROR: cannot parse '%s'", cfg_file);
|
||||||
else {
|
else {
|
||||||
char *host;
|
char *host;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
char *dbglvl;
|
char *dbglvl;
|
||||||
|
char *layout;
|
||||||
|
double f = 0.0;
|
||||||
|
|
||||||
host = xs_dict_get(srv_config, "host");
|
host = xs_dict_get(srv_config, "host");
|
||||||
prefix = xs_dict_get(srv_config, "prefix");
|
prefix = xs_dict_get(srv_config, "prefix");
|
||||||
dbglvl = xs_dict_get(srv_config, "dbglevel");
|
dbglvl = xs_dict_get(srv_config, "dbglevel");
|
||||||
|
layout = xs_dict_get(srv_config, "layout");
|
||||||
|
|
||||||
if (host == NULL || prefix == NULL)
|
if (host == NULL || prefix == NULL)
|
||||||
error = xs_str_new("cannot get server data");
|
error = xs_str_new("ERROR: cannot get server data");
|
||||||
else {
|
else {
|
||||||
srv_baseurl = xs_fmt("https://%s%s", host, prefix);
|
srv_baseurl = xs_fmt("https://%s%s", host, prefix);
|
||||||
|
|
||||||
|
@ -63,8 +66,12 @@ int srv_open(char *basedir)
|
||||||
error = xs_fmt("DEBUG level set to %d from environment", dbglevel);
|
error = xs_fmt("DEBUG level set to %d from environment", dbglevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!layout || (f = xs_number_get(layout)) != 2.0)
|
||||||
|
error = xs_fmt("ERROR: unsupported old disk layout %f\n", f);
|
||||||
|
else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue