fstab-generator: use generator_add_symlink()
This commit is contained in:
parent
b559616f23
commit
630d30d370
|
@ -91,7 +91,7 @@ static int add_swap(
|
||||||
bool noauto,
|
bool noauto,
|
||||||
bool nofail) {
|
bool nofail) {
|
||||||
|
|
||||||
_cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL;
|
_cleanup_free_ char *name = NULL, *unit = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -148,14 +148,10 @@ static int add_swap(
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (!noauto) {
|
if (!noauto) {
|
||||||
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET,
|
r = generator_add_symlink(arg_dest, SPECIAL_SWAP_TARGET,
|
||||||
nofail ? ".wants/" : ".requires/", name, NULL);
|
nofail ? "wants" : "requires", name);
|
||||||
if (!lnk)
|
if (r < 0)
|
||||||
return log_oom();
|
return r;
|
||||||
|
|
||||||
mkdir_parents_label(lnk, 0755);
|
|
||||||
if (symlink(unit, lnk) < 0)
|
|
||||||
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,7 +296,7 @@ static int add_mount(
|
||||||
const char *source) {
|
const char *source) {
|
||||||
|
|
||||||
_cleanup_free_ char
|
_cleanup_free_ char
|
||||||
*name = NULL, *unit = NULL, *lnk = NULL,
|
*name = NULL, *unit = NULL,
|
||||||
*automount_name = NULL, *automount_unit = NULL,
|
*automount_name = NULL, *automount_unit = NULL,
|
||||||
*filtered = NULL;
|
*filtered = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
|
@ -430,13 +426,10 @@ static int add_mount(
|
||||||
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
|
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
|
||||||
|
|
||||||
if (!noauto && !automount) {
|
if (!noauto && !automount) {
|
||||||
lnk = strjoin(dest, "/", post, nofail ? ".wants/" : ".requires/", name);
|
r = generator_add_symlink(dest, post,
|
||||||
if (!lnk)
|
nofail ? "wants" : "requires", name);
|
||||||
return log_oom();
|
if (r < 0)
|
||||||
|
return r;
|
||||||
mkdir_parents_label(lnk, 0755);
|
|
||||||
if (symlink(unit, lnk) < 0)
|
|
||||||
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (automount) {
|
if (automount) {
|
||||||
|
@ -491,14 +484,10 @@ static int add_mount(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to write unit file %s: %m", automount_unit);
|
return log_error_errno(r, "Failed to write unit file %s: %m", automount_unit);
|
||||||
|
|
||||||
free(lnk);
|
r = generator_add_symlink(dest, post,
|
||||||
lnk = strjoin(dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name);
|
nofail ? "wants" : "requires", automount_name);
|
||||||
if (!lnk)
|
if (r < 0)
|
||||||
return log_oom();
|
return r;
|
||||||
|
|
||||||
mkdir_parents_label(lnk, 0755);
|
|
||||||
if (symlink(automount_unit, lnk) < 0)
|
|
||||||
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue