util-linux: update to version 2.28

The following patches were merged upstream:
* 0001-switch_root-improve-statfs-f_type-portability.patch
* 0002-lib-colors-use-static-buffers-when-parse-scheme.patch
* 002-mkostemp.patch

The following patch is not needed any more because all libc
implementations support alloc in sscanf:
* 001-no-printf-alloc.patch

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 49191
This commit is contained in:
Hauke Mehrtens 2016-04-17 15:16:12 +00:00
parent 8a7b28071f
commit 91a508d5bf
6 changed files with 45 additions and 333 deletions

View file

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=util-linux
PKG_VERSION:=2.25.2
PKG_RELEASE:=4
PKG_VERSION:=2.28
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.25
PKG_MD5SUM:=cab3d7be354000f629bc601238b629b3
PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.28
PKG_MD5SUM:=e534e6ccc49107e5d31c329af798ef7d
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING getopt/COPYING libblkid/COPYING libmount/COPYING Documentation/licenses/COPYING.GPLv2 Documentation/licenses/COPYING.LGPLv2.1 libuuid/COPYING Documentation/licenses/COPYING.BSD-3
@ -41,6 +41,7 @@ CONFIGURE_ARGS += \
--disable-sulogin \
--without-python \
--without-udev \
--without-readline \
$(if $(CONFIG_PACKAGE_cal)$(CONFIG_PACKAGE_cfdisk)$(CONFIG_PACKAGE_setterm),--with-ncurses,--without-ncurses)
TARGET_CFLAGS += $(FPIC) -std=gnu99
@ -53,12 +54,15 @@ define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/libblkid/blkid.pc $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/libfdisk/fdisk.pc $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/libmount/mount.pc $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/libsmartcols/smartcols.pc $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/libuuid/uuid.pc $(1)/usr/lib/pkgconfig
$(INSTALL_DIR) $(1)/usr/include/blkid
$(CP) $(PKG_BUILD_DIR)/libblkid/src/blkid.h $(1)/usr/include/blkid
$(INSTALL_DIR) $(1)/usr/include/fdisk
$(CP) $(PKG_BUILD_DIR)/libfdisk/src/libfdisk.h $(1)/usr/include/fdisk
$(INSTALL_DIR) $(1)/usr/include/libmount
$(CP) $(PKG_BUILD_DIR)/libmount/src/libmount.h $(1)/usr/include/libmount
$(INSTALL_DIR) $(1)/usr/include/uuid
@ -68,6 +72,7 @@ define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libblkid.{a,so*} $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libfdisk.{a,so*} $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libmount.{a,so*} $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libuuid.{a,so*} $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libsmartcols.{a,so*} $(1)/usr/lib
@ -88,6 +93,18 @@ define Package/libblkid/description
identifiers/serial numbers...
endef
define Package/libfdisk
$(call Package/util-linux/Default)
DEPENDS:=+libuuid +libblkid
TITLE:=partition manipulating library
SECTION:=libs
CATEGORY:=Libraries
endef
define Package/libfdisk/description
The libfdisk library is used for manipulating with partition tables.
endef
define Package/libmount
$(call Package/util-linux/Default)
DEPENDS:=+libblkid
@ -174,7 +191,7 @@ endef
define Package/cfdisk
$(call Package/util-linux/Default)
TITLE:=display or manipulate disk partition table
DEPENDS:= +libblkid +libncurses +libsmartcols
DEPENDS:= +libblkid +libncurses +libsmartcols +libfdisk +libmount
SUBMENU:=disc
endef
@ -195,7 +212,7 @@ endef
define Package/fdisk
$(call Package/util-linux/Default)
TITLE:=manipulate disk partition table
DEPENDS:= +libblkid +libsmartcols
DEPENDS:= +libblkid +libsmartcols +libfdisk
SUBMENU=disc
endef
@ -449,6 +466,11 @@ define Package/wipefs/description
libblkid.
endef
define Package/libfdisk/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libfdisk.so* $(1)/usr/lib/
endef
define Package/libblkid/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libblkid.so* $(1)/usr/lib/
@ -626,6 +648,7 @@ define Package/wipefs/install
endef
$(eval $(call BuildPackage,libblkid))
$(eval $(call BuildPackage,libfdisk))
$(eval $(call BuildPackage,libmount))
$(eval $(call BuildPackage,libsmartcols))
$(eval $(call BuildPackage,libuuid))

