generator.c revision 7410616cd9dbbec97cf98d75324da5cda2b2f7a2
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include "util.h"
#include "special.h"
#include "mkdir.h"
#include "unit-name.h"
#include "generator.h"
#include "path-util.h"
#include "fstab-util.h"
#include "dropin.h"
FILE *f,
const char *dir,
const char *what,
const char *where,
const char *fstype) {
int r;
assert(f);
if (!is_device_path(what)) {
return 0;
}
r = fsck_exists(fstype);
if (r == -ENOENT) {
/* treat missing check as essentially OK */
return 0;
} else if (r < 0)
return log_warning_errno(r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype);
}
char *lnk;
} else {
if (r < 0)
return log_error_errno(r, "Failed to create fsck service name: %m");
fprintf(f,
"RequiresOverridable=%1$s\n"
"After=%1$s\n",
fsck);
}
return 0;
}
const char *dir,
const char *what,
const char *where,
const char *opts,
char **filtered) {
/* Allow configuration how long we wait for a device that
* backs a mount point to show up. This is useful to support
* endless device timeouts for devices that show up only after
* user input, like crypto devices. */
usec_t u;
int r;
if (r <= 0)
return r;
if (r < 0) {
return 0;
}
if (!node)
return log_oom();
if (r < 0)
return log_error_errno(r, "Failed to make unit name from path: %m");
"# Automatically generated by %s\n\n"
"[Unit]\nJobTimeoutSec=" USEC_FMT,
u / USEC_PER_SEC);
}