2011-12-21 22:30:48 +01:00
|
|
|
/*
|
|
|
|
* probe disks for filesystems and partitions
|
|
|
|
*
|
2012-11-12 19:36:23 +01:00
|
|
|
* Copyright (C) 2011 Kay Sievers <kay@vrfy.org>
|
2011-12-21 22:30:48 +01:00
|
|
|
* Copyright (C) 2011 Karel Zak <kzak@redhat.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
2011-12-23 03:16:56 +01:00
|
|
|
#include <getopt.h>
|
2011-12-21 22:30:48 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <blkid/blkid.h>
|
|
|
|
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
#include "sd-id128.h"
|
|
|
|
#include "gpt.h"
|
|
|
|
#include "efivars.h"
|
2011-12-21 22:30:48 +01:00
|
|
|
#include "udev.h"
|
|
|
|
|
2014-07-29 15:47:41 +02:00
|
|
|
static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) {
|
2014-03-07 02:34:18 +01:00
|
|
|
char s[256];
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
s[0] = '\0';
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
if (streq(name, "TYPE")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_TYPE", value);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "USAGE")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_USAGE", value);
|
2011-12-23 04:06:34 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "VERSION")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_VERSION", value);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "UUID")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_safe_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_UUID", s);
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_UUID_ENC", s);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "UUID_SUB")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_safe_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_UUID_SUB", s);
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_UUID_SUB_ENC", s);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "LABEL")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_safe_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_LABEL", s);
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_LABEL_ENC", s);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "PTTYPE")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_TABLE_TYPE", value);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2013-09-19 17:36:40 +02:00
|
|
|
} else if (streq(name, "PTUUID")) {
|
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_TABLE_UUID", value);
|
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "PART_ENTRY_NAME")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
2012-01-16 15:38:41 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_ENTRY_NAME", s);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (streq(name, "PART_ENTRY_TYPE")) {
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
2012-01-16 15:38:41 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_ENTRY_TYPE", s);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-04-16 20:27:44 +02:00
|
|
|
} else if (startswith(name, "PART_ENTRY_")) {
|
2013-01-09 19:06:46 +01:00
|
|
|
strscpyl(s, sizeof(s), "ID_", name, NULL);
|
2012-01-26 17:56:18 +01:00
|
|
|
udev_builtin_add_property(dev, test, s, value);
|
2013-02-17 02:21:27 +01:00
|
|
|
|
|
|
|
} else if (streq(name, "SYSTEM_ID")) {
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_SYSTEM_ID", s);
|
|
|
|
|
|
|
|
} else if (streq(name, "PUBLISHER_ID")) {
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_PUBLISHER_ID", s);
|
|
|
|
|
|
|
|
} else if (streq(name, "APPLICATION_ID")) {
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_APPLICATION_ID", s);
|
|
|
|
|
|
|
|
} else if (streq(name, "BOOT_SYSTEM_ID")) {
|
|
|
|
blkid_encode_string(value, s, sizeof(s));
|
|
|
|
udev_builtin_add_property(dev, test, "ID_FS_BOOT_SYSTEM_ID", s);
|
2012-01-10 01:34:15 +01:00
|
|
|
}
|
2011-12-21 22:30:48 +01:00
|
|
|
}
|
|
|
|
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) {
|
|
|
|
|
|
|
|
#if defined(GPT_ROOT_NATIVE) && defined(ENABLE_EFI)
|
|
|
|
|
|
|
|
_cleanup_free_ char *root_id = NULL;
|
|
|
|
bool found_esp = false;
|
|
|
|
blkid_partlist pl;
|
|
|
|
int i, nvals, r;
|
|
|
|
|
|
|
|
assert(pr);
|
|
|
|
|
|
|
|
/* Iterate through the partitions on this disk, and see if the
|
|
|
|
* EFI ESP we booted from is on it. If so, find the first root
|
|
|
|
* disk, and add a property indicating its partition UUID. */
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
pl = blkid_probe_get_partitions(pr);
|
|
|
|
if (!pl)
|
|
|
|
return errno ? -errno : -ENOMEM;
|
|
|
|
|
|
|
|
nvals = blkid_partlist_numof_partitions(pl);
|
|
|
|
for (i = 0; i < nvals; i++) {
|
|
|
|
blkid_partition pp;
|
|
|
|
const char *stype, *sid;
|
|
|
|
sd_id128_t type;
|
|
|
|
|
|
|
|
pp = blkid_partlist_get_partition(pl, i);
|
|
|
|
if (!pp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sid = blkid_partition_get_uuid(pp);
|
|
|
|
if (!sid)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
stype = blkid_partition_get_type_string(pp);
|
|
|
|
if (!stype)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sd_id128_from_string(stype, &type) < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sd_id128_equal(type, GPT_ESP)) {
|
|
|
|
sd_id128_t id, esp;
|
|
|
|
|
|
|
|
/* We found an ESP, let's see if it matches
|
|
|
|
* the ESP we booted from. */
|
|
|
|
|
|
|
|
if (sd_id128_from_string(sid, &id) < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
r = efi_loader_get_device_part_uuid(&esp);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
if (sd_id128_equal(id, esp))
|
|
|
|
found_esp = true;
|
|
|
|
|
|
|
|
} else if (sd_id128_equal(type, GPT_ROOT_NATIVE)) {
|
|
|
|
|
|
|
|
/* We found a suitable root partition, let's
|
|
|
|
* remember the first one. */
|
|
|
|
|
|
|
|
if (!root_id) {
|
|
|
|
root_id = strdup(sid);
|
|
|
|
if (!root_id)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We found the ESP on this disk, and also found a root
|
2014-03-07 03:30:30 +01:00
|
|
|
* partition, nice! Let's export its UUID */
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
if (found_esp && root_id)
|
2014-03-07 03:30:30 +01:00
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT_UUID", root_id);
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-29 15:47:41 +02:00
|
|
|
static int probe_superblocks(blkid_probe pr) {
|
2012-01-10 01:34:15 +01:00
|
|
|
struct stat st;
|
|
|
|
int rc;
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
if (fstat(blkid_probe_get_fd(pr), &st))
|
|
|
|
return -1;
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_probe_enable_partitions(pr, 1);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2014-03-07 02:34:18 +01:00
|
|
|
if (!S_ISCHR(st.st_mode) &&
|
|
|
|
blkid_probe_get_size(pr) <= 1024 * 1440 &&
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_probe_is_wholedisk(pr)) {
|
|
|
|
/*
|
|
|
|
* check if the small disk is partitioned, if yes then
|
|
|
|
* don't probe for filesystems.
|
|
|
|
*/
|
|
|
|
blkid_probe_enable_superblocks(pr, 0);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
rc = blkid_do_fullprobe(pr);
|
|
|
|
if (rc < 0)
|
2014-03-07 02:34:18 +01:00
|
|
|
return rc; /* -1 = error, 1 = nothing, 0 = success */
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
if (blkid_probe_lookup_value(pr, "PTTYPE", NULL, NULL) == 0)
|
|
|
|
return 0; /* partition table detected */
|
|
|
|
}
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
|
|
|
|
blkid_probe_enable_superblocks(pr, 1);
|
2011-12-21 22:30:48 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
return blkid_do_safeprobe(pr);
|
2011-12-21 22:30:48 +01:00
|
|
|
}
|
|
|
|
|
2014-07-29 15:47:41 +02:00
|
|
|
static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test) {
|
2014-03-07 03:30:30 +01:00
|
|
|
const char *root_partition;
|
2012-01-10 01:34:15 +01:00
|
|
|
int64_t offset = 0;
|
|
|
|
bool noraid = false;
|
2014-03-07 02:34:18 +01:00
|
|
|
_cleanup_close_ int fd = -1;
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_probe pr;
|
|
|
|
const char *data;
|
|
|
|
const char *name;
|
2014-12-13 01:56:56 +01:00
|
|
|
const char *prtype = NULL;
|
2012-01-10 01:34:15 +01:00
|
|
|
int nvals;
|
|
|
|
int i;
|
|
|
|
int err = 0;
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
bool is_gpt = false;
|
2012-01-10 01:34:15 +01:00
|
|
|
|
|
|
|
static const struct option options[] = {
|
|
|
|
{ "offset", optional_argument, NULL, 'o' },
|
|
|
|
{ "noraid", no_argument, NULL, 'R' },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
int option;
|
|
|
|
|
|
|
|
option = getopt_long(argc, argv, "oR", options, NULL);
|
|
|
|
if (option == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (option) {
|
|
|
|
case 'o':
|
|
|
|
offset = strtoull(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
noraid = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pr = blkid_new_probe();
|
2012-04-13 15:08:55 +02:00
|
|
|
if (!pr)
|
2012-01-10 01:34:15 +01:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
blkid_probe_set_superblocks_flags(pr,
|
|
|
|
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
|
|
|
|
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
|
2014-12-13 01:56:56 +01:00
|
|
|
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
|
|
|
|
BLKID_SUBLKS_BADCSUM);
|
2012-01-10 01:34:15 +01:00
|
|
|
|
|
|
|
if (noraid)
|
|
|
|
blkid_probe_filter_superblocks_usage(pr, BLKID_FLTR_NOTIN, BLKID_USAGE_RAID);
|
|
|
|
|
|
|
|
fd = open(udev_device_get_devnode(dev), O_RDONLY|O_CLOEXEC);
|
|
|
|
if (fd < 0) {
|
|
|
|
fprintf(stderr, "error: %s: %m\n", udev_device_get_devnode(dev));
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = blkid_probe_set_device(pr, fd, offset, 0);
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
|
2014-04-25 13:45:15 +02:00
|
|
|
log_debug("probe %s %sraid offset=%"PRIu64,
|
2012-04-08 16:06:20 +02:00
|
|
|
udev_device_get_devnode(dev),
|
2014-04-25 13:45:15 +02:00
|
|
|
noraid ? "no" : "", offset);
|
2012-01-10 01:34:15 +01:00
|
|
|
|
|
|
|
err = probe_superblocks(pr);
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
2014-12-13 01:56:56 +01:00
|
|
|
if (blkid_probe_has_value(pr, "SBBADCSUM")) {
|
|
|
|
if (!blkid_probe_lookup_value(pr, "TYPE", &prtype, NULL))
|
|
|
|
log_warning("incorrect %s checksum on %s",
|
|
|
|
prtype, udev_device_get_devnode(dev));
|
|
|
|
else
|
|
|
|
log_warning("incorrect checksum on %s",
|
|
|
|
udev_device_get_devnode(dev));
|
|
|
|
goto out;
|
|
|
|
}
|
2012-01-10 01:34:15 +01:00
|
|
|
|
2014-03-07 03:30:30 +01:00
|
|
|
/* If we are a partition then our parent passed on the root
|
|
|
|
* partition UUID to us */
|
|
|
|
root_partition = udev_device_get_property_value(dev, "ID_PART_GPT_AUTO_ROOT_UUID");
|
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
nvals = blkid_probe_numof_values(pr);
|
|
|
|
for (i = 0; i < nvals; i++) {
|
2014-03-07 14:37:01 +01:00
|
|
|
if (blkid_probe_get_value(pr, i, &name, &data, NULL))
|
2012-01-10 01:34:15 +01:00
|
|
|
continue;
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
|
2014-03-07 14:37:01 +01:00
|
|
|
print_property(dev, test, name, data);
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
|
2014-03-07 03:30:30 +01:00
|
|
|
/* Is this a disk with GPT partition table? */
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
if (streq(name, "PTTYPE") && streq(data, "gpt"))
|
|
|
|
is_gpt = true;
|
2014-03-07 03:30:30 +01:00
|
|
|
|
|
|
|
/* Is this a partition that matches the root partition
|
|
|
|
* property we inherited from our parent? */
|
|
|
|
if (root_partition && streq(name, "PART_ENTRY_UUID") && streq(data, root_partition))
|
|
|
|
udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT", "1");
|
2012-01-10 01:34:15 +01:00
|
|
|
}
|
|
|
|
|
udev-builtin-blkid: when we find a GPT partition marked as root disk on the same disk as the ESP, expose a property on the udev device
This is preparation for a logic to automatically discover the root
partition to boot from if no partition has been configured explicitly.
This makes use of our newly defined GPT type GUIDs for our root disks:
#define GPT_ROOT_X86 SD_ID128_MAKE(44,47,95,40,f2,97,41,b2,9a,f7,d1,31,d5,f0,45,8a)
#define GPT_ROOT_X86_64 SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09)
We define differen GUIDs for different architectures to allow images
which finde the right root partition for the appropriate arch.
2014-03-07 02:35:19 +01:00
|
|
|
if (is_gpt)
|
|
|
|
find_gpt_root(dev, pr, test);
|
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
blkid_free_probe(pr);
|
2011-12-21 22:30:48 +01:00
|
|
|
out:
|
2012-01-10 01:34:15 +01:00
|
|
|
if (err < 0)
|
|
|
|
return EXIT_FAILURE;
|
2014-03-07 02:34:18 +01:00
|
|
|
|
2012-01-10 01:34:15 +01:00
|
|
|
return EXIT_SUCCESS;
|
2011-12-21 22:30:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct udev_builtin udev_builtin_blkid = {
|
2012-01-10 01:34:15 +01:00
|
|
|
.name = "blkid",
|
|
|
|
.cmd = builtin_blkid,
|
|
|
|
.help = "filesystem and partition probing",
|
|
|
|
.run_once = true,
|
2011-12-21 22:30:48 +01:00
|
|
|
};
|