View file

@ -1,49 +0,0 @@
From 8f806bb1ea30f15db7ca36d1cfa79349f8115302 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 6 Nov 2014 12:50:27 +0100
Subject: [PATCH] switch_root: improve statfs->f_type portability
__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).
Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/statfs_magic.h | 11 +++++++++++
sys-utils/switch_root.c | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
--- a/include/statfs_magic.h
+++ b/include/statfs_magic.h
@@ -1,6 +1,17 @@
#ifndef UTIL_LINUX_STATFS_MAGIC_H
#define UTIL_LINUX_STATFS_MAGIC_H
+#include <sys/statfs.h>
+
+/*
+ * If possible then don't depend on internal libc __SWORD_TYPE type.
+ */
+#ifdef __GNUC__
+typedef __typeof__( ((struct statfs *)0)->f_type ) ul_statfs_ftype_t;
+#else
+typedef __SWORD_TYPE ul_statfs_ftype_t;
+#endif
+
/*
* Unfortunately, Linux kernel hedeader file <linux/magic.h> is incomplete
* mess and kernel returns by statfs f_type many numbers that are nowhere
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -181,8 +181,8 @@ static int switchroot(const char *newroo
if (pid <= 0) {
struct statfs stfs;
if (fstatfs(cfd, &stfs) == 0 &&
- (stfs.f_type == (__SWORD_TYPE)STATFS_RAMFS_MAGIC ||
- stfs.f_type == (__SWORD_TYPE)STATFS_TMPFS_MAGIC))
+ (stfs.f_type == (ul_statfs_ftype_t) STATFS_RAMFS_MAGIC ||
+ stfs.f_type == (ul_statfs_ftype_t) STATFS_TMPFS_MAGIC))
recursiveRemove(cfd);
else
warn(_("old root filesystem is not an initramfs"));

View file

@ -1,126 +0,0 @@
From 6508db29ded734ac4ff5e5e19486c143c9eb3d89 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 21 Nov 2014 12:23:47 +0100
Subject: [PATCH] lib/colors: use static buffers when parse scheme
* use static buffers when parse scheme colors
* cleanup deallocation on error in sequence parser
Signed-off-by: Karel Zak <kzak@redhat.com>
---
This is modified upstream patch.
--- a/lib/colors.c
+++ b/lib/colors.c
@@ -416,28 +416,31 @@ static int colors_add_scheme(struct ul_c
char *name,
char *seq0)
{
- struct ul_color_scheme *cs;
- char *seq;
+ struct ul_color_scheme *cs = NULL;
+ char *seq = NULL;
int rc;
if (!cc || !name || !*name || !seq0 || !*seq0)
return -EINVAL;
rc = cn_sequence(seq0, &seq);
- free(seq0);
if (rc)
return rc;
+ rc = -ENOMEM;
+
/* convert logical name (e.g. "red") to real ESC code */
if (isalpha(*seq)) {
const char *s = color_sequence_from_colorname(seq);
char *p;
- if (!s)
- return -EINVAL;
+ if (!s) {
+ rc = -EINVAL;
+ goto err;
+ }
p = strdup(s);
if (!p)
- return -ENOMEM;
+ goto err;
free(seq);
seq = p;
}
@@ -447,17 +450,28 @@ static int colors_add_scheme(struct ul_c
void *tmp = realloc(cc->schemes, (cc->nschemes + 10)
* sizeof(struct ul_color_scheme));
if (!tmp)
- return -ENOMEM;
+ goto err;
cc->schemes = tmp;
cc->schemes_sz = cc->nschemes + 10;
}
/* add a new item */
- cs = &cc->schemes[cc->nschemes++];
- cs->name = name;
+ cs = &cc->schemes[cc->nschemes];
cs->seq = seq;
+ cs->name = strdup(name);
+ if (!cs->name)
+ goto err;
+ cc->nschemes++;
return 0;
+err:
+ if (cs) {
+ free(cs->seq);
+ free(cs->name);
+ cs->seq = cs->name = NULL;
+ } else
+ free(seq);
+ return rc;
}
/*
@@ -543,7 +557,8 @@ static int colors_read_schemes(struct ul
{
int rc = 0;
FILE *f = NULL;
- char buf[BUFSIZ];
+ char buf[BUFSIZ],
+ cn[129], seq[129];
if (!cc->configured)
rc = colors_read_configuration(cc);
@@ -560,7 +575,6 @@ static int colors_read_schemes(struct ul
}
while (fgets(buf, sizeof(buf), f)) {
- char *cn = NULL, *seq = NULL;
char *p = strchr(buf, '\n');
if (!p) {
@@ -576,17 +590,14 @@ static int colors_read_schemes(struct ul
if (*p == '\0' || *p == '#')
continue;
- rc = sscanf(p, UL_SCNsA" " /* name */
- UL_SCNsA, /* color */
- &cn, &seq);
- if (rc == 2 && cn && seq)
+ rc = sscanf(p, "%128[^ ] %128[^\n ]", cn, seq);
+ if (rc == 2 && *cn && *seq) {
rc = colors_add_scheme(cc, cn, seq); /* set rc=0 on success */
- if (rc) {
- free(cn);
- free(seq);
+ if (rc)
+ goto done;
}
- rc = 0;
}
+ rc = 0;
done:
if (f)

