Bump buildroot to 2020.11-rc1 (#985)

* Update buildroot-patches for 2020.11-rc1 buildroot

* Update buildroot to 2020.11-rc1

Signed-off-by: Stefan Agner <stefan@agner.ch>

* Don't rely on sfdisk --list-free output

The --list-free (-F) argument does not allow machine readable mode. And
it seems that the output format changes over time (different spacing,
using size postfixes instead of raw blocks).

Use sfdisk json output and calculate free partition space ourselfs. This
works for 2.35 and 2.36 and is more robust since we rely on output which
is meant for scripts to parse.

* Migrate defconfigs for Buildroot 2020.11-rc1

In particular, rename BR2_TARGET_UBOOT_BOOT_SCRIPT(_SOURCE) to
BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT(_SOURCE).

* Rebase/remove systemd patches for systemd 246

* Drop apparmor/libapparmor from buildroot-external

* hassos-persists: use /run as directory for lockfiles

The U-Boot tools use /var/lock by default which is not created any more
by systemd by default (it is under tmpfiles legacy.conf, which we no
longer install).

* Disable systemd-update-done.service

The service is not suited for pure read-only systems. In particular the
service needs to be able to write a file in /etc and /var. Remove the
service. Note: This is a static service and cannot be removed using
systemd-preset.

* Disable apparmor.service for now

The service loads all default profiles. Some might actually cause
problems. E.g. the profile for ping seems not to match our setup for
/etc/resolv.conf:
[85503.634653] audit: type=1400 audit(1605286002.684:236): apparmor="DENIED" operation="open" profile="ping" name="/run/resolv.conf" pid=27585 comm="ping" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
This commit is contained in:
Stefan Agner
2020-11-13 18:25:44 +01:00
committed by GitHub
parent 25a0dd3082
commit a0871be6c0
4024 changed files with 68095 additions and 47900 deletions

View File

@@ -1,86 +0,0 @@
From 34fed3ff1740aded9c2aae6b5d67a4eb696f738e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 9 Jan 2020 11:03:51 +0100
Subject: [PATCH] blkdiscard: use O_EXCL, add --force
Let's make it more robust and safe. O_EXCL is an elegant way how to avoid
unwanted discard on mounted device.
Addresses: https://github.com/karelzak/util-linux/issues/915
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
sys-utils/blkdiscard.8 | 5 +++++
sys-utils/blkdiscard.c | 11 ++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/sys-utils/blkdiscard.8 b/sys-utils/blkdiscard.8
index 1f3a32be9..98c6f36a9 100644
--- a/sys-utils/blkdiscard.8
+++ b/sys-utils/blkdiscard.8
@@ -36,6 +36,11 @@ MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is
optional, e.g., "K" has the same meaning as "KiB") or the suffixes
KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
.TP
+.BR \-f , " \-\-force"
+Disable all checking. Since v2.36 the block device is open in exclusive mode (O_EXCL)
+by default to avoid collision with mounted filesystem or another kernel subsystem.
+The force option disables the exclusive access mode.
+.TP
.BR \-o , " \-\-offset \fIoffset"
Byte offset into the device from which to start discarding. The provided value
will be aligned to the device sector size. The default value is zero.
diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c
index f9ba5e468..589974f9c 100644
--- a/sys-utils/blkdiscard.c
+++ b/sys-utils/blkdiscard.c
@@ -88,6 +88,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Discard the content of sectors on a device.\n"), out);
fputs(USAGE_OPTIONS, out);
+ fputs(_(" -f, --force disable all checking\n"), out);
fputs(_(" -o, --offset <num> offset in bytes to discard from\n"), out);
fputs(_(" -l, --length <num> length of bytes to discard from the offset\n"), out);
fputs(_(" -p, --step <num> size of the discard iterations within the offset\n"), out);
@@ -106,7 +107,7 @@ static void __attribute__((__noreturn__)) usage(void)
int main(int argc, char **argv)
{
char *path;
- int c, fd, verbose = 0, secsize;
+ int c, fd, verbose = 0, secsize, force = 0;
uint64_t end, blksize, step, range[2], stats[2];
struct stat sb;
struct timeval now, last;
@@ -116,6 +117,7 @@ int main(int argc, char **argv)
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "offset", required_argument, NULL, 'o' },
+ { "force", no_argument, NULL, 'f' },
{ "length", required_argument, NULL, 'l' },
{ "step", required_argument, NULL, 'p' },
{ "secure", no_argument, NULL, 's' },
@@ -133,8 +135,11 @@ int main(int argc, char **argv)
range[1] = ULLONG_MAX;
step = 0;
- while ((c = getopt_long(argc, argv, "hVsvo:l:p:z", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hfVsvo:l:p:z", longopts, NULL)) != -1) {
switch(c) {
+ case 'f':
+ force = 1;
+ break;
case 'l':
range[1] = strtosize_or_err(optarg,
_("failed to parse length"));
@@ -176,7 +181,7 @@ int main(int argc, char **argv)
errtryhelp(EXIT_FAILURE);
}
- fd = open(path, O_WRONLY);
+ fd = open(path, O_WRONLY | (force ? 0 : O_EXCL));
if (fd < 0)
err(EXIT_FAILURE, _("cannot open %s"), path);
--
2.18.2

View File

@@ -1,195 +0,0 @@
From e5f31446166de7212213c62a019945afb8e197ef Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 14 Jan 2020 11:43:24 +0100
Subject: [PATCH] libfdisk: add fdisk_set_disklabel_id_from_string()
We have fdisk_set_disklabel_id(), but it's old ask-API based function.
It's not comfortable if you want to avoid dialog or template.
Addresses: https://github.com/karelzak/util-linux/issues/916
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
libfdisk/docs/libfdisk-sections.txt | 1 +
libfdisk/src/dos.c | 29 ++++++++++++++++++-----------
libfdisk/src/fdiskP.h | 2 +-
libfdisk/src/gpt.c | 18 ++++++++++--------
libfdisk/src/label.c | 19 ++++++++++++++++++-
libfdisk/src/libfdisk.h.in | 1 +
libfdisk/src/libfdisk.sym | 3 +++
7 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/libfdisk/docs/libfdisk-sections.txt b/libfdisk/docs/libfdisk-sections.txt
index f148da527..6675c1100 100644
--- a/libfdisk/docs/libfdisk-sections.txt
+++ b/libfdisk/docs/libfdisk-sections.txt
@@ -81,6 +81,7 @@ fdisk_list_disklabel
fdisk_locate_disklabel
fdisk_reorder_partitions
fdisk_set_disklabel_id
+fdisk_set_disklabel_id_from_string
fdisk_set_partition_type
fdisk_toggle_partition_flag
fdisk_verify_disklabel
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 53713ec5f..98314dfa6 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -707,12 +707,12 @@ static int dos_create_disklabel(struct fdisk_context *cxt)
return 0;
}
-static int dos_set_disklabel_id(struct fdisk_context *cxt)
+static int dos_set_disklabel_id(struct fdisk_context *cxt, const char *str)
{
- char *end = NULL, *str = NULL;
+ char *str0 = str;
unsigned int id, old;
struct fdisk_dos_label *l;
- int rc;
+ int rc = 0;
assert(cxt);
assert(cxt->label);
@@ -722,18 +722,25 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt)
l = self_label(cxt);
old = mbr_get_id(cxt->firstsector);
- rc = fdisk_ask_string(cxt,
+
+ if (!str)
+ rc = fdisk_ask_string(cxt,
_("Enter the new disk identifier"), &str);
- if (rc)
- return rc;
+ if (!rc) {
+ char *end = NULL;
- errno = 0;
- id = strtoul(str, &end, 0);
- if (errno || str == end || (end && *end)) {
- fdisk_warnx(cxt, _("Incorrect value."));
- return -EINVAL;
+ errno = 0;
+ id = strtoul(str, &end, 0);
+ if (errno || str == end || (end && *end)) {
+ fdisk_warnx(cxt, _("Incorrect value."));
+ rc = -EINVAL;
+ }
}
+ if (!str0)
+ free(str);
+ if (rc)
+ return -EINVAL;
mbr_set_id(cxt->firstsector, id);
l->non_pt_changed = 1;
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
index fefebae2a..0487466e3 100644
--- a/libfdisk/src/fdiskP.h
+++ b/libfdisk/src/fdiskP.h
@@ -220,7 +220,7 @@ struct fdisk_label_operations {
/* get details from label */
int (*get_item)(struct fdisk_context *cxt, struct fdisk_labelitem *item);
/* set disk label ID */
- int (*set_id)(struct fdisk_context *cxt);
+ int (*set_id)(struct fdisk_context *cxt, const char *str);
/* new partition */
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index f50bb4441..9608053a2 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -2502,11 +2502,11 @@ done:
return rc;
}
-static int gpt_set_disklabel_id(struct fdisk_context *cxt)
+static int gpt_set_disklabel_id(struct fdisk_context *cxt, const char *str)
{
struct fdisk_gpt_label *gpt;
struct gpt_guid uuid;
- char *str, *old, *new;
+ char *old, *new;
int rc;
assert(cxt);
@@ -2514,12 +2514,14 @@ static int gpt_set_disklabel_id(struct fdisk_context *cxt)
assert(fdisk_is_label(cxt, GPT));
gpt = self_label(cxt);
- if (fdisk_ask_string(cxt,
- _("Enter new disk UUID (in 8-4-4-4-12 format)"), &str))
- return -EINVAL;
-
- rc = string_to_guid(str, &uuid);
- free(str);
+ if (!str) {
+ if (fdisk_ask_string(cxt,
+ _("Enter new disk UUID (in 8-4-4-4-12 format)"), &str))
+ return -EINVAL;
+ rc = string_to_guid(str, &uuid);
+ free(str);
+ } else
+ rc = string_to_guid(str, &uuid);
if (rc) {
fdisk_warnx(cxt, _("Failed to parse your UUID."));
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index a18cdeaff..fd4555de2 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -481,7 +481,24 @@ int fdisk_set_disklabel_id(struct fdisk_context *cxt)
return -ENOSYS;
DBG(CXT, ul_debugobj(cxt, "setting %s disk ID", cxt->label->name));
- return cxt->label->op->set_id(cxt);
+ return cxt->label->op->set_id(cxt, NULL);
+}
+
+/**
+ * fdisk_set_disklabel_id_from_string
+ * @cxt: fdisk context
+ *
+ * Returns: 0 on success, otherwise, a corresponding error.
+ */
+int fdisk_set_disklabel_id_from_string(struct fdisk_context *cxt, const char *str)
+{
+ if (!cxt || !cxt->label || !str)
+ return -EINVAL;
+ if (!cxt->label->op->set_id)
+ return -ENOSYS;
+
+ DBG(CXT, ul_debugobj(cxt, "setting %s disk ID from '%s'", cxt->label->name, str));
+ return cxt->label->op->set_id(cxt, str);
}
/**
diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in
index 0669c0a7c..2ba34dc0a 100644
--- a/libfdisk/src/libfdisk.h.in
+++ b/libfdisk/src/libfdisk.h.in
@@ -399,6 +399,7 @@ extern int fdisk_get_disklabel_item(struct fdisk_context *cxt, int id, struct fd
extern int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id);
extern int fdisk_set_disklabel_id(struct fdisk_context *cxt);
+extern int fdisk_set_disklabel_id_from_string(struct fdisk_context *cxt, const char *str);
extern int fdisk_get_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition **pa);
extern int fdisk_set_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition *pa);
diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym
index 96fcadd71..eee2d6bda 100644
--- a/libfdisk/src/libfdisk.sym
+++ b/libfdisk/src/libfdisk.sym
@@ -308,3 +308,6 @@ FDISK_2.35 {
fdisk_script_set_table;
fdisk_assign_device_by_fd;
} FDISK_2.33;
+FDISK_2.36 {
+ fdisk_set_disklabel_id_from_string;
+} FDISK_2.35;
--
2.18.2

View File

@@ -1,139 +0,0 @@
From 65e27d545cb54ac63536a8b6e7d5def180ddb5b7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 14 Jan 2020 11:50:46 +0100
Subject: [PATCH] sfdisk: add --disk-id to change disk UUID/ID
Addresses: https://github.com/karelzak/util-linux/issues/916
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
disk-utils/sfdisk.8 | 5 +++++
disk-utils/sfdisk.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8
index 3ff5dd4e6..9ee71e81a 100644
--- a/disk-utils/sfdisk.8
+++ b/disk-utils/sfdisk.8
@@ -152,6 +152,11 @@ or a GUID for GPT. For backward compatibility the options \fB\-c\fR and
Change the GPT partition UUID. If \fIuuid\fR is not specified,
then print the current partition UUID.
.TP
+.BR "\-\-disk\-id \fIdevice " [ \fIid ]
+Change the disk identifier. If \fIid\fR is not specified,
+then print the current identifier. The identifier is UUID for GPT
+or unsigned integer for MBR.
+.TP
.BR \-r , " \-\-reorder " \fIdevice
Renumber the partitions, ordering them by their start offset.
.TP
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index bb6e1c6df..0db797b2d 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -86,6 +86,7 @@ enum {
ACT_PARTUUID,
ACT_PARTLABEL,
ACT_PARTATTRS,
+ ACT_DISKID,
ACT_DELETE
};
@@ -1327,6 +1328,46 @@ static int command_partattrs(struct sfdisk *sf, int argc, char **argv)
return write_changes(sf);
}
+/*
+ * sfdisk --disk-id <device> [<str>]
+ */
+static int command_diskid(struct sfdisk *sf, int argc, char **argv)
+{
+ const char *devname = NULL;
+ char *str = NULL;
+
+ if (!argc)
+ errx(EXIT_FAILURE, _("no disk device specified"));
+ devname = argv[0];
+
+ if (argc == 2)
+ str = argv[1];
+ else if (argc > 2)
+ errx(EXIT_FAILURE, _("unexpected arguments"));
+
+ if (fdisk_assign_device(sf->cxt, devname, !str) != 0)
+ err(EXIT_FAILURE, _("cannot open %s"), devname);
+
+ /* print */
+ if (!str) {
+ fdisk_get_disklabel_id(sf->cxt, &str);
+ if (str)
+ printf("%s\n", str);
+ free(str);
+ fdisk_deassign_device(sf->cxt, 1);
+ return 0;
+ }
+
+ /* change */
+ if (sf->backup)
+ backup_partition_table(sf, devname);
+
+ if (fdisk_set_disklabel_id_from_string(sf->cxt, str) != 0)
+ errx(EXIT_FAILURE, _("%s: failed to set disklabel ID"), devname);
+
+ return write_changes(sf);
+}
+
static void sfdisk_print_partition(struct sfdisk *sf, size_t n)
{
struct fdisk_partition *pa = NULL;
@@ -1941,6 +1982,9 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" --part-uuid <dev> <part> [<uuid>] print or change partition uuid\n"), out);
fputs(_(" --part-attrs <dev> <part> [<str>] print or change partition attributes\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_(" --disk-id <dev> [<str>] print or change disk label ID (UUID)\n"), out);
+
fputs(USAGE_SEPARATOR, out);
fputs(_(" <dev> device (usually disk) path\n"), out);
fputs(_(" <part> partition number\n"), out);
@@ -2007,6 +2051,7 @@ int main(int argc, char *argv[])
OPT_PARTLABEL,
OPT_PARTTYPE,
OPT_PARTATTRS,
+ OPT_DISKID,
OPT_BYTES,
OPT_COLOR,
OPT_MOVEDATA,
@@ -2052,6 +2097,8 @@ int main(int argc, char *argv[])
{ "part-type", no_argument, NULL, OPT_PARTTYPE },
{ "part-attrs", no_argument, NULL, OPT_PARTATTRS },
+ { "disk-id", no_argument, NULL, OPT_DISKID },
+
{ "show-pt-geometry", no_argument, NULL, 'G' }, /* deprecated */
{ "unit", required_argument, NULL, 'u' }, /* deprecated */
{ "Linux", no_argument, NULL, 'L' }, /* deprecated */
@@ -2192,6 +2239,9 @@ int main(int argc, char *argv[])
case OPT_PARTATTRS:
sf->act = ACT_PARTATTRS;
break;
+ case OPT_DISKID:
+ sf->act = ACT_DISKID;
+ break;
case OPT_NOREREAD:
sf->noreread = 1;
break;
@@ -2296,6 +2346,10 @@ int main(int argc, char *argv[])
rc = command_partattrs(sf, argc - optind, argv + optind);
break;
+ case ACT_DISKID:
+ rc = command_diskid(sf, argc - optind, argv + optind);
+ break;
+
case ACT_REORDER:
rc = command_reorder(sf, argc - optind, argv + optind);
break;
--
2.18.2

View File

@@ -1,62 +0,0 @@
From 3cfde0370d3a8949df0c5bcf447cec6692910ed2 Mon Sep 17 00:00:00 2001
From: Sami Kerola <kerolasa@iki.fi>
Date: Sat, 15 Feb 2020 21:12:50 +0000
Subject: [PATCH] kill: include sys/types.h before checking
SYS_pidfd_send_signal
Including sys/types.h must happen before SYS_pidfd_send_signal is checked,
because that header defines variable in normal conditions. When sys/types.h
does not have SYS_pidfd_send_signal then fallback is defined in config.h
that is included by default, and has therefore worked fine before and after
this change.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
include/pidfd-utils.h | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
index 593346576..0baedd2c9 100644
--- a/include/pidfd-utils.h
+++ b/include/pidfd-utils.h
@@ -1,26 +1,28 @@
#ifndef UTIL_LINUX_PIDFD_UTILS
#define UTIL_LINUX_PIDFD_UTILS
-#if defined(__linux__) && defined(SYS_pidfd_send_signal)
-# include <sys/types.h>
+#if defined(__linux__)
# include <sys/syscall.h>
+# if defined(SYS_pidfd_send_signal)
+# include <sys/types.h>
-# ifndef HAVE_PIDFD_OPEN
+# ifndef HAVE_PIDFD_OPEN
static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
unsigned int flags)
{
return syscall(SYS_pidfd_send_signal, pidfd, sig, info, flags);
}
-# endif
+# endif
-# ifndef HAVE_PIDFD_SEND_SIGNAL
+# ifndef HAVE_PIDFD_SEND_SIGNAL
static inline int pidfd_open(pid_t pid, unsigned int flags)
{
return syscall(SYS_pidfd_open, pid, flags);
}
-# endif
+# endif
-# define UL_HAVE_PIDFD 1
+# define UL_HAVE_PIDFD 1
-#endif /* __linux__ && SYS_pidfd_send_signal */
+# endif /* SYS_pidfd_send_signal */
+#endif /* __linux__ */
#endif /* UTIL_LINUX_PIDFD_UTILS */
--
2.18.2

View File

@@ -1,40 +0,0 @@
From 0a4035ff2e4fd5b5ae0cf8f8665696c2aff53b75 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 10 Mar 2020 11:43:16 +0100
Subject: [PATCH] include: cleanup pidfd inckudes
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
include/pidfd-utils.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
index 0baedd2c9..4a6c3a604 100644
--- a/include/pidfd-utils.h
+++ b/include/pidfd-utils.h
@@ -3,10 +3,10 @@
#if defined(__linux__)
# include <sys/syscall.h>
-# if defined(SYS_pidfd_send_signal)
+# if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
# include <sys/types.h>
-# ifndef HAVE_PIDFD_OPEN
+# ifndef HAVE_PIDFD_SEND_SIGNAL
static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
unsigned int flags)
{
@@ -14,7 +14,7 @@ static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
}
# endif
-# ifndef HAVE_PIDFD_SEND_SIGNAL
+# ifndef HAVE_PIDFD_OPEN
static inline int pidfd_open(pid_t pid, unsigned int flags)
{
return syscall(SYS_pidfd_open, pid, flags);
--
2.18.2

View File

@@ -1,138 +0,0 @@
From d8c68b52cc939a16f04ec976648a37f5f5de718c Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 4 Feb 2020 15:11:19 +0100
Subject: libfdisk: (script) accept sector-size, ignore unknown headers
- add sector-size between supported headers (already in --dump output)
- report unknown headers by -ENOTSUP
- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()
Addresses: https://github.com/karelzak/util-linux/issues/949
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Retrieved from:
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=d8c68b52cc939a16f04ec976648a37f5f5de718c]
---
disk-utils/sfdisk.c | 6 +++++-
libfdisk/src/script.c | 49 ++++++++++++++++++++++++++-----------------------
2 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 0db797b2d..e08862aa8 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1823,7 +1823,11 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
}
rc = fdisk_script_read_line(dp, stdin, buf, sizeof(buf));
- if (rc < 0) {
+ if (rc == -ENOTSUP) {
+ buf[sizeof(buf) - 1] = '\0';
+ fdisk_warnx(sf->cxt, _("Unknown script header '%s' -- ignore."), buf);
+ continue;
+ } else if (rc < 0) {
DBG(PARSE, ul_debug("script parsing failed, trying sfdisk specific commands"));
buf[sizeof(buf) - 1] = '\0';
rc = loop_control_commands(sf, dp, buf);
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
index a21771b6a..d3e67fa9c 100644
--- a/libfdisk/src/script.c
+++ b/libfdisk/src/script.c
@@ -805,8 +805,12 @@ static inline int is_header_line(const char *s)
/* parses "<name>: value", note modifies @s*/
static int parse_line_header(struct fdisk_script *dp, char *s)
{
- int rc = -EINVAL;
+ size_t i;
char *name, *value;
+ static const char *supported[] = {
+ "label", "unit", "label-id", "device", "grain",
+ "first-lba", "last-lba", "table-length", "sector-size"
+ };
DBG(SCRIPT, ul_debugobj(dp, " parse header '%s'", s));
@@ -816,7 +820,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
name = s;
value = strchr(s, ':');
if (!value)
- goto done;
+ return -EINVAL;
*value = '\0';
value++;
@@ -825,32 +829,30 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
ltrim_whitespace((unsigned char *) value);
rtrim_whitespace((unsigned char *) value);
+ if (!*name || !*value)
+ return -EINVAL;
+
+ /* check header name */
+ for (i = 0; i < ARRAY_SIZE(supported); i++) {
+ if (strcmp(name, supported[i]) == 0)
+ break;
+ }
+ if (i == ARRAY_SIZE(supported))
+ return -ENOTSUP;
+
+ /* header specific actions */
if (strcmp(name, "label") == 0) {
if (dp->cxt && !fdisk_get_label(dp->cxt, value))
- goto done; /* unknown label name */
+ return -EINVAL; /* unknown label name */
dp->force_label = 1;
+
} else if (strcmp(name, "unit") == 0) {
if (strcmp(value, "sectors") != 0)
- goto done; /* only "sectors" supported */
- } else if (strcmp(name, "label-id") == 0
- || strcmp(name, "device") == 0
- || strcmp(name, "grain") == 0
- || strcmp(name, "first-lba") == 0
- || strcmp(name, "last-lba") == 0
- || strcmp(name, "table-length") == 0) {
- ; /* whatever is possible */
- } else
- goto done; /* unknown header */
+ return -EINVAL; /* only "sectors" supported */
- if (*name && *value)
- rc = fdisk_script_set_header(dp, name, value);
-done:
- if (rc)
- DBG(SCRIPT, ul_debugobj(dp, "header parse error: "
- "[rc=%d, name='%s', value='%s']",
- rc, name, value));
- return rc;
+ }
+ return fdisk_script_set_header(dp, name, value);
}
/* returns zero terminated string with next token and @str is updated */
@@ -1363,7 +1365,8 @@ int fdisk_script_set_fgets(struct fdisk_script *dp,
*
* Reads next line into dump.
*
- * Returns: 0 on success, <0 on error, 1 when nothing to read.
+ * Returns: 0 on success, <0 on error, 1 when nothing to read. For unknown headers
+ * returns -ENOTSUP, it's usually safe to ignore this error.
*/
int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz)
{
@@ -1428,7 +1431,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
while (!feof(f)) {
rc = fdisk_script_read_line(dp, f, buf, sizeof(buf));
- if (rc)
+ if (rc && rc != -ENOTSUP)
break;
}
--
cgit 1.2-0.3.lf.el7

View File

@@ -9,6 +9,9 @@ menuconfig BR2_PACKAGE_UTIL_LINUX
if BR2_PACKAGE_UTIL_LINUX
config BR2_PACKAGE_UTIL_LINUX_LIBS
bool
config BR2_PACKAGE_UTIL_LINUX_LIBBLKID
bool "libblkid"
depends on BR2_USE_MMU # fork()
@@ -84,15 +87,14 @@ config BR2_PACKAGE_UTIL_LINUX_CHFN_CHSH
bool "chfn/chsh"
depends on (BR2_ENABLE_LOCALE && BR2_USE_WCHAR) # linux-pam
depends on !BR2_STATIC_LIBS
depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
depends on BR2_USE_MMU # linux-pam
select BR2_PACKAGE_LINUX_PAM
help
Change login shell, real user name and information
comment "chfn/chsh needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
comment "chfn/chsh needs a toolchain w/ wchar, locale, dynamic library"
depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
|| BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
|| BR2_STATIC_LIBS
config BR2_PACKAGE_UTIL_LINUX_CHMEM
bool "chmem"

View File

@@ -0,0 +1 @@
../util-linux.hash

View File

@@ -0,0 +1,89 @@
################################################################################
#
# util-linux-libs
#
################################################################################
# Please keep this file as similar as possible to util-linux.mk
UTIL_LINUX_LIBS_VERSION = $(UTIL_LINUX_VERSION)
UTIL_LINUX_LIBS_SOURCE = $(UTIL_LINUX_SOURCE)
UTIL_LINUX_LIBS_SITE = $(UTIL_LINUX_SITE)
UTIL_LINUX_LIBS_DL_SUBDIR = $(UTIL_LINUX_DL_SUBDIR)
# README.licensing claims that some files are GPL-2.0 only, but this is not
# true. Some files are GPL-3.0+ but only in tests and optionally in hwclock
# (but we disable that option). rfkill uses an ISC-style license.
UTIL_LINUX_LIBS_LICENSE = LGPL-2.1+ (libblkid, libfdisk, libmount), BSD-3-Clause (libuuid)
UTIL_LINUX_LIBS_LICENSE_FILES = README.licensing \
Documentation/licenses/COPYING.BSD-3-Clause \
Documentation/licenses/COPYING.LGPL-2.1-or-later
UTIL_LINUX_LIBS_INSTALL_STAGING = YES
UTIL_LINUX_LIBS_DEPENDENCIES = \
host-pkgconf \
$(TARGET_NLS_DEPENDENCIES)
UTIL_LINUX_LIBS_CONF_OPTS += \
--disable-rpath \
--disable-makeinstall-chown
UTIL_LINUX_LIBS_LINK_LIBS = $(TARGET_NLS_LIBS)
# Prevent the installation from attempting to move shared libraries from
# ${usrlib_execdir} (/usr/lib) to ${libdir} (/lib), since both paths are
# the same when merged usr is in use.
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
UTIL_LINUX_LIBS_CONF_OPTS += --bindir=/usr/bin --sbindir=/usr/sbin --libdir=/usr/lib
endif
# systemd depends on util-linux-libs so we disable systemd support
UTIL_LINUX_LIBS_CONF_OPTS += \
--without-systemd \
--with-systemdsystemunitdir=no
# systemd/eudev depend on util-linux-libs so we disable udev support
UTIL_LINUX_LIBS_CONF_OPTS += --without-udev
# No libs use wchar
UTIL_LINUX_LIBS_CONF_OPTS += --disable-widechar
# No libs use ncurses
UTIL_LINUX_LIBS_CONF_OPTS += --without-ncursesw --without-ncurses
# Unfortunately, the util-linux does LIBS="" at the end of its
# configure script. So we have to pass the proper LIBS value when
# calling the configure script to make configure tests pass properly,
# and then pass it again at build time.
UTIL_LINUX_LIBS_CONF_ENV += LIBS="$(UTIL_LINUX_LIBS_LINK_LIBS)"
UTIL_LINUX_LIBS_MAKE_OPTS += LIBS="$(UTIL_LINUX_LIBS_LINK_LIBS)"
# libmount optionally uses selinux
ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBMOUNT)$(BR2_PACKAGE_LIBSELINUX),yy)
UTIL_LINUX_LIBS_DEPENDENCIES += libselinux
UTIL_LINUX_LIBS_CONF_OPTS += --with-selinux
else
UTIL_LINUX_LIBS_CONF_OPTS += --without-selinux
endif
# Disable utilities
UTIL_LINUX_LIBS_CONF_OPTS += \
--disable-all-programs \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBBLKID),--enable-libblkid,--disable-libblkid) \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBFDISK),--enable-libfdisk,--disable-libfdisk) \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBMOUNT),--enable-libmount,--disable-libmount) \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBSMARTCOLS),--enable-libsmartcols,--disable-libsmartcols) \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBUUID),--enable-libuuid,--disable-libuuid)
# libmount python bindings are separate, will be installed by full util-linux
UTIL_LINUX_LIBS_CONF_OPTS += --without-python --disable-pylibmount
# No libs use readline
UTIL_LINUX_LIBS_CONF_OPTS += --without-readline
# No libs use audit
UTIL_LINUX_LIBS_CONF_OPTS += --without-audit
# No libs use libmagic
UTIL_LINUX_LIBS_CONF_OPTS += --without-libmagic
$(eval $(autotools-package))

