chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: expose priority field of messages, in preparation for prioq support
[elogind.git]
/
src
/
gpt-auto-generator
/
gpt-auto-generator.c
diff --git
a/src/gpt-auto-generator/gpt-auto-generator.c
b/src/gpt-auto-generator/gpt-auto-generator.c
index b6f6a74a22a387a8b542f72f530cea8fe0b18226..05934da82f8a18a8495bbade7ebe4357112811f9 100644
(file)
--- a/
src/gpt-auto-generator/gpt-auto-generator.c
+++ b/
src/gpt-auto-generator/gpt-auto-generator.c
@@
-24,7
+24,7
@@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/statfs.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/statfs.h>
-#include <blkid.h>
+#include <blkid
/blkid
.h>
#ifdef HAVE_LINUX_BTRFS_H
#include <linux/btrfs.h>
#ifdef HAVE_LINUX_BTRFS_H
#include <linux/btrfs.h>
@@
-54,7
+54,7
@@
static const char *arg_dest = "/tmp";
static const char *arg_dest = "/tmp";
-define_trivial_cleanup_func(blkid_probe, blkid_free_probe)
+DEFINE_TRIVIAL_CLEANUP_FUNC(blkid_probe, blkid_free_probe);
#define _cleanup_blkid_freep_probe_ _cleanup_(blkid_free_probep)
static int verify_gpt_partition(const char *node, sd_id128_t *type, unsigned *nr, char **fstype) {
#define _cleanup_blkid_freep_probe_ _cleanup_(blkid_free_probep)
static int verify_gpt_partition(const char *node, sd_id128_t *type, unsigned *nr, char **fstype) {
@@
-74,10
+74,8
@@
static int verify_gpt_partition(const char *node, sd_id128_t *type, unsigned *nr
errno = 0;
r = blkid_do_safeprobe(b);
errno = 0;
r = blkid_do_safeprobe(b);
- if (r == -2)
- return -ENODEV;
- else if (r == 1)
- return -ENODEV;
+ if (r == -2 || r == 1) /* no result or uncertain */
+ return -EBADSLT;
else if (r != 0)
return errno ? -errno : -EIO;
else if (r != 0)
return errno ? -errno : -EIO;
@@
-182,7
+180,7
@@
static int add_swap(const char *path, const char *fstype) {
}
static int add_home(const char *path, const char *fstype) {
}
static int add_home(const char *path, const char *fstype) {
- _cleanup_free_ char *unit = NULL, *lnk = NULL;
+ _cleanup_free_ char *unit = NULL, *lnk = NULL
, *fsck = NULL
;
_cleanup_fclose_ FILE *f = NULL;
if (dir_is_empty("/home") <= 0)
_cleanup_fclose_ FILE *f = NULL;
if (dir_is_empty("/home") <= 0)
@@
-200,19
+198,23
@@
static int add_home(const char *path, const char *fstype) {
return -errno;
}
return -errno;
}
+ fsck = unit_name_from_path_instance("systemd-fsck", path, ".service");
+ if (!fsck)
+ return log_oom();
+
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
"[Unit]\n"
"DefaultDependencies=no\n"
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
"[Unit]\n"
"DefaultDependencies=no\n"
- "After=" SPECIAL_LOCAL_FS_PRE_TARGET "\n"
+ "Requires=%s\n"
+ "After=" SPECIAL_LOCAL_FS_PRE_TARGET " %s\n"
"Conflicts=" SPECIAL_UMOUNT_TARGET "\n"
"Before=" SPECIAL_UMOUNT_TARGET " " SPECIAL_LOCAL_FS_TARGET "\n\n"
"[Mount]\n"
"What=%s\n"
"Where=/home\n"
"Conflicts=" SPECIAL_UMOUNT_TARGET "\n"
"Before=" SPECIAL_UMOUNT_TARGET " " SPECIAL_LOCAL_FS_TARGET "\n\n"
"[Mount]\n"
"What=%s\n"
"Where=/home\n"
- "Type=%s\n"
- "FsckPassNo=2\n",
- path, fstype);
+ "Type=%s\n",
+ fsck, fsck, path, fstype);
fflush(f);
if (ferror(f)) {
fflush(f);
if (ferror(f)) {
@@
-224,7
+226,6
@@
static int add_home(const char *path, const char *fstype) {
if (!lnk)
return log_oom();
if (!lnk)
return log_oom();
-
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to create symlink %s: %m", lnk);
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to create symlink %s: %m", lnk);
@@
-294,6
+295,9
@@
static int enumerate_partitions(struct udev *udev, dev_t dev) {
r = verify_gpt_partition(node, &type_id, &nr, &fstype);
if (r < 0) {
r = verify_gpt_partition(node, &type_id, &nr, &fstype);
if (r < 0) {
+ /* skip child devices which are not detected properly */
+ if (r == -EBADSLT)
+ continue;
log_error("Failed to verify GPT partition %s: %s",
node, strerror(-r));
return r;
log_error("Failed to verify GPT partition %s: %s",
node, strerror(-r));
return r;