From 02c29713e636d105e63fe2286fdd673a57573eea Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Thu, 15 Dec 2016 20:53:53 +0000 Subject: util-linux: update to 2.29 --- .../0001-chrt-default-to-SCHED_RR-policy.patch | 39 ++++ ...rser-for-proc-pid-stat-which-is-including.patch | 79 ++++++++ .../0001-sfdisk-cleanup-dump-error-messages.patch | 44 ++++ ...t-be-silent-when-list-non-existing-device.patch | 70 +++++++ .../0001-sfdisk-support-empty-label-use-case.patch | 223 +++++++++++++++++++++ abs/core/util-linux/PKGBUILD | 39 +++- 6 files changed, 488 insertions(+), 6 deletions(-) create mode 100644 abs/core/util-linux/0001-chrt-default-to-SCHED_RR-policy.patch create mode 100644 abs/core/util-linux/0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch create mode 100644 abs/core/util-linux/0001-sfdisk-cleanup-dump-error-messages.patch create mode 100644 abs/core/util-linux/0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch create mode 100644 abs/core/util-linux/0001-sfdisk-support-empty-label-use-case.patch diff --git a/abs/core/util-linux/0001-chrt-default-to-SCHED_RR-policy.patch b/abs/core/util-linux/0001-chrt-default-to-SCHED_RR-policy.patch new file mode 100644 index 0000000..c442149 --- /dev/null +++ b/abs/core/util-linux/0001-chrt-default-to-SCHED_RR-policy.patch @@ -0,0 +1,39 @@ +From c7adc2f204f19167f781fa2ee739e0ca386fc4f5 Mon Sep 17 00:00:00 2001 +From: Andreas Henriksson +Date: Fri, 2 Dec 2016 15:10:18 +0100 +Subject: [PATCH] chrt: default to SCHED_RR policy + +This fixes a regression introduced in: + +commit 7a4ea5664edba98bff28adec3a9c3cfb5763a495 +"chrt: add control struct" + +Previously (and as documented in the manpage) the default policy +was SCHED_RR. Now it's implicitly SCHED_OTHER (0) as the value +is not initialized explicitly anymore. + +Test-command: chrt 90 echo hello + +Reported-by: Patrick Pelissier +Addresses: http://bugs.debian.org/846572 +Signed-off-by: Andreas Henriksson +--- + schedutils/chrt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/schedutils/chrt.c b/schedutils/chrt.c +index a861d9f..73d1ffa 100644 +--- a/schedutils/chrt.c ++++ b/schedutils/chrt.c +@@ -409,7 +409,7 @@ static void set_sched(struct chrt_ctl *ctl) + + int main(int argc, char **argv) + { +- struct chrt_ctl _ctl = { .pid = -1 }, *ctl = &_ctl; ++ struct chrt_ctl _ctl = { .pid = -1, .policy = SCHED_RR }, *ctl = &_ctl; + int c; + + static const struct option longopts[] = { +-- +2.10.2 + diff --git a/abs/core/util-linux/0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch b/abs/core/util-linux/0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch new file mode 100644 index 0000000..b13f189 --- /dev/null +++ b/abs/core/util-linux/0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch @@ -0,0 +1,79 @@ +From 3fcbd7978980dc1a29c626b701333e27599e506d Mon Sep 17 00:00:00 2001 +From: OGAWA Hirofumi +Date: Wed, 23 Nov 2016 14:13:34 +0900 +Subject: [PATCH] lsns: Fix parser for /proc//stat which is including + space in comm + +For example, child process of spamd has + + 32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ... + +fscanf("%d %*s %c %d*[^\n]") in read_process() can't parse above as we +expected, because %s only skips non-whitespace. I.e. it parses like +following, + + 32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ... + +---+ +----+ + + %d %*s %c + +and returns 2 (pid=32031, state=c). + +This fixes it by skipping task->comm part manually. + +Signed-off-by: OGAWA Hirofumi +--- + sys-utils/lsns.c | 30 ++++++++++++++++++++++++++---- + 1 file changed, 26 insertions(+), 4 deletions(-) + +diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c +index e4fd208..809737c 100644 +--- a/sys-utils/lsns.c ++++ b/sys-utils/lsns.c +@@ -217,6 +217,30 @@ static int get_ns_ino(int dir, const char *nsname, ino_t *ino) + return 0; + } + ++static int parse_proc_stat(FILE *fp, pid_t *pid, char *state, pid_t *ppid) ++{ ++ char *line = NULL, *p; ++ size_t len = 0; ++ int rc; ++ ++ if (getline(&line, &len, fp) < 0) { ++ rc = -errno; ++ goto error; ++ } ++ ++ p = strrchr(line, ')'); ++ if (p == NULL || ++ sscanf(line, "%d (", pid) != 1 || ++ sscanf(p, ") %c %d*[^\n]", state, ppid) != 2) { ++ rc = -EINVAL; ++ goto error; ++ } ++ rc = 0; ++ ++error: ++ free(line); ++ return rc; ++} + + static int read_process(struct lsns *ls, pid_t pid) + { +@@ -255,11 +279,9 @@ static int read_process(struct lsns *ls, pid_t pid) + rc = -errno; + goto done; + } +- rc = fscanf(f, "%d %*s %c %d*[^\n]", &p->pid, &p->state, &p->ppid); +- if (rc != 3) { +- rc = rc < 0 ? -errno : -EINVAL; ++ rc = parse_proc_stat(f, &p->pid, &p->state, &p->ppid); ++ if (rc < 0) + goto done; +- } + rc = 0; + + for (i = 0; i < ARRAY_SIZE(p->ns_ids); i++) { +-- +2.10.2 + diff --git a/abs/core/util-linux/0001-sfdisk-cleanup-dump-error-messages.patch b/abs/core/util-linux/0001-sfdisk-cleanup-dump-error-messages.patch new file mode 100644 index 0000000..918138c --- /dev/null +++ b/abs/core/util-linux/0001-sfdisk-cleanup-dump-error-messages.patch @@ -0,0 +1,44 @@ +From c49b765a6e9031642e2bb846e93dddc6827e4b28 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 30 Nov 2016 10:53:56 +0100 +Subject: [PATCH] sfdisk: cleanup --dump error messages + +old: + # truncate -s 1G empty && ./sfdisk --dump empty + sfdisk: failed to dump partition table: Success + +new: + # truncate -s 1G empty && ./sfdisk --dump empty + sfdisk: empty: does not contain a recognized partition table. + +Addresses: https://github.com/karelzak/util-linux/issues/375 +Signed-off-by: Karel Zak +--- + disk-utils/sfdisk.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index 0f69d65..10307ad 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -950,13 +950,16 @@ static int command_dump(struct sfdisk *sf, int argc, char **argv) + if (rc) + err(EXIT_FAILURE, _("cannot open %s"), devname); + ++ if (!fdisk_has_label(sf->cxt)) ++ errx(EXIT_FAILURE, _("%s: does not contain a recognized partition table"), devname); ++ + dp = fdisk_new_script(sf->cxt); + if (!dp) + err(EXIT_FAILURE, _("failed to allocate dump struct")); + + rc = fdisk_script_read_context(dp, NULL); + if (rc) +- err(EXIT_FAILURE, _("failed to dump partition table")); ++ errx(EXIT_FAILURE, _("%s: failed to dump partition table"), devname); + + if (sf->json) + fdisk_script_enable_json(dp, 1); +-- +2.10.2 + diff --git a/abs/core/util-linux/0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch b/abs/core/util-linux/0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch new file mode 100644 index 0000000..4b088bb --- /dev/null +++ b/abs/core/util-linux/0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch @@ -0,0 +1,70 @@ +From fed304837f60b626f6198663990e76e506f89063 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 29 Nov 2016 15:58:18 +0100 +Subject: [PATCH] sfdisk: don't be silent when list non-existing device + +Addresses: https://github.com/karelzak/util-linux/issues/376 +Signed-off-by: Karel Zak +--- + disk-utils/sfdisk.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index 52f2a6d..0f69d65 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -560,6 +560,7 @@ static int write_changes(struct sfdisk *sf) + */ + static int command_list_partitions(struct sfdisk *sf, int argc, char **argv) + { ++ int fail = 0; + fdisk_enable_listonly(sf->cxt, 1); + + if (argc) { +@@ -568,13 +569,14 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv) + for (i = 0; i < argc; i++) { + if (ct) + fputs("\n\n", stdout); +- if (print_device_pt(sf->cxt, argv[i], 0, sf->verify) == 0) +- ct++; ++ if (print_device_pt(sf->cxt, argv[i], 1, sf->verify) != 0) ++ fail++; ++ ct++; + } + } else + print_all_devices_pt(sf->cxt, sf->verify); + +- return 0; ++ return fail; + } + + /* +@@ -582,6 +584,7 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv) + */ + static int command_list_freespace(struct sfdisk *sf, int argc, char **argv) + { ++ int fail = 0; + fdisk_enable_listonly(sf->cxt, 1); + + if (argc) { +@@ -590,13 +593,14 @@ static int command_list_freespace(struct sfdisk *sf, int argc, char **argv) + for (i = 0; i < argc; i++) { + if (ct) + fputs("\n\n", stdout); +- if (print_device_freespace(sf->cxt, argv[i], 0) == 0) +- ct++; ++ if (print_device_freespace(sf->cxt, argv[i], 1) != 0) ++ fail++; ++ ct++; + } + } else + print_all_devices_freespace(sf->cxt); + +- return 0; ++ return fail; + } + + /* +-- +2.10.2 + diff --git a/abs/core/util-linux/0001-sfdisk-support-empty-label-use-case.patch b/abs/core/util-linux/0001-sfdisk-support-empty-label-use-case.patch new file mode 100644 index 0000000..29ab44d --- /dev/null +++ b/abs/core/util-linux/0001-sfdisk-support-empty-label-use-case.patch @@ -0,0 +1,223 @@ +From 35ca51182782193f555fbdcb06bb10766550d017 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 30 Nov 2016 12:43:10 +0100 +Subject: [PATCH] sfdisk: support empty label use-case + +By default sfdisk creates partition table when a first partition is +specified, otherwise the device is not modified. This force users to +create at least one partition. + +This commit allows to create empty label without partitions if "label: +" header line is specified by script. + +The commit also modifies "New situation:" output to list label name +and label identifier. + +Addresses: https://github.com/karelzak/util-linux/issues/374 +Signed-off-by: Karel Zak +--- + disk-utils/fdisk-list.c | 23 +++++++++++++++-------- + disk-utils/fdisk-list.h | 1 + + disk-utils/sfdisk.8 | 18 +++++++++++++++++- + disk-utils/sfdisk.c | 17 +++++++++++++++++ + libfdisk/src/libfdisk.h.in | 1 + + libfdisk/src/libfdisk.sym | 5 +++++ + libfdisk/src/script.c | 20 +++++++++++++++++++- + 7 files changed, 75 insertions(+), 10 deletions(-) + +diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c +index e6b2033..c9560f4 100644 +--- a/disk-utils/fdisk-list.c ++++ b/disk-utils/fdisk-list.c +@@ -34,10 +34,23 @@ static int is_ide_cdrom_or_tape(char *device) + return ret; + } + ++void list_disk_identifier(struct fdisk_context *cxt) ++{ ++ struct fdisk_label *lb = fdisk_get_label(cxt, NULL); ++ char *id = NULL; ++ ++ if (fdisk_has_label(cxt)) ++ fdisk_info(cxt, _("Disklabel type: %s"), ++ fdisk_label_get_name(lb)); ++ ++ if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) { ++ fdisk_info(cxt, _("Disk identifier: %s"), id); ++ free(id); ++ } ++} + + void list_disk_geometry(struct fdisk_context *cxt) + { +- char *id = NULL; + struct fdisk_label *lb = fdisk_get_label(cxt, NULL); + uint64_t bytes = fdisk_get_nsectors(cxt) * fdisk_get_sector_size(cxt); + char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE +@@ -71,14 +84,8 @@ void list_disk_geometry(struct fdisk_context *cxt) + if (fdisk_get_alignment_offset(cxt)) + fdisk_info(cxt, _("Alignment offset: %lu bytes"), + fdisk_get_alignment_offset(cxt)); +- if (fdisk_has_label(cxt)) +- fdisk_info(cxt, _("Disklabel type: %s"), +- fdisk_label_get_name(lb)); + +- if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) { +- fdisk_info(cxt, _("Disk identifier: %s"), id); +- free(id); +- } ++ list_disk_identifier(cxt); + } + + void list_disklabel(struct fdisk_context *cxt) +diff --git a/disk-utils/fdisk-list.h b/disk-utils/fdisk-list.h +index eddab92..4ed5c25 100644 +--- a/disk-utils/fdisk-list.h ++++ b/disk-utils/fdisk-list.h +@@ -2,6 +2,7 @@ + #define UTIL_LINUX_FDISK_LIST_H + + extern void list_disklabel(struct fdisk_context *cxt); ++extern void list_disk_identifier(struct fdisk_context *cxt); + extern void list_disk_geometry(struct fdisk_context *cxt); + extern void list_freespace(struct fdisk_context *cxt); + +diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 +index fcde872..efe4a86 100644 +--- a/disk-utils/sfdisk.8 ++++ b/disk-utils/sfdisk.8 +@@ -212,7 +212,10 @@ Deprecated option. Only the sector unit is supported. + .BR \-X , " \-\-label " \fItype + Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option + is not given, then \fBsfdisk\fR defaults to the existing label, but if there +-is no label on the device yet, then the type defaults to \fBdos\fR. ++is no label on the device yet, then the type defaults to \fBdos\fR. The default ++or the current label may be overwritten by the "label: " script header ++line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty ++disk label (see the \fBEMPTY DISK LABEL\fR section below). + .TP + .BR \-Y , " \-\-label\-nested " \fItype + Force editing of a nested disk label. The primary disk label has to exist already. +@@ -404,6 +407,19 @@ For backward compatibility the \fBId=\fR field has the same meaning. + .RE + .RE + ++.SH "EMPTY DISK LABEL" ++.B sfdisk ++does not create partition table without partitions by default. The lines with ++partitions are expected in the script by default. The empty partition table has ++to be explicitly requested by "label: " script header line without any ++partitions lines. For example: ++.RS ++.sp ++.B "echo 'label: gpt' | sfdisk /dev/sdb" ++.sp ++.RE ++creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature. ++ + .SH "BACKING UP THE PARTITION TABLE" + It is recommended to save the layout of your devices. + .B sfdisk +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index 10307ad..2d65974 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -1766,8 +1766,25 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) + } + } while (1); + ++ /* create empty disk label if label, but no partition specified */ ++ if (rc == SFDISK_DONE_EOF && created == 0 ++ && fdisk_script_has_force_label(dp) == 1 ++ && fdisk_table_get_nents(tb) == 0 ++ && fdisk_script_get_header(dp, "label")) { ++ ++ int xrc = fdisk_apply_script_headers(sf->cxt, dp); ++ created = !xrc; ++ if (xrc) { ++ fdisk_warnx(sf->cxt, _( ++ "Failed to apply script headers, " ++ "disk label not created.")); ++ rc = SFDISK_DONE_ABORT; ++ } ++ } ++ + if (!sf->quiet && rc != SFDISK_DONE_ABORT) { + fdisk_info(sf->cxt, _("\nNew situation:")); ++ list_disk_identifier(sf->cxt); + list_disklabel(sf->cxt); + } + +diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in +index 9154f5b..59cce19 100644 +--- a/libfdisk/src/libfdisk.h.in ++++ b/libfdisk/src/libfdisk.h.in +@@ -642,6 +642,7 @@ const char *fdisk_script_get_header(struct fdisk_script *dp, const char *name); + int fdisk_script_set_header(struct fdisk_script *dp, const char *name, const char *data); + struct fdisk_table *fdisk_script_get_table(struct fdisk_script *dp); + int fdisk_script_get_nlines(struct fdisk_script *dp); ++int fdisk_script_has_force_label(struct fdisk_script *dp); + + int fdisk_script_set_userdata(struct fdisk_script *dp, void *data); + void *fdisk_script_get_userdata(struct fdisk_script *dp); +diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym +index 02cd7a8..d6d4ac5 100644 +--- a/libfdisk/src/libfdisk.sym ++++ b/libfdisk/src/libfdisk.sym +@@ -274,3 +274,8 @@ FDISK_2.29 { + fdisk_labelitem_is_number; + fdisk_gpt_set_npartitions; + } FDISK_2.28; ++ ++ ++FDISK_2.30 { ++ fdisk_script_has_force_label; ++} FDISK_2.29; +diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c +index ae7e99a..0d1f260 100644 +--- a/libfdisk/src/script.c ++++ b/libfdisk/src/script.c +@@ -36,7 +36,8 @@ struct fdisk_script { + size_t nlines; + struct fdisk_label *label; + +- unsigned int json : 1; /* JSON output */ ++ unsigned int json : 1, /* JSON output */ ++ force_label : 1; /* label: specified */ + }; + + +@@ -354,6 +355,22 @@ int fdisk_script_get_nlines(struct fdisk_script *dp) + } + + /** ++ * fdisk_script_has_force_label: ++ * @dp: script ++ * ++ * Note that fdisk_script_set_header(dp, "label", name) does not modify ++ * force_label status. The label has to be specified by script. ++ * ++ * Returns: true if "label: " has been parsed. ++ */ ++int fdisk_script_has_force_label(struct fdisk_script *dp) ++{ ++ assert(dp); ++ return dp->force_label; ++} ++ ++ ++/** + * fdisk_script_read_context: + * @dp: script + * @cxt: context +@@ -706,6 +723,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s) + if (strcmp(name, "label") == 0) { + if (dp->cxt && !fdisk_get_label(dp->cxt, value)) + goto done; /* unknown label name */ ++ dp->force_label = 1; + } else if (strcmp(name, "unit") == 0) { + if (strcmp(value, "sectors") != 0) + goto done; /* only "sectors" supported */ +-- +2.10.2 + diff --git a/abs/core/util-linux/PKGBUILD b/abs/core/util-linux/PKGBUILD index 64faa1a..72df84c 100644 --- a/abs/core/util-linux/PKGBUILD +++ b/abs/core/util-linux/PKGBUILD @@ -5,7 +5,8 @@ pkgbase=util-linux pkgname=(util-linux libutil-linux) -pkgver=2.27.1 +_pkgmajor=2.29 +pkgver=${_pkgmajor} pkgrel=1 pkgdesc="Miscellaneous system utilities for Linux" url="https://www.kernel.org/pub/linux/utils/util-linux/" @@ -14,13 +15,33 @@ makedepends=('systemd' 'python2') license=('GPL2') options=('strip' 'debug') validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284') # Karel Zak -source=("https://www.kernel.org/pub/linux/utils/util-linux/v${pkgver%.?}/$pkgbase-$pkgver.tar."{xz,sign} - pam-{login,common,su}) -md5sums=('3cd2698d1363a2c64091c2dadc974647' +source=("https://www.kernel.org/pub/linux/utils/util-linux/v$_pkgmajor/$pkgbase-$pkgver.tar."{xz,sign} + pam-{login,common,su} + '0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch' + '0001-sfdisk-cleanup-dump-error-messages.patch' + '0001-sfdisk-support-empty-label-use-case.patch' + '0001-chrt-default-to-SCHED_RR-policy.patch' + '0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch') +md5sums=('07b6845f48a421ad5844aa9d58edb837' 'SKIP' '4368b3f98abd8a32662e094c54e7f9b1' 'a31374fef2cba0ca34dfc7078e2969e4' - 'fa85e5cce5d723275b14365ba71a8aad') + 'fa85e5cce5d723275b14365ba71a8aad' + '3fce7192ce1b3d97fdffd0226ed63a90' + '2f3c061865360170cacda948035fd02d' + '6d2e3915124938577f0ff18ef701c87f' + '168c1cb2cfe7d4eddfc6e3f3b19d3ced' + '68c2076a9a09564ba0c9776540a175fa') + +prepare() { + cd "$pkgbase-$pkgver" + + patch -Np1 <../0001-sfdisk-don-t-be-silent-when-list-non-existing-device.patch + patch -Np1 <../0001-sfdisk-cleanup-dump-error-messages.patch + patch -Np1 <../0001-sfdisk-support-empty-label-use-case.patch + patch -Np1 <../0001-chrt-default-to-SCHED_RR-policy.patch + patch -Np1 <../0001-lsns-Fix-parser-for-proc-pid-stat-which-is-including.patch +} build() { cd "$pkgbase-$pkgver" @@ -36,7 +57,7 @@ build() { --enable-chfn-chsh \ --enable-write \ --enable-mesg \ - --enable-libmount-force-mountinfo \ + --disable-tailf \ --with-python=2 make @@ -80,6 +101,12 @@ package_util-linux() { ### runtime libs are shipped as part of libutil-linux rm "$pkgdir"/usr/lib/lib*.{a,so}* + + ### tailf has been deprecated for a while. let's not include it anymore. + rm \ + "$pkgdir"/usr/bin/tailf \ + "$pkgdir"/usr/share/bash-completion/completions/tailf \ + "$pkgdir"/usr/share/man/man1/tailf.1 } package_libutil-linux() { -- cgit v0.12