summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-lease.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-03 15:43:02 +0100
committerTom Gundersen <teg@jklm.no>2014-03-03 16:48:02 +0100
commitce78df79b88d02d36cbf9e39e70ecb871750e16d (patch)
tree6fba4d4220d43c0bc27b5f6cedc3a504a078e923 /src/libsystemd-network/sd-dhcp-lease.c
parent8100c1a8f58b2fb5d97e156420a7e16562e93bc4 (diff)
sd-dhcp-lease: add Root Path support
This is necessary when mounting /dev/nfs based on a DHCP lease.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-lease.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 0529b6d8fa..722dd0a419 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -96,6 +96,18 @@ int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname) {
return 0;
}
+int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path) {
+ assert_return(lease, -EINVAL);
+ assert_return(root_path, -EINVAL);
+
+ if (lease->root_path)
+ *root_path = lease->root_path;
+ else
+ return -ENOENT;
+
+ return 0;
+}
+
int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, struct in_addr *addr) {
assert_return(lease, -EINVAL);
assert_return(addr, -EINVAL);
@@ -212,6 +224,14 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
break;
+ case DHCP_OPTION_ROOT_PATH:
+ if (len >= 1) {
+ free(lease->root_path);
+ lease->root_path = strndup((const char *)option, len);
+ }
+
+ break;
+
case DHCP_OPTION_RENEWAL_T1_TIME:
if (len == 4) {
memcpy(&val, option, 4);
@@ -323,6 +343,10 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
if (r >= 0)
fprintf(f, "HOSTNAME=%s\n", string);
+ r = sd_dhcp_lease_get_root_path(lease, &string);
+ if (r >= 0)
+ fprintf(f, "ROOT_PATH=%s\n", string);
+
r = 0;
fflush(f);
@@ -361,6 +385,7 @@ int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret) {
"MTU", &mtu,
"DOMAINNAME", &lease->domainname,
"HOSTNAME", &lease->hostname,
+ "ROOT_PATH", &lease->root_path,
NULL);
if (r < 0) {
if (r == -ENOENT)