diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-04-29 18:40:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-29 18:40:19 +0200 |
commit | db7076bf78bd8e466ae927b6d3ddf64190c8d299 (patch) | |
tree | 58b5135da7e2b28b525e7b532644576bae750927 /src/shared | |
parent | 007f09d487da7f8e136cd1346feee2dcba28be61 (diff) | |
parent | d9732d78034cd01a75f2cda6ebaddb4c3a0929ea (diff) |
Merge pull request #5164 from Werkov/ordering-for-_netdev-devices
Ordering for _netdev devices
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/generator.c | 41 | ||||
-rw-r--r-- | src/shared/generator.h | 6 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c index 9a069b2f97..19ec133772 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -188,10 +188,49 @@ int generator_write_timeouts( return write_drop_in_format(dir, unit, 50, "device-timeout", "# Automatically generated by %s\n\n" - "[Unit]\nJobTimeoutSec=%s", + "[Unit]\nJobRunningTimeoutSec=%s", program_invocation_short_name, timeout); } +int generator_write_device_deps( + const char *dir, + const char *what, + const char *where, + const char *opts) { + + /* fstab records that specify _netdev option should apply the network + * ordering on the actual device depending on network connection. If we + * are not mounting real device (NFS, CIFS), we rely on _netdev effect + * on the mount unit itself. */ + + _cleanup_free_ char *node = NULL, *unit = NULL; + int r; + + if (!fstab_test_option(opts, "_netdev\0")) + return 0; + + node = fstab_node_to_udev_node(what); + if (!node) + return log_oom(); + + /* Nothing to apply dependencies to. */ + if (!is_device_path(node)) + return 0; + + r = unit_name_from_path(node, ".device", &unit); + if (r < 0) + return log_error_errno(r, "Failed to make unit name from path: %m"); + + /* See mount_add_default_dependencies for explanation why we create such + * dependencies. */ + return write_drop_in_format(dir, unit, 50, "netdev-dependencies", + "# Automatically generated by %s\n\n" + "[Unit]\n" + "After=" SPECIAL_NETWORK_ONLINE_TARGET " " SPECIAL_NETWORK_TARGET "\n" + "Wants=" SPECIAL_NETWORK_ONLINE_TARGET "\n", + program_invocation_short_name); +} + int generator_write_initrd_root_device_deps(const char *dir, const char *what) { _cleanup_free_ char *unit = NULL; int r; diff --git a/src/shared/generator.h b/src/shared/generator.h index a6017c1b76..825d934c8e 100644 --- a/src/shared/generator.h +++ b/src/shared/generator.h @@ -35,6 +35,12 @@ int generator_write_timeouts( const char *opts, char **filtered); +int generator_write_device_deps( + const char *dir, + const char *what, + const char *where, + const char *opts); + int generator_write_initrd_root_device_deps( const char *dir, const char *what); |