Commit ec7a696c authored by Andreas Henriksson's avatar Andreas Henriksson

Imported Upstream version 2.28

parents dda60f51 44338f7f
......@@ -309,6 +309,7 @@ CONTRIBUTORS:
J William Piggott <elseifthen@gmx.com>
KaiGai Kohei <kaigai@kaigai.gr.jp>
Kalev Soikonen <ksop@hot.ee>
Kaligule <Code@schauderbasis.de>
Kay Sievers <kay.sievers@vrfy.org>
Kees Cook <kees.cook@canonical.com>
Ken Kopin <kenkopin@gmail.com>
......@@ -474,6 +475,7 @@ CONTRIBUTORS:
Scott Telford <st@epcc.ed.ac.uk>
Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Sebastian Krahmer <krahmer@suse.de>
Sebastian Rasmussen <sebras@gmail.com>
Serge Hallyn <serge.hallyn@ubuntu.com>
Sergei Antonov <saproj@gmail.com>
Sergey Gusarov <laborer2008@gmail.com>
......
See version control history.
http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log;h=2.28-rc2
http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log;h=2.28
......@@ -78,6 +78,7 @@ agetty:
- add support for \e in issue file to print \033 [Karel Zak]
- don't ignore netlink on select() [Karel Zak]
- fix chown(3), chmod(3) and open(3) race [Sami Kerola]
- remove atoi() from argv[] parsing [clang analyze] [Karel Zak]
- support \e{name} for issue file [Karel Zak]
- tweak formatting and some wordings in the man page [Benno Schulenberg]
bash-completion:
......@@ -88,6 +89,7 @@ bash-completion:
- ipcmk add missing completion file [Sami Kerola]
- lslogins add missing completion file [Sami Kerola]
- lsns add missing completion file [Sami Kerola]
- update chrt completion [Sami Kerola]
blkdiscard:
- add --zeroout (BLKZEROOUT ioctl) [Karel Zak]
- don't report "zero range" at the end [Ruediger Meier]
......@@ -101,6 +103,7 @@ blkid, uuidd, uuidgen:
build-sys:
- Properly order install dependencies of pylibmount [Filipe Brandenburger]
- add --disable-ipcrm --disable-ipcs [Ruediger Meier]
- add --disable-logger and --disable-lslogins [Ruediger Meier]
- add and use openat build conditionals [Ruediger Meier]
- add lsns to gitignore [Karel Zak]
- add missing "not found" strings [Ruediger Meier]
......@@ -114,10 +117,12 @@ build-sys:
- disable unused parameter warnings for some test progs [Ruediger Meier]
- fix [g]libtoolize version for OSX [Ruediger Meier]
- fix again UL_SCANF_TYPE_MODIFIER [Ruediger Meier]
- fix cap-ng configure flag handling [Mike Frysinger]
- fix if..endif for *_la_LDFLAGS [Karel Zak]
- fix libtoolize for OSX [Ruediger Meier]
- fix typo [Romain Naour]
- fix typo and more all RT to the same place [Karel Zak]
- happy new year... [Karel Zak]
- ignore vim .swp files [Ruediger Meier]
- improve uuidd and script build conditions [Ruediger Meier]
- install missing bash completions [Ruediger Meier]
......@@ -125,6 +130,7 @@ build-sys:
- portable usage of find command [Ruediger Meier]
- pylibmount, mount context is Linux only [Ruediger Meier]
- release++ (v2.28-rc1) [Karel Zak]
- release++ (v2.28-rc2) [Karel Zak]
- remove AM_CONDITIONAL from UL_CHECK_SYSCALL [Karel Zak]
- remove duplicate cal sources [Ruediger Meier]
- remove libtermcap support [Sami Kerola]
......@@ -147,6 +153,7 @@ chrt:
- add control struct [Karel Zak]
- add support for SCHED_DEADLINE [Karel Zak]
- fix case SCHED_RR [Ruediger Meier]
- make --sched-* short options to require an argument [Sami Kerola]
- make man page more structured [Karel Zak]
- make usage more readable [Karel Zak]
- output function refactoring [Karel Zak]
......@@ -197,6 +204,7 @@ fdisk:
- fix warning, incompatible pointer types passing 'uint64_t *' [Ruediger Meier]
- fix warning, uninitialized variable [Ruediger Meier]
- make 'f' command more verbose [Karel Zak]
- remove dead assignment [clang analyze] [Karel Zak]
- remove unused include sysfs.h [Ruediger Meier]
- sun, undef HAVE_QSORT_R for non-Linux [Ruediger Meier]
- to recognize Intel Rapid Start hibernation partition [Jörg Jenderek]
......@@ -219,6 +227,7 @@ fstrim:
- systemd timer units should be WantedBy=timers.target [Peter Hoeg]
getopt:
- fix -n name for BSD [Ruediger Meier]
- make sure setprogname provided by non-Linux system [Karel Zak]
hexdump:
- certain long options should not accept arguments [Phil Ruffwind]
- fix a typo and tweak some wordings in the manpage [Benno Schulenberg]
......@@ -249,6 +258,7 @@ ipcs:
- --shmems, upward/backward compatibility [Ruediger Meier]
- consolidate output header printing [Ruediger Meier]
- fix ipc_sem_get_limits() [Karel Zak]
- make static analyzer happy [clang analyze] [Karel Zak]
- make sure to parse whole lines for shm_data [Ruediger Meier]
- show gid instead of uid [Hushan Jia]
- ulong -> unsigned long [Ruediger Meier]
......@@ -283,6 +293,7 @@ lib/strutils:
- add more ERANGE messages [Ruediger Meier]
- fix errno usage in strtoint functions [Ruediger Meier]
- parse_size(), sync errno and return value [Ruediger Meier]
- use int for fgetc() [Karel Zak]
lib/strv:
- add strv_extendv() [Karel Zak]
lib/sysfs:
......@@ -301,6 +312,7 @@ libblkid:
- fix compiler warnings [-Wmissing-prototypes] [Ruediger Meier]
- make XFS Log visible for wipefs [Karel Zak]
- make minix prober more robust [Karel Zak]
- revert mmap usage [Karel Zak]
- use internally uint64_t for offsets and sizes [Karel Zak]
- use mmap() rather than read() [Karel Zak]
libblkid,libmount:
......@@ -320,12 +332,14 @@ libfdisk:
- fix compiler warnings [-Wmissing-prototypes] [Ruediger Meier]
- fix missing symbol [Ruediger Meier]
- fix partition move/resize code [Karel Zak]
- fix ref.counting in fdisk_apply_script() [clang analyze] [Karel Zak]
- fix typo [Karel Zak]
- fix warnings, "redundant redeclaration" [-Wredundant-decls] [Ruediger Meier]
- remove ifdef HDIO_GETGEO [Ruediger Meier]
libmount:
- (monitor) don't check for regular mtab [Karel Zak]
- (monitor) remove unnecessary epoll EPOLLPRI [Karel Zak]
- Fix possible NULL dereference in get_btrfs_fs_root() [Karel Zak]
- Typo fix [Stanislav Brabec]
- add 'force-mountinfo' to features list, improve debug [Karel Zak]
- add cgroup2 pseudo FS [Karel Zak]
......@@ -346,6 +360,7 @@ libmount:
- handle btrfs default subvolume mount [Stanislav Brabec]
- improve conversion from root= to the devname [Karel Zak]
- move btrfs subvol code refactoring [Karel Zak]
- result of operation is garbage or undefined [clang analyze] [Karel Zak]
- run btrfs subvol checks for "auto" fs type [Stanislav Brabec]
- run btrfs subvol checks for "subvolid" option [Stanislav Brabec]
- use fstatat(AT_NO_AUTOMOUNT) for mountpoints [Karel Zak]
......@@ -524,14 +539,21 @@ po:
- merge changes [Karel Zak]
- update cs.po (from translationproject.org) [Petr Písař]
- update de.po (from translationproject.org) [Philipp Thomas]
- update es.po (from translationproject.org) [Antonio Ceballos Roa]
- update ja.po (from translationproject.org) [Takeshi Hamasaki]
- update nl.po (from translationproject.org) [Benno Schulenberg]
- update pl.po (from translationproject.org) [Jakub Bogusz]
- update pt_BR.po (from translationproject.org) [Rafael Fontenelle]
- update ru.po (from translationproject.org) [Evgeniy Yakushev]
- update sv.po (from translationproject.org) [Sebastian Rasmussen]
- update uk.po (from translationproject.org) [Yuri Chornoivan]
- update zh_CN.po (from translationproject.org) [Wylmer Wang]
prlimit:
- cleanup output units [Karel Zak]
readprofile:
- add scanf field width limits [cppcheck] [Boris Egorov]
rename:
- add example to the man page [Kaligule]
scols/table_print:
- restore old stream after printing to str [Igor Gnatenko]
script:
......@@ -585,8 +607,10 @@ taskset:
- fix description of `-c` option in the man page [Yuriy M. Kaminskiy]
tests:
- --parallel prints results in a single line [Ruediger Meier]
- add DM error target for blkid [Karel Zak]
- add btrfs mount tests [Stanislav Brabec]
- add colcrt functional tests [Sami Kerola]
- add fdisk/bsd hexdump for alpha [Ruediger Meier]
- add logger tests "id _numbers_ with spaces" [Ruediger Meier]
- add missing files [Karel Zak]
- add new fdisk bsd test [Karel Zak]
......@@ -611,6 +635,7 @@ tests:
- fallback for missing TS_DESC [Karel Zak]
- fix compiler warnings [-Wmissing-prototypes] [Ruediger Meier]
- fix fdisk/bsd for alpha [Ruediger Meier]
- fix fdisk/bsd for hppa [Ruediger Meier]
- fix minix tests for big endian [Ruediger Meier]
- fix non-working udevadm settle for scsi_debug [Ruediger Meier]
- fix redirection [Stanislav Brabec]
......@@ -634,6 +659,7 @@ tests:
- minor cleanup ts_fdisk_clean() [Ruediger Meier]
- mkfs.ext3 image-file needs option -F [Ruediger Meier]
- no more sleep, udevadm settle only [Ruediger Meier]
- remove deprecated md5sum based fdisk/bsd test [Ruediger Meier]
- remove invalid argument in libmount/debug [Ruediger Meier]
- remove redundant check for NULL [cppcheck] [Boris Egorov]
- replace username with tag in logger test [Karel Zak]
......@@ -687,6 +713,7 @@ uuidd:
- use signalfd() and setup_timer() [Sami Kerola]
vipw:
- Remove pre-ANSI compiler support [Romain Naour]
- make tmp_file usage more robust [clang analyze] [Karel Zak]
- print only one new line when asking about shadow file [Sami Kerola]
- use puts() when formatting unnecessary [Karel Zak]
wipefs:
......
util-linux 2.28: Apr 12 2016
* see Documentation/releases/v2.28-ReleaseNotes or the complete changelog at
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-ChangeLog
util-linux 2.28-rc2: Mar 29 2016
* see Documentation/releases/v2.28-ReleaseNotes or the complete changelog at
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-rc2-ChangeLog
......
......@@ -8,31 +8,45 @@ _chrt_module()
'-h'|'--help'|'-V'|'--version')
return 0
;;
'-T'|'--sched-runtime'|'-P'|'--sched-period'|'-D'|'--sched-deadline')
COMPREPLY=( $(compgen -W "nanoseconds" -- $cur) )
return 0
;;
esac
# FIXME: -p is ambiguous, it takes either pid or priority as an
# argument depending on whether user wanted to get or set the
# values. Perhaps the command interface should be reconsidered.
case $cur in
-*)
OPTS="--batch
--fifo
--idle
--other
--rr
--reset-on-fork
OPTS="
--all-tasks
--batch
--deadline
--fifo
--help
--idle
--max
--other
--pid
--reset-on-fork
--rr
--sched-deadline
--sched-period
--sched-runtime
--verbose
--version"
--version
"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
local PIDS
PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
local i
for i in ${COMP_WORDS[*]}; do
case $i in
'-p'|'--pid')
COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
return 0
;;
esac
done
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _chrt_module chrt
......@@ -376,6 +376,9 @@
/* Define to 1 if you have the `setns' function. */
#undef HAVE_SETNS
/* Define to 1 if you have the `setprogname' function. */
#undef HAVE_SETPROGNAME
/* Define to 1 if you have the `setresgid' function. */
#undef HAVE_SETRESGID
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for util-linux 2.28-rc2.
# Generated by GNU Autoconf 2.69 for util-linux 2.28.
#
# Report bugs to <kzak@redhat.com>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='util-linux'
PACKAGE_TARNAME='util-linux'
PACKAGE_VERSION='2.28-rc2'
PACKAGE_STRING='util-linux 2.28-rc2'
PACKAGE_VERSION='2.28'
PACKAGE_STRING='util-linux 2.28'
PACKAGE_BUGREPORT='kzak@redhat.com'
PACKAGE_URL='http://www.kernel.org/pub/linux/utils/util-linux/'
......@@ -1239,8 +1239,10 @@ enable_bfs
enable_minix
enable_fdformat
enable_hwclock
enable_lslogins
enable_wdctl
enable_cal
enable_logger
enable_switch_root
enable_pivot_root
enable_ipcrm
......@@ -1870,7 +1872,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures util-linux 2.28-rc2 to adapt to many kinds of systems.
\`configure' configures util-linux 2.28 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1940,7 +1942,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of util-linux 2.28-rc2:";;
short | recursive ) echo "Configuration of util-linux 2.28:";;
esac
cat <<\_ACEOF
......@@ -1998,8 +2000,10 @@ Optional Features:
--disable-minix do not build fsck.minix, mkfs.minix
--disable-fdformat do not build fdformat
--disable-hwclock do not build hwclock
--disable-lslogins do not build lslogins
--disable-wdctl do not build wdctl
--disable-cal do not build cal
--disable-logger do not build logger
--disable-switch_root do not build switch_root
--disable-pivot_root do not build pivot_root
--disable-ipcrm do not build ipcrm
......@@ -2085,7 +2089,7 @@ Optional Packages:
--without-tinfo compile without libtinfo
--with-readline compile with GNU Readline support
--with-utempter compile script(1) with libutempter
--without-capng compile without libcap-ng
--without-cap-ng compile without libcap-ng
--without-libz compile without libz
--without-user compile without libuser (remote chsh)
--with-btrfs build with support for btrfs
......@@ -2228,7 +2232,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
util-linux configure 2.28-rc2
util-linux configure 2.28
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2754,7 +2758,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by util-linux $as_me 2.28-rc2, which was
It was created by util-linux $as_me 2.28, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -4993,7 +4997,7 @@ fi
# Define the identity of the package.
PACKAGE='util-linux'
VERSION='2.28-rc2'
VERSION='2.28'
cat >>confdefs.h <<_ACEOF
......@@ -5352,7 +5356,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{print $3}' \
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
LIBBLKID_DATE="29-Mar-2015"
LIBBLKID_DATE="12-Apr-2016"
LIBBLKID_LT_MAJOR=1
LIBBLKID_LT_MINOR=1
LIBBLKID_LT_MICRO=0
......@@ -17759,6 +17763,7 @@ for ac_func in \
qsort_r \
rpmatch \
scandirat \
setprogname \
setresgid \
setresuid \
sched_setattr \
......@@ -22503,7 +22508,17 @@ else
fi
if test "x$with_cap_ng" = xno; then :
if false; then
HAVE_CAP_NG_TRUE=
HAVE_CAP_NG_FALSE='#'
else
HAVE_CAP_NG_TRUE='#'
HAVE_CAP_NG_FALSE=
fi
have_cap_ng=no
else
......@@ -23535,18 +23550,27 @@ fi
# Check whether --enable-lslogins was given.
if test "${enable_lslogins+set}" = set; then :
enableval=$enable_lslogins;
else
if test "x$ul_default_estate" != x; then
enable_lslogins=$ul_default_estate
build_lslogins=yes
if test "x$ul_default_estate" = xno; then
build_lslogins=no
enable_lslogins=$ul_default_estate
else
enable_lslogins=check
fi
else
build_lslogins=yes
enable_lslogins=check
fi
if test "x$enable_lslogins" = xno; then
build_lslogins=no
else
build_lslogins=yes
fi
......@@ -23910,19 +23934,27 @@ else
fi
# Check whether --enable-logger was given.
if test "${enable_logger+set}" = set; then :
enableval=$enable_logger;
else
if test "x$ul_default_estate" != x; then
enable_logger=$ul_default_estate
build_logger=yes
if test "x$ul_default_estate" = xno; then
build_logger=no
enable_logger=$ul_default_estate
else
enable_logger=check
fi
else
build_logger=yes
enable_logger=yes
fi
if test "x$enable_logger" = xno; then
build_logger=no
else
build_logger=yes
fi
if test "x$build_logger" = xyes; then
......@@ -29161,6 +29193,10 @@ if test -z "${HAVE_CAP_NG_TRUE}" && test -z "${HAVE_CAP_NG_FALSE}"; then
as_fn_error $? "conditional \"HAVE_CAP_NG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_CAP_NG_TRUE}" && test -z "${HAVE_CAP_NG_FALSE}"; then
as_fn_error $? "conditional \"HAVE_CAP_NG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${BUILD_SETPRIV_TRUE}" && test -z "${BUILD_SETPRIV_FALSE}"; then
as_fn_error $? "conditional \"BUILD_SETPRIV\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
......@@ -29922,7 +29958,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by util-linux $as_me 2.28-rc2, which was
This file was extended by util-linux $as_me 2.28, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -29989,7 +30025,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
util-linux config.status 2.28-rc2
util-linux config.status 2.28
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -30,7 +30,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{print $3}' \
dnl libblkid version
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
LIBBLKID_DATE="29-Mar-2015"
LIBBLKID_DATE="12-Apr-2016"
LIBBLKID_LT_MAJOR=1
LIBBLKID_LT_MINOR=1
LIBBLKID_LT_MICRO=0
......@@ -380,6 +380,7 @@ AC_CHECK_FUNCS([ \
qsort_r \
rpmatch \
scandirat \
setprogname \
setresgid \
setresuid \
sched_setattr \
......@@ -1185,10 +1186,13 @@ AC_CHECK_FUNCS([setns])
AC_ARG_WITH([cap_ng],
AS_HELP_STRING([--without-capng], [compile without libcap-ng]),
AS_HELP_STRING([--without-cap-ng], [compile without libcap-ng]),
[], [with_cap_ng=auto]
)
AS_IF([test "x$with_cap_ng" = xno], [have_cap_ng=no],[
AS_IF([test "x$with_cap_ng" = xno], [
AM_CONDITIONAL([HAVE_CAP_NG], [false])
have_cap_ng=no
],[
UL_CHECK_LIB([cap-ng], [capng_apply], [cap_ng])
])
......@@ -1318,7 +1322,11 @@ UL_REQUIRES_HAVE([lscpu], [cpu_set_t], [cpu_set_t type])
AM_CONDITIONAL([BUILD_LSCPU], [test "x$build_lscpu" = xyes])
UL_BUILD_INIT([lslogins], [check])
AC_ARG_ENABLE([lslogins],
AS_HELP_STRING([--disable-lslogins], [do not build lslogins]),
[], [UL_DEFAULT_ENABLE([lslogins], [check])]
)
UL_BUILD_INIT([lslogins])
UL_REQUIRES_BUILD([lslogins], [libsmartcols])
UL_REQUIRES_HAVE([lslogins], [shadow_h], [shadow.h header])
UL_REQUIRES_HAVE([lslogins], [utmp_h], [utmp.h header])
......@@ -1361,8 +1369,11 @@ AC_ARG_ENABLE([cal],
UL_BUILD_INIT([cal])
AM_CONDITIONAL([BUILD_CAL], [test "x$build_cal" = xyes])
UL_BUILD_INIT([logger], [yes])
AC_ARG_ENABLE([logger],
AS_HELP_STRING([--disable-logger], [do not build logger]),
[], [UL_DEFAULT_ENABLE([logger], [check])]
)
UL_BUILD_INIT([logger])
AM_CONDITIONAL([BUILD_LOGGER], [test "x$build_logger" = xyes])
UL_BUILD_INIT([look], [yes])
......
......@@ -797,7 +797,6 @@ static int dos_menu_cb(struct fdisk_context **cxt0,
fdisk_info(cxt, _("Leaving nested disklabel."));
fdisk_unref_context(cxt);
cxt = *cxt0;
}
break;
}
......
......@@ -883,7 +883,7 @@ const char *split(const char **state, size_t *l, const char *separator, int quot
/* Rewind file pointer forward to new line. */
int skip_fline(FILE *fp)
{
char ch;
int ch;
do {
if ((ch = fgetc(fp)) == EOF)
......
......@@ -31,7 +31,7 @@ extern "C" {
#endif
#define BLKID_VERSION "2.28."
#define BLKID_DATE "29-Mar-2015"
#define BLKID_DATE "12-Apr-2016"
/**
* blkid_dev:
......
......@@ -180,7 +180,6 @@ struct blkid_struct_probe
int fd; /* device file descriptor */
uint64_t off; /* begin of data on the device */
uint64_t size; /* end of data on the device */
size_t mmap_granularity; /* minimal size of mmaped buffer (PAGE_SIZE) */
dev_t devno; /* device number (st.st_rdev) */
dev_t disk_devno; /* devno of the whole-disk or 0 */
......
......@@ -104,7 +104,6 @@
#include <stdint.h>
#include <stdarg.h>
#include <limits.h>
#include <sys/mman.h>
#ifdef HAVE_LIBUUID
# include <uuid.h>
......@@ -581,85 +580,6 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[
return 0;
}
/* align to mmap granularity */
#define PROBE_ALIGN_OFF(p, o) ((o) & ~((p)->mmap_granularity - 1ULL))
/* default buffer sizes */
#define PROBE_MMAP_BEGINSIZ (1024ULL * 1024ULL * 2ULL) /* begin of the device */
#define PROBE_MMAP_ENDSIZ (1024ULL * 1024ULL * 2ULL) /* end of the device */
#define PROBE_MMAP_MIDSIZ (1024ULL * 1024ULL) /* middle of the device */
#define probe_is_mmap_wanted(p) (!S_ISCHR((p)->mode))
static struct blkid_bufinfo *mmap_buffer(blkid_probe pr, uint64_t real_off, uint64_t len)
{
uint64_t map_len;
uint64_t map_off = 0;
struct blkid_bufinfo *bf = NULL;
/*
* libblkid heavily reads begin and end of the device, so it seems
* better to mmap ~2MiB from the begin and end of the device to reduces
* number of syscalls and necessary buffers. For random accees
* somewhere in the middle of the device we use 1MiB buffers.
*/
if (!pr->mmap_granularity)
pr->mmap_granularity = getpagesize();
/* begin of the device */
if (real_off == 0 || real_off + len < PROBE_MMAP_BEGINSIZ) {
DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %"PRIu64")", pr->size));
map_off = 0;
map_len = PROBE_MMAP_BEGINSIZ > pr->size ? pr->size : PROBE_MMAP_BEGINSIZ;
/* end of the device */
} else if (real_off > pr->off + pr->size - PROBE_MMAP_ENDSIZ) {
DBG(BUFFER, ul_debug("\tmapping end of the device (probing area: "
"off=%"PRIu64", size=%"PRIu64")", pr->off, pr->size));
map_off = PROBE_ALIGN_OFF(pr, pr->off + pr->size - PROBE_MMAP_ENDSIZ);
map_len = pr->off + pr->size - map_off;
/* middle of the device */
} else {
uint64_t minlen;
map_off = PROBE_ALIGN_OFF(pr, real_off);
minlen = real_off + len - map_off;
map_len = minlen > PROBE_MMAP_MIDSIZ ? minlen : PROBE_MMAP_MIDSIZ;
if (map_off + map_len > pr->off + pr->size)
map_len = pr->size - map_off;
}
assert(map_off <= real_off);
assert(map_off + map_len >= real_off + len);
/* allocate buffer handler */
bf = malloc(sizeof(*bf));
if (!bf) {
errno = ENOMEM;
return NULL;
}
/* mmap into memmory */
bf->data = mmap(NULL, map_len, PROT_READ, MAP_SHARED, pr->fd, map_off);
if (bf->data == MAP_FAILED) {
DBG(BUFFER, ul_debug("\tmmap failed: %m"));
free(bf);
return NULL;
}
bf->off = map_off;
bf->len = map_len;
INIT_LIST_HEAD(&bf->bufs);
DBG(BUFFER, ul_debug("\tmmap %p: off=%"PRIu64", len=%"PRIu64" (%"PRIu64" pages)",
bf->data, map_off, map_len, map_len / pr->mmap_granularity));
return bf;
}
static struct blkid_bufinfo *read_buffer(blkid_probe pr, uint64_t real_off, uint64_t len)
{
ssize_t ret;
......@@ -759,10 +679,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len
/* not found; read from disk */
if (!bf) {
if (probe_is_mmap_wanted(pr))
bf = mmap_buffer(pr, real_off, len);
else
bf = read_buffer(pr, real_off, len);
bf = read_buffer(pr, real_off, len);
if (!bf)
return NULL;
......@@ -794,13 +711,10 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
DBG(BUFFER, ul_debug(" remove buffer: %p [off=%"PRIu64", len=%"PRIu64"]",
bf->data, bf->off, bf->len));
if (probe_is_mmap_wanted(pr))
munmap(bf->data, bf->len);
free(bf);
}
DBG(LOWPROBE, ul_debug(" buffers summary: %"PRIu64" bytes by %"PRIu64" read/mmap() calls",
DBG(LOWPROBE, ul_debug(" buffers summary: %"PRIu64" bytes by %"PRIu64" read() calls",
len, ct));
INIT_LIST_HEAD(&pr->buffers);
......
......@@ -1270,10 +1270,13 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
* @cxt: context
* @dp: script (or NULL to remove previous reference)
*
* Sets reference to the @dp script. The script headers might be used by label
* drivers to overwrite built-in defaults (for example disk label Id) and label
* driver might optimize the default semantic to be more usable for scripts
* (for example to not ask for primary/logical/extended partition type).
* Sets reference to the @dp script and remove reference to the previously used
* script.
*
* The script headers might be used by label drivers to overwrite
* built-in defaults (for example disk label Id) and label driver might
* optimize the default semantic to be more usable for scripts (for example to
* not ask for primary/logical/extended partition type).
*