View File

@@ -1,9 +1,9 @@
# From https://www.kernel.org/pub/linux/utils/util-linux/v2.35/sha256sums.asc
sha256 d9de3edd287366cd908e77677514b9387b22bc7b88f45b83e1922c3597f1d7f9 util-linux-2.35.1.tar.xz
# From https://www.kernel.org/pub/linux/utils/util-linux/v2.36/sha256sums.asc
sha256 9e4b1c67eb13b9b67feb32ae1dc0d50e08ce9e5d82e1cccd0ee771ad2fa9e0b1 util-linux-2.36.tar.xz
# License files, locally calculated
sha256 869660b5269f4f40a8a679da7f403ea3a6e71d46087aab5e14871b09bcb55955 README.licensing
sha256 9b718a9460fed5952466421235bc79eb49d4e9eacc920d7a9dd6285ab8fd6c6d Documentation/licenses/COPYING.BSD-3-Clause
sha256 ba7640f00d93e72e92b94b9d71f25ec53bac2f1682f5c4adcccb0018359f60f8 Documentation/licenses/COPYING.BSD-4-Clause-UC
sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 Documentation/licenses/COPYING.GPL-2.0-or-later
sha256 e53348ce276358e9997014071c5294b36a18c4b34f32f00ee57b9acce0aafd63 Documentation/licenses/COPYING.ISC
sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 Documentation/licenses/COPYING.LGPL-2.1-or-later
sha256 869660b5269f4f40a8a679da7f403ea3a6e71d46087aab5e14871b09bcb55955 README.licensing
sha256 9b718a9460fed5952466421235bc79eb49d4e9eacc920d7a9dd6285ab8fd6c6d Documentation/licenses/COPYING.BSD-3-Clause
sha256 ba7640f00d93e72e92b94b9d71f25ec53bac2f1682f5c4adcccb0018359f60f8 Documentation/licenses/COPYING.BSD-4-Clause-UC
sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 Documentation/licenses/COPYING.GPL-2.0-or-later
sha256 e53348ce276358e9997014071c5294b36a18c4b34f32f00ee57b9acce0aafd63 Documentation/licenses/COPYING.ISC
sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 Documentation/licenses/COPYING.LGPL-2.1-or-later