View file

@ -1,104 +0,0 @@
--- a/configure.ac
+++ b/configure.ac
@@ -798,7 +798,6 @@ AC_ARG_ENABLE([libmount],
)
UL_BUILD_INIT([libmount])
UL_REQUIRES_BUILD([libmount], [libblkid])
-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes])
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -22,6 +22,10 @@
#include "pathnames.h"
#include "strutils.h"
+#ifndef HAVE_SCANF_MS_MODIFIER
+# define UL_SCNsA "%s"
+#endif
+
static int next_number(char **s, int *num)
{
char *end = NULL;
@@ -52,16 +56,31 @@ static int mnt_parse_table_line(struct l
int rc, n = 0, xrc;
char *src = NULL, *fstype = NULL, *optstr = NULL;
+#ifndef HAVE_SCANF_MS_MODIFIER
+ size_t len = strlen(s) + 1;
+ src = malloc(len);
+ fstype = malloc(len);
+ fs->target = malloc(len);
+ optstr = malloc(len);
+#endif
+
rc = sscanf(s, UL_SCNsA" " /* (1) source */
UL_SCNsA" " /* (2) target */
UL_SCNsA" " /* (3) FS type */
UL_SCNsA" " /* (4) options */
"%n", /* byte count */
+#ifdef HAVE_SCANF_MS_MODIFIER
&src,
&fs->target,
&fstype,
&optstr,
+#else
+ src,
+ fs->target,
+ fstype,
+ optstr,
+#endif
&n);
xrc = rc;
@@ -127,6 +146,16 @@ static int mnt_parse_mountinfo_line(stru
unsigned int maj, min;
char *fstype = NULL, *src = NULL, *p;
+#ifndef HAVE_SCANF_MS_MODIFIER
+ size_t len = strlen(s) + 1;
+ fs->root = malloc(len);
+ fs->target = malloc(len);
+ fs->vfs_optstr = malloc(len);
+ fs->fs_optstr = malloc(len);
+ fstype = malloc(len);
+ src = malloc(len);
+#endif
+
rc = sscanf(s, "%d " /* (1) id */
"%d " /* (2) parent */
"%u:%u " /* (3) maj:min */
@@ -138,9 +167,15 @@ static int mnt_parse_mountinfo_line(stru
&fs->id,
&fs->parent,
&maj, &min,
+#ifdef HAVE_SCANF_MS_MODIFIER
&fs->root,
&fs->target,
&fs->vfs_optstr,
+#else
+ fs->root,
+ fs->target,
+ fs->vfs_optstr,
+#endif
&end);
if (rc >= 7 && end > 0)
@@ -160,9 +195,15 @@ static int mnt_parse_mountinfo_line(stru
UL_SCNsA" " /* (9) source */
UL_SCNsA, /* (10) fs options (fs specific) */
+#ifdef HAVE_SCANF_MS_MODIFIER
&fstype,
&src,
&fs->fs_optstr);
+#else
+ fstype,
+ src,
+ fs->fs_optstr);
+#endif
if (rc >= 10) {
size_t sz;

View file

@ -1,46 +0,0 @@
Support older hosts with latest util-linux-native
mkostemp is not defined on older machines. So we detect this and
provide a define that uses mkstemp instead.
O_CLOEXEC is not defined on older machines. It is however defined
in the 'c.h' header. Fix up the users to include 'c.h'.
fdisks/fdisksunlabel.c was modified to use qsort_r, however
this is not defined on older hosts. Revert:
commit c69bbca9c1f6645097bd20fe3a21f5a99a2a0698
fdisk: (sun): use ask API, remove global variable
Upstream-Status: Inappropriate [other]
Patches revert upstream changes in order to support older
machines.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,7 @@ AC_CHECK_FUNCS([ \
llseek \
lseek64 \
mempcpy \
+ mkostemp \
nanosleep \
open_memstream \
personality \
--- a/include/c.h
+++ b/include/c.h
@@ -233,6 +233,13 @@ static inline int dirfd(DIR *d)
#endif
/*
+ * mkostemp replacement
+ */
+#ifndef HAVE_MKOSTEMP
+#define mkostemp(template, flags) mkstemp(template)
+#endif
+
+/*
* MAXHOSTNAMELEN replacement
*/
static inline size_t get_hostname_max(void)

View file

@ -10,7 +10,7 @@
endif # BUILD_LIBUUID
--- a/configure.ac
+++ b/configure.ac
@@ -1802,15 +1802,19 @@ AC_CONFIG_HEADERS([config.h])
@@ -2122,18 +2122,23 @@ AC_CONFIG_HEADERS([config.h])
#
AC_CONFIG_FILES([
Makefile
@ -18,6 +18,10 @@
libblkid/docs/Makefile
libblkid/docs/version.xml
libblkid/src/blkid.h
+libfdisk/fdisk.pc
libfdisk/docs/Makefile
libfdisk/docs/version.xml
libfdisk/src/libfdisk.h
+libmount/mount.pc
libmount/docs/Makefile
libmount/docs/version.xml
@ -52,7 +56,7 @@
endif # BUILD_LIBMOUNT
--- a/libsmartcols/Makemodule.am
+++ b/libsmartcols/Makemodule.am
@@ -8,7 +8,6 @@ SUBDIRS += libsmartcols/docs
@@ -9,7 +9,6 @@ SUBDIRS += libsmartcols/docs
endif
pkgconfig_DATA += libsmartcols/smartcols.pc
@ -60,3 +64,13 @@
EXTRA_DIST += libsmartcols/COPYING
endif # BUILD_LIBSMARTCOLS
--- a/libfdisk/Makemodule.am
+++ b/libfdisk/Makemodule.am
@@ -8,7 +8,6 @@ SUBDIRS += libfdisk/docs
endif
pkgconfig_DATA += libfdisk/fdisk.pc
-PATHFILES += libfdisk/fdisk.pc
EXTRA_DIST += libfdisk/COPYING
endif # BUILD_LIBFDISK