Use fflush_and_check() in more places
This commit is contained in:
parent
0dfb89d3c2
commit
4652c56c59
|
@ -176,9 +176,9 @@ static int create_disk(
|
||||||
"ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
|
"ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
if (ferror(f))
|
if (r < 0)
|
||||||
return log_error_errno(errno, "Failed to write file %s: %m", p);
|
return log_error_errno(r, "Failed to write file %s: %m", p);
|
||||||
|
|
||||||
from = strjoina("../", n);
|
from = strjoina("../", n);
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,9 @@ int main(int argc, char *argv[]) {
|
||||||
"Options=umask=0077,noauto\n",
|
"Options=umask=0077,noauto\n",
|
||||||
what);
|
what);
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
if (ferror(f)) {
|
if (r < 0) {
|
||||||
log_error_errno(errno, "Failed to write mount unit file: %m");
|
log_error_errno(r, "Failed to write mount unit file: %m");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ int main(int argc, char *argv[]) {
|
||||||
"Where=/boot\n"
|
"Where=/boot\n"
|
||||||
"TimeoutIdleSec=120\n", f);
|
"TimeoutIdleSec=120\n", f);
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
if (ferror(f)) {
|
if (r < 0) {
|
||||||
log_error_errno(errno, "Failed to write automount unit file: %m");
|
log_error_errno(r, "Failed to write automount unit file: %m");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,9 +275,9 @@ static int add_mount(
|
||||||
if (!isempty(filtered) && !streq(filtered, "defaults"))
|
if (!isempty(filtered) && !streq(filtered, "defaults"))
|
||||||
fprintf(f, "Options=%s\n", filtered);
|
fprintf(f, "Options=%s\n", filtered);
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
if (ferror(f))
|
if (r < 0)
|
||||||
return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
|
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
|
||||||
|
|
||||||
if (!noauto && post) {
|
if (!noauto && post) {
|
||||||
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
|
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
|
||||||
|
@ -324,9 +324,9 @@ static int add_mount(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
if (ferror(f))
|
if (r < 0)
|
||||||
return log_error_errno(errno, "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);
|
free(lnk);
|
||||||
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
|
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
|
||||||
|
|
Loading…
Reference in a new issue