Compare commits
3 Commits
397288e3eb
...
d06661ab66
Author | SHA1 | Date |
---|---|---|
Zbigniew Jędrzejewski-Szmek | d06661ab66 | |
Yu Watanabe | 9f83091e3c | |
Yu Watanabe | c4473dec34 |
|
@ -689,7 +689,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||||
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
||||||
NETDEV_COMMON_SECTIONS NETDEV_OTHER_SECTIONS,
|
NETDEV_COMMON_SECTIONS NETDEV_OTHER_SECTIONS,
|
||||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||||
CONFIG_PARSE_WARN, netdev_raw);
|
CONFIG_PARSE_WARN, netdev_raw, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||||
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
||||||
NETDEV_VTABLE(netdev)->sections,
|
NETDEV_VTABLE(netdev)->sections,
|
||||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||||
CONFIG_PARSE_WARN, netdev);
|
CONFIG_PARSE_WARN, netdev, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|
|
@ -335,6 +335,7 @@ int network_verify(Network *network) {
|
||||||
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
|
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
|
||||||
_cleanup_free_ char *fname = NULL, *name = NULL;
|
_cleanup_free_ char *fname = NULL, *name = NULL;
|
||||||
_cleanup_(network_unrefp) Network *network = NULL;
|
_cleanup_(network_unrefp) Network *network = NULL;
|
||||||
|
_cleanup_strv_free_ char **dropins = NULL;
|
||||||
_cleanup_fclose_ FILE *file = NULL;
|
_cleanup_fclose_ FILE *file = NULL;
|
||||||
const char *dropin_dirname;
|
const char *dropin_dirname;
|
||||||
char *d;
|
char *d;
|
||||||
|
@ -522,7 +523,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||||
"TokenBucketFilter\0"
|
"TokenBucketFilter\0"
|
||||||
"TrivialLinkEqualizer\0",
|
"TrivialLinkEqualizer\0",
|
||||||
config_item_perf_lookup, network_network_gperf_lookup,
|
config_item_perf_lookup, network_network_gperf_lookup,
|
||||||
CONFIG_PARSE_WARN, network);
|
CONFIG_PARSE_WARN, network, &dropins);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -538,10 +539,23 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||||
network->filename);
|
network->filename);
|
||||||
|
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
if (stat(filename, &stats) < 0)
|
if (stat(filename, &stats) >= 0)
|
||||||
return -errno;
|
|
||||||
network->timestamp = timespec_load(&stats.st_mtim);
|
network->timestamp = timespec_load(&stats.st_mtim);
|
||||||
|
|
||||||
|
char **f;
|
||||||
|
STRV_FOREACH(f, dropins) {
|
||||||
|
usec_t t;
|
||||||
|
|
||||||
|
if (stat(*f, &stats) < 0) {
|
||||||
|
network->timestamp = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
t = timespec_load(&stats.st_mtim);
|
||||||
|
if (t > network->timestamp)
|
||||||
|
network->timestamp = t;
|
||||||
|
}
|
||||||
|
|
||||||
if (network_verify(network) < 0)
|
if (network_verify(network) < 0)
|
||||||
/* Ignore .network files that do not match the conditions. */
|
/* Ignore .network files that do not match the conditions. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -89,7 +89,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
|
||||||
r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
|
r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
|
||||||
"Service\0",
|
"Service\0",
|
||||||
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
|
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
|
||||||
false, service);
|
false, service, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|
|
@ -493,7 +493,8 @@ int config_parse_many(
|
||||||
ConfigItemLookup lookup,
|
ConfigItemLookup lookup,
|
||||||
const void *table,
|
const void *table,
|
||||||
ConfigParseFlags flags,
|
ConfigParseFlags flags,
|
||||||
void *userdata) {
|
void *userdata,
|
||||||
|
char ***ret_dropins) {
|
||||||
|
|
||||||
_cleanup_strv_free_ char **dropin_dirs = NULL;
|
_cleanup_strv_free_ char **dropin_dirs = NULL;
|
||||||
_cleanup_strv_free_ char **files = NULL;
|
_cleanup_strv_free_ char **files = NULL;
|
||||||
|
@ -509,7 +510,14 @@ int config_parse_many(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
return config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata);
|
r = config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (ret_dropins)
|
||||||
|
*ret_dropins = TAKE_PTR(files);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_PARSER(type, vartype, conv_func) \
|
#define DEFINE_PARSER(type, vartype, conv_func) \
|
||||||
|
|
|
@ -107,7 +107,8 @@ int config_parse_many(
|
||||||
ConfigItemLookup lookup,
|
ConfigItemLookup lookup,
|
||||||
const void *table,
|
const void *table,
|
||||||
ConfigParseFlags flags,
|
ConfigParseFlags flags,
|
||||||
void *userdata);
|
void *userdata,
|
||||||
|
char ***ret_dropins); /* possibly NULL */
|
||||||
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_int);
|
CONFIG_PARSER_PROTOTYPE(config_parse_int);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_unsigned);
|
CONFIG_PARSER_PROTOTYPE(config_parse_unsigned);
|
||||||
|
|
Loading…
Reference in New Issue