From 3f1d72433d6ffc9802382192f1a33b122bd623f5 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 13 Dec 2020 09:49:23 -0500 Subject: /usr/libexec/lilo/blkid: New binary to replace od --- diff --git a/blkid.c b/blkid.c new file mode 100644 index 0000000..f88290d --- /dev/null +++ b/blkid.c @@ -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 +#include +#include +#include + +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; +} diff --git a/build b/build index a9a6ec5..3c885b4 100755 --- a/build +++ b/build @@ -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. diff --git a/changelog b/changelog index e4a7e1c..4d414e7 100644 --- a/changelog +++ b/changelog @@ -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 Sun, 13 Dec 2020 10:18:41 -0500 + lilo (24.2-1) trunk * New upstream version. diff --git a/copyright b/copyright index b59ba92..8c707fd 100644 --- a/copyright +++ b/copyright @@ -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 -. +On this system, a copy of the GNU General Public License may be found at +. 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}" -- cgit v0.9.1