View File

@@ -4,9 +4,11 @@
#
################################################################################
UTIL_LINUX_VERSION_MAJOR = 2.35
UTIL_LINUX_VERSION_MINOR = 1
UTIL_LINUX_VERSION = $(UTIL_LINUX_VERSION_MAJOR).$(UTIL_LINUX_VERSION_MINOR)
# When making changes to this file, please check if
# util-linux-libs/util-linux-libs.mk needs to be updated accordingly as well.
UTIL_LINUX_VERSION_MAJOR = 2.36
UTIL_LINUX_VERSION = $(UTIL_LINUX_VERSION_MAJOR)
UTIL_LINUX_SOURCE = util-linux-$(UTIL_LINUX_VERSION).tar.xz
UTIL_LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/util-linux/v$(UTIL_LINUX_VERSION_MAJOR)
@@ -22,18 +24,15 @@ UTIL_LINUX_LICENSE_FILES = README.licensing \
Documentation/licenses/COPYING.LGPL-2.1-or-later
UTIL_LINUX_INSTALL_STAGING = YES
UTIL_LINUX_DEPENDENCIES = host-pkgconf $(TARGET_NLS_DEPENDENCIES)
UTIL_LINUX_DEPENDENCIES = \
host-pkgconf \
$(if $(BR2_PACKAGE_UTIL_LINUX_LIBS),util-linux-libs) \
$(TARGET_NLS_DEPENDENCIES)
UTIL_LINUX_CONF_OPTS += \
--disable-rpath \
--disable-makeinstall-chown
UTIL_LINUX_LIBS = $(TARGET_NLS_LIBS)
# system depends on util-linux so we enable systemd support
# (which needs systemd to be installed)
UTIL_LINUX_CONF_OPTS += \
--without-systemd \
--with-systemdsystemunitdir=no
UTIL_LINUX_LINK_LIBS = $(TARGET_NLS_LIBS)
HOST_UTIL_LINUX_DEPENDENCIES = host-pkgconf
@@ -43,6 +42,10 @@ HOST_UTIL_LINUX_CONF_OPTS = \
--with-systemdsystemunitdir=no \
--without-python
ifneq ($(BR2_PACKAGE_UTIL_LINUX_BINARIES)$(BR2_PACKAGE_UTIL_LINUX_CRAMFS)$(BR2_PACKAGE_UTIL_LINUX_FSCK)$(BR2_PACKAGE_UTIL_LINUX_LOSETUP),)
UTIL_LINUX_SELINUX_MODULES = fstools
endif
# Prevent the installation from attempting to move shared libraries from
# ${usrlib_execdir} (/usr/lib) to ${libdir} (/lib), since both paths are
# the same when merged usr is in use.
@@ -50,6 +53,20 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
UTIL_LINUX_CONF_OPTS += --bindir=/usr/bin --sbindir=/usr/sbin --libdir=/usr/lib
endif
ifeq ($(BR2_PACKAGE_SYSTEMD),y)
UTIL_LINUX_CONF_OPTS += --with-systemd --with-systemdsystemunitdir=/usr/lib/systemd/system
UTIL_LINUX_DEPENDENCIES += systemd
else
UTIL_LINUX_CONF_OPTS += --without-systemd --with-systemdsystemunitdir=no
endif
ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
UTIL_LINUX_CONF_OPTS += --with-udev
UTIL_LINUX_DEPENDENCIES += udev
else
UTIL_LINUX_CONF_OPTS += --without-udev
endif
ifeq ($(BR2_PACKAGE_NCURSES),y)
UTIL_LINUX_DEPENDENCIES += ncurses
ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
@@ -68,16 +85,12 @@ endif
UTIL_LINUX_CONF_OPTS += --without-ncursesw --without-ncurses
endif
ifeq ($(BR2_PACKAGE_LIBCAP_NG),y)
UTIL_LINUX_DEPENDENCIES += libcap-ng
endif
# Unfortunately, the util-linux does LIBS="" at the end of its
# configure script. So we have to pass the proper LIBS value when
# calling the configure script to make configure tests pass properly,
# and then pass it again at build time.
UTIL_LINUX_CONF_ENV += LIBS="$(UTIL_LINUX_LIBS)"
UTIL_LINUX_MAKE_OPTS += LIBS="$(UTIL_LINUX_LIBS)"
UTIL_LINUX_CONF_ENV += LIBS="$(UTIL_LINUX_LINK_LIBS)"
UTIL_LINUX_MAKE_OPTS += LIBS="$(UTIL_LINUX_LINK_LIBS)"
ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
UTIL_LINUX_DEPENDENCIES += libselinux
@@ -92,6 +105,9 @@ define UTIL_LINUX_SELINUX_PAMFILES_TWEAK
endef
endif
# Used by setpriv
UTIL_LINUX_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBCAP_NG),libcap-ng)
# Used by cramfs utils
UTIL_LINUX_DEPENDENCIES += $(if $(BR2_PACKAGE_ZLIB),zlib)
@@ -172,6 +188,7 @@ HOST_UTIL_LINUX_CONF_OPTS += \
--enable-libblkid \
--enable-libmount \
--enable-libuuid \
--without-libmagic \
--without-ncurses \
--without-ncursesw \
--without-tinfo
@@ -228,7 +245,7 @@ endif
ifeq ($(BR2_PACKAGE_READLINE),y)
UTIL_LINUX_CONF_OPTS += --with-readline
UTIL_LINUX_LIBS += $(if $(BR2_STATIC_LIBS),-lcurses)
UTIL_LINUX_LINK_LIBS += $(if $(BR2_STATIC_LIBS),-lcurses)
UTIL_LINUX_DEPENDENCIES += readline
else
UTIL_LINUX_CONF_OPTS += --without-readline
@@ -241,6 +258,13 @@ else
UTIL_LINUX_CONF_OPTS += --without-audit
endif
ifeq ($(BR2_PACKAGE_FILE),y)
UTIL_LINUX_CONF_OPTS += --with-libmagic
UTIL_LINUX_DEPENDENCIES += file
else
UTIL_LINUX_CONF_OPTS += --without-libmagic
endif
# Install PAM configuration files
ifeq ($(BR2_PACKAGE_UTIL_LINUX_SU)$(BR2_PACKAGE_LINUX_PAM),yy)
define UTIL_LINUX_INSTALL_PAMFILES
@@ -266,3 +290,7 @@ UTIL_LINUX_POST_INSTALL_TARGET_HOOKS += UTIL_LINUX_GETTY_SYMLINK
$(eval $(autotools-package))
$(eval $(host-autotools-package))
# Must be included after the autotools-package call, to make sure all variables
# are available
include package/util-linux/util-linux-libs/util-linux-libs.mk