diff options
author | Tom Gundersen <teg@jklm.no> | 2014-09-08 13:50:52 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-09-08 15:09:07 +0200 |
commit | adc5b2e2ebcb91ee18b6a32681b8ec1e52793473 (patch) | |
tree | 8a15c0a594c734d67fcd3dae14100cf3a35c6d4d /src/libsystemd | |
parent | b70c73fcf1885b717b464353edecaf650a1e520a (diff) |
sd-network: add _get_network_file api
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-network/sd-network.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index 3a3f53576f..d63e6f9dfa 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -120,6 +120,30 @@ _public_ int sd_network_link_get_setup_state(int ifindex, char **state) { return 0; } +_public_ int sd_network_link_get_network_file(int ifindex, char **filename) { + _cleanup_free_ char *s = NULL, *p = NULL; + int r; + + assert_return(ifindex > 0, -EINVAL); + assert_return(filename, -EINVAL); + + if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0) + return -ENOMEM; + + r = parse_env_file(p, NEWLINE, "NETWORK_FILE", &s, NULL); + if (r == -ENOENT) + return -ENODATA; + if (r < 0) + return r; + if (isempty(s)) + return -ENODATA; + + *filename = s; + s = NULL; + + return 0; +} + _public_ int sd_network_link_get_operational_state(int ifindex, char **state) { _cleanup_free_ char *s = NULL, *p = NULL; int r; |