mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
sd-network: introduce sd_network_link_get_stat()
This commit is contained in:
@@ -387,6 +387,23 @@ int sd_network_link_get_carrier_bound_by(int ifindex, int **ret) {
|
||||
return network_link_get_ifindexes(ifindex, "CARRIER_BOUND_BY", ret);
|
||||
}
|
||||
|
||||
int sd_network_link_get_stat(int ifindex, struct stat *ret) {
|
||||
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)];
|
||||
struct stat st;
|
||||
|
||||
assert_return(ifindex > 0, -EINVAL);
|
||||
|
||||
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
|
||||
|
||||
if (stat(path, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
if (ret)
|
||||
*ret = st;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int MONITOR_TO_FD(sd_network_monitor *m) {
|
||||
return (int) (unsigned long) m - 1;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
@@ -187,6 +188,8 @@ int sd_network_link_get_dhcp6_client_iaid_string(int ifindex, char **iaid);
|
||||
/* Get DHCPv6 client DUID for a given link. */
|
||||
int sd_network_link_get_dhcp6_client_duid_string(int ifindex, char **duid);
|
||||
|
||||
int sd_network_link_get_stat(int ifindex, struct stat *ret);
|
||||
|
||||
/* Monitor object */
|
||||
typedef struct sd_network_monitor sd_network_monitor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user