1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 #include "path-util.h"
30 static const char *arg_dest = "/tmp";
32 int main(int argc, char *argv[]) {
35 _cleanup_free_ char *name = NULL;
36 _cleanup_fclose_ FILE *f = NULL;
38 if (argc > 1 && argc != 4) {
39 log_error("This program takes three or no arguments.");
46 log_set_target(LOG_TARGET_SAFE);
47 log_parse_environment();
55 if (dir_is_empty("/boot") <= 0)
58 r = efi_get_loader_device_part_uuid(&id);
62 log_error("Failed to read ESP partition UUID: %s", strerror(-r));
66 name = strjoin(arg_dest, "/boot.mount", NULL);
72 f = fopen(name, "wxe");
74 log_error("Failed to create mount unit file %s: %m", name);
79 "# Automatially generated by systemd-efi-boot-generator\n\n"
81 "Description=EFI System Partition\n\n"
84 "What=/dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n"
85 "Options=umask=0077\n",
86 SD_ID128_FORMAT_VAL(id));
89 name = strjoin(arg_dest, "/boot.automount", NULL);
96 f = fopen(name, "wxe");
98 log_error("Failed to create automount unit file %s: %m", name);
102 fputs("# Automatially generated by systemd-efi-boot-generator\n\n"
104 "Description=EFI System Partition Automount\n\n"
109 name = strjoin(arg_dest, "/local-fs.target.wants/boot.automount", NULL);
115 mkdir_parents(name, 0755);
117 if (symlink("../boot.automount", name) < 0) {
118 log_error("Failed to create symlink: %m");