diff options
-rw-r--r-- | blkid.c | 66 | ||||
-rwxr-xr-x | build | 2 | ||||
-rw-r--r-- | changelog | 7 | ||||
-rw-r--r-- | copyright | 21 | ||||
-rw-r--r-- | install-lilo.sh | 5 |
5 files changed, 92 insertions, 9 deletions
@@ -0,0 +1,66 @@ +/* + * Print an MBR disk signature for use in a Linux PARTUUID + * + * Copyright (C) 2020 Patrick McDermott + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <inttypes.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +static int +read_id(const char *dev) +{ + FILE *fp; + uint8_t id[4]; + + if ((fp = fopen(dev, "r")) == NULL) { + perror("Failed to open device"); + return 1; + } + + if (fseek(fp, 440L, SEEK_SET) != 0) { + perror("Failed to seek on device"); + fclose(fp); + return 1; + } + + if (fread(id, sizeof(*id), sizeof(id) / sizeof(*id), fp) != 4) { + perror("Failed to read from device"); + fclose(fp); + return 1; + } + + printf("%" PRIx8 "%" PRIx8 "%" PRIx8 "%" PRIx8 "\n", + id[3], id[2], id[1], id[0]); + + fclose(fp); + return 0; +} + +int +main(int argc, char *argv[]) +{ + int errors = 0; + + while (--argc) { + errors += read_id(*++argv); + } + + return (errors > 0) ? EXIT_FAILURE : EXIT_SUCCESS; +} @@ -12,6 +12,8 @@ build: install: build oh-autoinstall install -m 0755 ../install-lilo.sh dest/sbin/install-lilo + install -d -m 0755 dest/usr/libexec/lilo/ + $(CC) -o dest/usr/libexec/lilo/blkid ../blkid.c rm dest/etc/*/p*.d/* dest/etc/lilo.conf_example rm dest/boot/coffee.bmp dest/boot/debian*.bmp dest/boot/*.dat # Remove unneeded Perl and Bash scripts. @@ -1,3 +1,10 @@ +lilo (24.2-2) trunk + + * Use an included "/usr/libexec/lilo/blkid" utility instead of "od" to + read the MBR disk signature. + + -- Patrick McDermott <patrick.mcdermott@libiquity.com> Sun, 13 Dec 2020 10:18:41 -0500 + lilo (24.2-1) trunk * New upstream version. @@ -92,10 +92,21 @@ On this system, a copy of the GNU General Public License may be found at Distribution Packaging ====================== -Copyright (C) 2014 Patrick "P. J." McDermott +Copyright (C) 2014, 2020 Patrick McDermott -These files may be reproduced, distributed, modified, and otherwise dealt in -under the terms of the Expat License. +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, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -On this system, a copy of the Expat License may be found at -<file:///usr/share/common-licenses/Expat>. +On this system, a copy of the GNU General Public License may be found at +<file:///usr/share/common-licenses/GPL-2>. diff --git a/install-lilo.sh b/install-lilo.sh index 6ec8555..6beae2c 100644 --- a/install-lilo.sh +++ b/install-lilo.sh @@ -28,11 +28,8 @@ main() sed 's|^\([/a-zA-Z]*\)\([0-9]*\)|\1|')" rootpart="$(printf '%s\n' "${root}" | \ sed 's|^\([/a-zA-Z]*\)\([0-9]*\)|\2|')" - read b4 b3 b2 b1 <<-EOF - $(od -An -tx1 -v -j 440 -N 4 "${rootdev}") - EOF root="$(printf 'PARTUUID=%s-%02d\n' \ - "${b1}${b2}${b3}${b4}" ${rootpart})" + "$(/usr/libexec/lilo/blkid "${rootdev}")" ${rootpart})" elif [ ${#} -eq 2 ]; then boot="${1}" root="${2}" |