"ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
name);
- fflush(f);
- if (ferror(f))
- return log_error_errno(errno, "Failed to write file %s: %m", p);
+ r = fflush_and_check(f);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write file %s: %m", p);
from = strjoina("../", n);
"Options=umask=0077,noauto\n",
what);
- fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write mount unit file: %m");
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error_errno(r, "Failed to write mount unit file: %m");
return EXIT_FAILURE;
}
"Where=/boot\n"
"TimeoutIdleSec=120\n", f);
- fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write automount unit file: %m");
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error_errno(r, "Failed to write automount unit file: %m");
return EXIT_FAILURE;
}
if (!isempty(filtered) && !streq(filtered, "defaults"))
fprintf(f, "Options=%s\n", filtered);
- fflush(f);
- if (ferror(f))
- return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
+ r = fflush_and_check(f);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write unit file %s: %m", unit);
if (!noauto && post) {
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
if (r < 0)
return r;
- fflush(f);
- if (ferror(f))
- return log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
+ r = fflush_and_check(f);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write unit file %s: %m", automount_unit);
free(lnk);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);