linux-qubasis

linux oasis port as a qubes template

git clone https://9o.is/git/linux-qubasis.git

commit 838e12a3ff559dd675175ffb5a13bbe3c56759bc
parent 6c931c06fd2e034878a1db5ffb922ef837aea84d
Author: Jul <jul@9o.is>
Date:   Mon,  8 Sep 2025 16:27:22 +0800

add util-linux

Diffstat:
M.gitmodules | 4++++
Mgen.sh | 2++
Mninja/functions.sh | 29+++++++++++++++++------------
Mninja/rules.ninja | 6+++++-
Apkg/probe/HAVE__THREAD_LOCAL | 5+++++
Apkg/probe/gen.sh | 7+++++++
Apkg/util-linux/config.h | 320+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/fdisk.8 | 294+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/gen.sh | 276+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/losetup.8 | 240+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0001-Don-t-omit-second-operand-to-operator.patch | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0002-Avoid-a-few-unnecessary-statement-expressions.patch | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0003-Don-t-use-min-to-determine-if-dflt-is-non-zero.patch | 36++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0004-Remove-need-for-VLA-for-label-name.patch | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0005-Avoid-statement-expressions-min-max.patch | 285+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0006-Avoid-initialization-of-flexible-array-in-struct.patch | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0007-Use-MAXIMUM_PARTS-instead-of-VLA.patch | 28++++++++++++++++++++++++++++
Apkg/util-linux/patch/0008-Use-alloca-if-VLAs-aren-t-supported.patch | 28++++++++++++++++++++++++++++
Apkg/util-linux/patch/0009-Use-static-inline-function-for-cmp_numbers.patch | 37+++++++++++++++++++++++++++++++++++++
Apkg/util-linux/patch/0010-Avoid-use-of-long-double.patch | 44++++++++++++++++++++++++++++++++++++++++++++
Apkg/util-linux/repo | 1+
21 files changed, 1959 insertions(+), 13 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -66,3 +66,7 @@ path = pkg/pax/repo url = https://git.sr.ht/~mcf/pax ignore = all +[submodule "util-linux"] + path = pkg/util-linux/repo + url = https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git + ignore = all diff --git a/gen.sh b/gen.sh @@ -28,7 +28,9 @@ subgen pkg/mandoc subgen pkg/netbsd-curses subgen pkg/oksh subgen pkg/pax +subgen pkg/probe subgen pkg/sbase +subgen pkg/util-linux subgen pkg/zlib subgen pkg/zstd diff --git a/ninja/functions.sh b/ninja/functions.sh @@ -29,7 +29,9 @@ rule() { build() { _v1=$1; shift _v2=$1; shift - printf 'build %s: %s %s\n' "$_v2" "$_v1" "$*" >> "$_ninja_writepath" + _vs= + for _v in $*; do _vs="$_vs $_v"; done + printf 'build %s: %s %s\n' "$_v2" "$_v1" "$_vs" >> "$_ninja_writepath" } cflags() { @@ -510,15 +512,6 @@ _ninja_flush_fetch() { error unknown fetch method $1 ;; esac - - if [ -d "$_ninja_dir"/patch ]; then - _outs= - for _v in "$_ninja_dir"/patch/*.patch; do - _out=$_fetchdir/${_v##*/} - _outs="$_outs $_out" - build patch $_out ${_v#"$_ninja_dir"/} '|' $_fetchdir/fetched $_outs - done - fi } _ninja_flush_build() { @@ -577,10 +570,22 @@ _ninja_flush_sync() { build phony $tgtdir/sync $_subgens ;; pkg) - build phony $tgtdir/sync $outdir/_fetch/fetched $_subgens + _patches= + _fetchdir=$outdir/_fetch + + if [ -d "$_ninja_dir"/patch ]; then + for _v in "$_ninja_dir"/patch/*.patch; do + _out=$_fetchdir/${_v##*/} + _in=$dir/${_v#"$_ninja_dir"/} + build patch $_out $_in '|' $_fetchdir/fetched $_patches + _patches="$_patches $_out" + done + fi + + build phony $tgtdir/sync $outdir/_fetch/fetched $_patches $_subgens if [ "$_ninja_buffer_sync" ]; then _ninja_dedup _ninja_buffer_sync $_ninja_buffer_sync - build phony "$_ninja_buffer_sync" $outdir/_fetch/fetched + build phony "$_ninja_buffer_sync" $outdir/_fetch/fetched $_patches fi ;; esac diff --git a/ninja/rules.ninja b/ninja/rules.ninja @@ -90,9 +90,13 @@ rule extract-deflate description = EXTRACT/DEFLATE $srcdir rule patch - command = git -C $srcdir am --3way --keep-non-patch --no-gpg-sign --whitespace=nowarn $PWD/$in && touch $out + command = git -C $srcdir am --3way --keep-non-patch --no-gpg-sign --whitespace=nowarn ../../../$in >/dev/null && touch $out description = PATCH $in rule sed command = sed $expr $in >$out description = SED $out + +rule probe + command = if $cc $cflags $ldflags -x c -o /dev/null $in 2>$out.log; then echo '#define $var 1'; fi >$out + description = PROBE $var diff --git a/pkg/probe/HAVE__THREAD_LOCAL b/pkg/probe/HAVE__THREAD_LOCAL @@ -0,0 +1,5 @@ +_Thread_local int x; +int main(void) { + return x; +} + diff --git a/pkg/probe/gen.sh b/pkg/probe/gen.sh @@ -0,0 +1,7 @@ + +probe() { + build probe $outdir/$1 $dir/$1 + bind var $1 +} + +probe HAVE__THREAD_LOCAL diff --git a/pkg/util-linux/config.h b/pkg/util-linux/config.h @@ -0,0 +1,320 @@ +#define _PATH_RUNSTATEDIR "/run" +#define LOCALEDIR "/share/locale" + +/* #undef AC_APPLE_UNIVERSAL_BUILD */ +#define AGETTY_RELOAD 1 +#define CHFN_CHSH_PASSWORD 1 +#define CONFIG_ADJTIME_PATH "/etc/adjtime" +/* #undef CRYPTSETUP_VIA_DLOPEN */ +/* #undef ENABLE_NLS */ +#define FS_SEARCH_PATH "/bin" +/* #undef HAVE_ASM_IO_H */ +#define HAVE_BTRFS_SUPPORT 1 +#define HAVE_BYTESWAP_H 1 +/* #undef HAVE_CFLOCALECOPYCURRENT */ +/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ +#define HAVE_CLEARENV 1 +#define HAVE_CLOCK_GETTIME 1 +/* #undef HAVE_CLOSE_RANGE */ +#define HAVE_CPU_SET_T 1 +/* #undef HAVE_CRYPTSETUP */ +/* #undef HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY */ +#define HAVE_CRYPT_H 1 +/* #undef HAVE_DCGETTEXT */ +#define HAVE_DECL_BLK_ZONE_REP_CAPACITY 1 +#define HAVE_DECL_CPU_ALLOC 1 +/* #undef HAVE_DECL_DIRFD */ +/* #undef HAVE_DECL_TZNAME */ +#define HAVE_DECL__NL_TIME_WEEK_1STDAY 0 +#define HAVE_DIRFD 1 +/* #undef HAVE_DIR_DD_FD */ +#define HAVE_DLFCN_H 1 +#define HAVE_EACCESS 1 +#define HAVE_ENDIAN_H 1 +#define HAVE_ENVIRON_DECL 1 +#define HAVE_ERR 1 +#define HAVE_ERRNO_H 1 +#define HAVE_ERRX 1 +#define HAVE_ERR_H 1 +#define HAVE_EXPLICIT_BZERO 1 +/* #undef HAVE_FALLOCATE */ +#define HAVE_FCNTL_H 1 +#define HAVE_FPURGE 1 +#define HAVE_FSEEKO 1 +#define HAVE_FSTATAT 1 +#define HAVE_FSYNC 1 +#define HAVE_FUTIMENS 1 +#define HAVE_GETDOMAINNAME 1 +#define HAVE_GETDTABLESIZE 1 +/* #undef HAVE_GETEXECNAME */ +/* #undef HAVE_GETMNTINFO */ +#define HAVE_GETOPT_H 1 +#define HAVE_GETRANDOM 1 +#define HAVE_GETRLIMIT 1 +/* #undef HAVE_GETSGNAM */ +/* #undef HAVE_GETTEXT */ +#define HAVE_GETUSERSHELL 1 +#define HAVE_ICONV 1 +#define HAVE_INOTIFY_INIT 1 +#define HAVE_INOTIFY_INIT1 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_IOPERM 1 +#define HAVE_IOPL 1 +/* #undef HAVE_ISNAN */ +#define HAVE_JRAND48 1 +/* #undef HAVE_LANGINFO_ALTMON */ +#define HAVE_LANGINFO_H 1 +/* #undef HAVE_LANGINFO_NL_ABALTMON */ +#define HAVE_LASTLOG_H 1 +#define HAVE_LCHOWN 1 +/* #undef HAVE_LIBAUDIT */ +#define HAVE_LIBBLKID 1 +/* #undef HAVE_LIBCAP_NG */ +/* #undef HAVE_LIBCRYPT */ +/* #undef HAVE_LIBECONF */ +/* #undef HAVE_LIBMOUNT */ +/* #undef HAVE_LIBNCURSES */ +/* #undef HAVE_LIBNCURSESW */ +/* #undef HAVE_LIBREADLINE */ +/* #undef HAVE_LIBRTAS */ +/* #undef HAVE_LIBSELINUX */ +/* #undef HAVE_LIBSYSTEMD */ +/* #undef HAVE_LIBTINFO */ +/* #undef HAVE_LIBUDEV */ +/* #undef HAVE_LIBUSER */ +/* #undef HAVE_LIBUTEMPTER */ +#define HAVE_LIBUTIL 1 +/* #undef HAVE_LIBUTIL_H */ +#define HAVE_LIBUUID 1 +#define HAVE_LINUX_BLKPG_H 1 +#define HAVE_LINUX_BLKZONED_H 1 +#define HAVE_LINUX_BTRFS_H 1 +#define HAVE_LINUX_CAPABILITY_H 1 +#define HAVE_LINUX_CDROM_H 1 +/* #undef HAVE_LINUX_COMPILER_H */ +#define HAVE_LINUX_FALLOC_H 1 +#define HAVE_LINUX_FD_H 1 +#define HAVE_LINUX_FIEMAP_H 1 +#define HAVE_LINUX_FS_H 1 +#define HAVE_LINUX_GSMMUX_H 1 +#define HAVE_LINUX_MAJOR_H 1 +#define HAVE_LINUX_NET_NAMESPACE_H 1 +#define HAVE_LINUX_NSFS_H 1 +/* #undef HAVE_LINUX_RAW_H */ +#define HAVE_LINUX_SECUREBITS_H 1 +#define HAVE_LINUX_TIOCL_H 1 +#define HAVE_LINUX_VERSION_H 1 +#define HAVE_LINUX_WATCHDOG_H 1 +/* #undef HAVE_LLSEEK */ +#define HAVE_LOCALE_H 1 +/* #undef HAVE_LOFF_T */ +/* #undef HAVE_MAGIC */ +#define HAVE_MEMORY_H 1 +#define HAVE_MEMPCPY 1 +#define HAVE_MKOSTEMP 1 +#define HAVE_MNTENT_H 1 +#define HAVE_NANOSLEEP 1 +/* #undef HAVE_NCURSESW_NCURSES_H */ +/* #undef HAVE_NCURSESW_TERM_H */ +/* #undef HAVE_NCURSES_H */ +/* #undef HAVE_NCURSES_NCURSES_H */ +/* #undef HAVE_NCURSES_TERM_H */ +#define HAVE_NETINET_IN_H 1 +/* #undef HAVE_NET_IF_DL_H */ +#define HAVE_NET_IF_H 1 +/* #undef HAVE_NTP_GETTIME */ +#define HAVE_OPENAT 1 +#define HAVE_OPEN_MEMSTREAM 1 +#define HAVE_PATHS_H 1 +/* #undef HAVE_PCRE2_POSIX */ +#define HAVE_PERSONALITY 1 +/* #undef HAVE_PIDFD_OPEN */ +/* #undef HAVE_PIDFD_SEND_SIGNAL */ +#define HAVE_POSIX_FADVISE 1 +/* #undef HAVE_POSIX_FALLOCATE */ +#define HAVE_PRCTL 1 +/* #undef HAVE_PRLIMIT */ +#define HAVE_PROGRAM_INVOCATION_SHORT_NAME 1 +#define HAVE_PTY 1 +#define HAVE_PTY_H 1 +#define HAVE_QSORT_R 1 +#define HAVE_REBOOT 1 +/* #undef HAVE_RESIZETERM */ +/* #undef HAVE_RPMATCH */ +/* #undef HAVE_SA_LEN */ +/* #undef HAVE_SCANDIRAT */ +/* #undef HAVE_SCHED_SETATTR */ +#define HAVE_SCHED_SETSCHEDULER 1 +#define HAVE_SECURE_GETENV 1 +/* #undef HAVE_SECURITY_GET_INITIAL_CONTEXT */ +/* #undef HAVE_SECURITY_OPENPAM_H */ +/* #undef HAVE_SECURITY_PAM_APPL_H */ +/* #undef HAVE_SECURITY_PAM_MISC_H */ +#define HAVE_SENDFILE 1 +/* #undef HAVE_SETITIMER */ +#define HAVE_SETNS 1 +/* #undef HAVE_SETPROGNAME */ +#define HAVE_SETRESGID 1 +#define HAVE_SETRESUID 1 +#define HAVE_SHADOW_H 1 +#define HAVE_SIGHANDLER_T 1 +#define HAVE_SIGQUEUE 1 +/* #undef HAVE_SLANG_H */ +/* #undef HAVE_SLANG_SLANG_H */ +/* #undef HAVE_SLANG_SLCURSES_H */ +/* #undef HAVE_SLCURSES_H */ +/* #undef HAVE_SMACK */ +#define HAVE_SRANDOM 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_EXT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +/* #undef HAVE_STRNCHR */ +#define HAVE_STRNDUP 1 +#define HAVE_STRNLEN 1 +#define HAVE_STRSIGNAL_DECL 1 +#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 +#define HAVE_STRUCT_TERMIOS_C_LINE 1 +#define HAVE_STRUCT_TM_TM_ZONE 1 +#define HAVE_SWAPOFF 1 +#define HAVE_SWAPON 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSINFO 1 +/* #undef HAVE_SYS_DISKLABEL_H */ +/* #undef HAVE_SYS_DISK_H */ +/* #undef HAVE_SYS_ENDIAN_H */ +#define HAVE_SYS_FILE_H 1 +/* #undef HAVE_SYS_IOCCOM_H */ +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_IO_H 1 +/* #undef HAVE_SYS_MKDEV_H */ +#define HAVE_SYS_MOUNT_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_PRCTL_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SENDFILE_H 1 +#define HAVE_SYS_SIGNALFD_H 1 +#define HAVE_SYS_SOCKET_H 1 +/* #undef HAVE_SYS_SOCKIO_H */ +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_SWAP_H 1 +#define HAVE_SYS_SYSCALL_H 1 +#define HAVE_SYS_SYSMACROS_H 1 +#define HAVE_SYS_TIMEX_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TTYDEFAULTS_H 1 +#define HAVE_SYS_TYPES_H 1 +/* #undef HAVE_SYS_UCRED_H */ +#define HAVE_SYS_UN_H 1 +#define HAVE_SYS_XATTR_H 1 +/* #undef HAVE_TERM_H */ +#define HAVE_TIMEGM 1 +#define HAVE_TIMER_CREATE 1 +#ifdef HAVE__THREAD_LOCAL +# define HAVE_TLS 1 +#endif +#define HAVE_TM_GMTOFF 1 +#define HAVE_TM_ZONE 1 +/* #undef HAVE_TZNAME */ +/* #undef HAVE_UNION_SEMUN */ +#define HAVE_UNISTD_H 1 +#define HAVE_UNLINKAT 1 +#define HAVE_UNSHARE 1 +#define HAVE_UPDWTMPX 1 +/* #undef HAVE_USE_DEFAULT_COLORS */ +#define HAVE_USLEEP 1 +#define HAVE_UTIMENSAT 1 +#define HAVE_UTMPX_H 1 +#define HAVE_UTMP_H 1 +/* #undef HAVE_UUIDD */ +#define HAVE_VWARNX 1 +#define HAVE_WARN 1 +#define HAVE_WARNX 1 +#define HAVE_WIDECHAR 1 +#define HAVE___FPENDING 1 +#define HAVE___FPURGE 1 +#define HAVE___PROGNAME 1 +/* #undef HAVE___SECURE_GETENV */ +#define LIBBLKID_DATE "01-Jun-2021" +#define LIBBLKID_VERSION "2.37.0" +#define LIBFDISK_VERSION "2.37.0" +#define LIBMOUNT_VERSION "2.37.0" +#define LIBSMARTCOLS_VERSION "2.37.0" +/* #undef LOGIN_CHOWN_VCS */ +/* #undef LOGIN_STAT_MAIL */ +#define LT_OBJDIR ".libs/" +/* #undef MULTIARCHTRIPLET */ +/* #undef NDEBUG */ +#define ONLY_LISTED_SHELLS 1 +#define PACKAGE "util-linux" +#define PACKAGE_BUGREPORT "kzak@redhat.com" +#define PACKAGE_NAME "util-linux" +#define PACKAGE_STRING "util-linux 2.37" +#define PACKAGE_TARNAME "util-linux" +#define PACKAGE_URL "http://www.kernel.org/pub/linux/utils/util-linux/" +#define PACKAGE_VERSION "2.37" +#define PG_BELL 1 +#define STDC_HEADERS 1 +/* #undef SYS_close_range */ +/* #undef SYS_fallocate */ +/* #undef SYS_ioprio_get */ +/* #undef SYS_ioprio_set */ +/* #undef SYS_pidfd_open */ +/* #undef SYS_pidfd_send_signal */ +/* #undef SYS_pivot_root */ +/* #undef SYS_prlimit64 */ +/* #undef SYS_sched_getaffinity */ +/* #undef SYS_sched_setattr */ +/* #undef SYS_setns */ +/* #undef SYS_swapoff */ +/* #undef SYS_swapon */ +/* #undef SYS_unshare */ +/* #undef TM_IN_SYS_TIME */ +#define USE_COLORS_BY_DEFAULT 1 +/* #undef USE_HWCLOCK_CMOS */ +#define USE_HWCLOCK_GPLv3_DATETIME 1 +/* #undef USE_LIBMOUNT_SUPPORT_MTAB */ +#define USE_LIBMOUNT_SUPPORT_NAMESPACES 1 +#define USE_PLYMOUTH_SUPPORT 1 +/* #undef USE_SULOGIN_EMERGENCY_MOUNT */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif +#define USE_TTY_GROUP 1 +/* #undef USE_USRDIR_PATHS_ONLY */ +/* #undef USE_VENDORDIR */ +#define VERSION "2.37" +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif +/* #undef _DARWIN_C_SOURCE */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif +/* #undef _FILE_OFFSET_BITS */ +/* #undef _LARGEFILE_SOURCE */ +/* #undef _LARGE_FILES */ +/* #undef _MINIX */ +/* #undef _POSIX_1_SOURCE */ +/* #undef _POSIX_SOURCE */ +/* #undef const */ +/* #undef volatile */ diff --git a/pkg/util-linux/fdisk.8 b/pkg/util-linux/fdisk.8 @@ -0,0 +1,294 @@ +'\" t +.\" Title: fdisk +.\" Author: [see the "AUTHOR(S)" section] +.\" Generator: Asciidoctor 2.0.15 +.\" Date: 2021-06-01 +.\" Manual: System Administration +.\" Source: util-linux {release-version} +.\" Language: English +.\" +.TH "FDISK" "8" "2021-06-01" "util\-linux {release\-version}" "System Administration" +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.ss \n[.ss] 0 +.nh +.ad l +.de URL +\fI\\$2\fP <\\$1>\\$3 +.. +.als MTO URL +.if \n[.g] \{\ +. mso www.tmac +. am URL +. ad l +. . +. am MTO +. ad l +. . +. LINKSTYLE blue R < > +.\} +.SH "NAME" +fdisk \- manipulate disk partition table +.SH "SYNOPSIS" +.sp +\fBfdisk\fP [options] \fIdevice\fP +.sp +\fBfdisk\fP \fB\-l\fP [\fIdevice\fP...] +.SH "DESCRIPTION" +.sp +\fBfdisk\fP is a dialog\-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables. +.sp +Block devices can be divided into one or more logical disks called \fIpartitions\fP. This division is recorded in the \fIpartition table\fP, usually found in sector 0 of the disk. (In the BSD world one talks about `disk slices\(aq and a `disklabel\(aq.) +.sp +All partitioning is driven by device I/O limits (the topology) by default. \fBfdisk\fP is able to optimize the disk layout for a 4K\-sector size and use an alignment offset on modern devices for MBR and GPT. It is always a good idea to follow \fBfdisk\fP\(aqs defaults as the default values (e.g., first and last partition sectors) and partition sizes specified by the +/\-<size>{M,G,...} notation are always aligned according to the device properties. +.sp +CHS (Cylinder\-Head\-Sector) addressing is deprecated and not used by default. Please, do not follow old articles and recommendations with \fBfdisk \-S <n> \-H <n>\fP advices for SSD or 4K\-sector devices. +.sp +Note that \fBpartx\fP(8) provides a rich interface for scripts to print disk layouts, \fBfdisk\fP is mostly designed for humans. Backward compatibility in the output of \fBfdisk\fP is not guaranteed. The input (the commands) should always be backward compatible. +.SH "OPTIONS" +.sp +\fB\-b\fP, \fB\-\-sector\-size\fP \fIsectorsize\fP +.RS 4 +Specify the sector size of the disk. Valid values are 512, 1024, 2048, and 4096. (Recent kernels know the sector size. Use this option only on old kernels or to override the kernel\(cqs ideas.) Since util\-linux\-2.17, \fBfdisk\fP differentiates between logical and physical sector size. This option changes both sector sizes to \fIsectorsize\fP. +.RE +.sp +\fB\-B\fP, \fB\-\-protect\-boot\fP +.RS 4 +Don\(cqt erase the beginning of the first disk sector when creating a new disk label. This feature is supported for GPT and MBR. +.RE +.sp +\fB\-c\fP, \fB\-\-compatibility\fP[=\fImode\fP] +.RS 4 +Specify the compatibility mode, \(aqdos\(aq or \(aqnondos\(aq. The default is non\-DOS mode. For backward compatibility, it is possible to use the option without the \fImode\fP argument \(em then the default is used. Note that the optional \fImode\fP argument cannot be separated from the \fB\-c\fP option by a space, the correct form is for example \fB\-c\fP=\fIdos\fP. +.RE +.sp +\fB\-h\fP, \fB\-\-help\fP +.RS 4 +Display a help text and exit. +.RE +.sp +\fB\-L\fP, \fB\-\-color\fP[=\fIwhen\fP] +.RS 4 +Colorize the output. The optional argument \fIwhen\fP can be \fBauto\fP, \fBnever\fP or \fBalways\fP. If the \fIwhen\fP argument is omitted, it defaults to \fBauto\fP. The colors can be disabled; for the current built\-in default see the \fB\-\-help\fP output. See also the \fBCOLORS\fP section. +.RE +.sp +\fB\-l\fP, \fB\-\-list\fP +.RS 4 +List the partition tables for the specified devices and then exit. +.sp +If no devices are given, the devices mentioned in \fI/proc/partitions\fP (if this file exists) are used. Devices are always listed in the order in which they are specified on the command\-line, or by the kernel listed in \fI/proc/partitions\fP. +.RE +.sp +\fB\-x\fP, \fB\-\-list\-details\fP +.RS 4 +Like \fB\-\-list\fP, but provides more details. +.RE +.sp +\fB\-\-lock\fP[=\fImode\fP] +.RS 4 +Use exclusive BSD lock for device or file it operates. The optional argument \fImode\fP can be \fByes\fP, \fBno\fP (or 1 and 0) or \fBnonblock\fP. If the \fImode\fP argument is omitted, it defaults to \fB"yes"\fP. This option overwrites environment variable \fB$LOCK_BLOCK_DEVICE\fP. The default is not to use any lock at all, but it\(cqs recommended to avoid collisions with udevd or other tools. +.RE +.sp +\fB\-n\fP, \fB\-\-noauto\-pt\fP +.RS 4 +Don\(cqt automatically create a default partition table on empty device. The partition table has to be explicitly created by user (by command like \(aqo\(aq, \(aqg\(aq, etc.). +.RE +.sp +\fB\-o\fP, \fB\-\-output\fP \fIlist\fP +.RS 4 +Specify which output columns to print. Use \fB\-\-help\fP to get a list of all supported columns. +.sp +The default list of columns may be extended if \fIlist\fP is specified in the format \fI+list\fP (e.g., \fB\-o +UUID\fP). +.RE +.sp +\fB\-s\fP, \fB\-\-getsz\fP +.RS 4 +Print the size in 512\-byte sectors of each given block device. This option is DEPRECATED in favour of \fBblockdev\fP(8). +.RE +.sp +\fB\-t\fP, \fB\-\-type\fP \fItype\fP +.RS 4 +Enable support only for disklabels of the specified \fItype\fP, and disable support for all other types. +.RE +.sp +\fB\-u\fP, \fB\-\-units\fP[=\fIunit\fP] +.RS 4 +When listing partition tables, show sizes in \(aqsectors\(aq or in \(aqcylinders\(aq. The default is to show sizes in sectors. For backward compatibility, it is possible to use the option without the \fIunit\fP argument \(em then the default is used. Note that the optional \fIunit\fP argument cannot be separated from the \fB\-u\fP option by a space, the correct form is for example \(aq*\-u=*\fIcylinders\fP\(aq. +.RE +.sp +\fB\-C\fP, \fB\-\-cylinders\fP \fInumber\fP +.RS 4 +Specify the number of cylinders of the disk. I have no idea why anybody would want to do so. +.RE +.sp +\fB\-H\fP, \fB\-\-heads\fP \fInumber\fP +.RS 4 +Specify the number of heads of the disk. (Not the physical number, of course, but the number used for partition tables.) Reasonable values are 255 and 16. +.RE +.sp +\fB\-S\fP, \fB\-\-sectors\fP \fInumber\fP +.RS 4 +Specify the number of sectors per track of the disk. (Not the physical number, of course, but the number used for partition tables.) A reasonable value is 63. +.RE +.sp +\fB\-w\fP, \fB\-\-wipe\fP \fIwhen\fP +.RS 4 +Wipe filesystem, RAID and partition\-table signatures from the device, in order to avoid possible collisions. The argument \fIwhen\fP can be \fBauto\fP, \fBnever\fP or \fBalways\fP. When this option is not given, the default is \fBauto\fP, in which case signatures are wiped only when in interactive mode. In all cases detected signatures are reported by warning messages before a new partition table is created. See also \fBwipefs\fP(8) command. +.RE +.sp +\fB\-W\fP, \fB\-\-wipe\-partitions\fP \fIwhen\fP +.RS 4 +Wipe filesystem, RAID and partition\-table signatures from a newly created partitions, in order to avoid possible collisions. The argument \fIwhen\fP can be \fBauto\fP, \fBnever\fP or \fBalways\fP. When this option is not given, the default is \fBauto\fP, in which case signatures are wiped only when in interactive mode and after confirmation by user. In all cases detected signatures are reported by warning messages before a new partition is created. See also \fBwipefs\fP(8) command. +.RE +.sp +\fB\-V\fP, \fB\-\-version\fP +.RS 4 +Display version information and exit. +.RE +.SH "DEVICES" +.sp +The \fIdevice\fP is usually \fI/dev/sda\fP, \fI/dev/sdb\fP or so. A device name refers to the entire disk. Old systems without libata (a library used inside the Linux kernel to support ATA host controllers and devices) make a difference between IDE and SCSI disks. In such cases the device name will be \fI/dev/hd*\fP (IDE) or \fI/dev/sd*\fP (SCSI). +.sp +The \fIpartition\fP is a device name followed by a partition number. For example, \fI/dev/sda1\fP is the first partition on the first hard disk in the system. See also Linux kernel documentation (the \fIDocumentation/admin\-guide/devices.txt\fP file). +.SH "SIZES" +.sp +The "last sector" dialog accepts partition size specified by number of sectors or by +/\-<size>{K,B,M,G,...} notation. +.sp +If the size is prefixed by \(aq+\(aq then it is interpreted as relative to the partition first sector. If the size is prefixed by \(aq\-\(aq then it is interpreted as relative to the high limit (last available sector for the partition). +.sp +In the case the size is specified in bytes than the number may be followed by the multiplicative suffixes KiB=1024, 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". +.sp +The relative sizes are always aligned according to device I/O limits. The +/\-<size>{K,B,M,G,...} notation is recommended. +.sp +For backward compatibility fdisk also accepts the suffixes KB=1000, MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB. These 10^N suffixes are deprecated. +.SH "SCRIPT FILES" +.sp +\fBfdisk\fP allows reading (by \(aqI\(aq command) \fBsfdisk\fP(8) compatible script files. The script is applied to in\-memory partition table, and then it is possible to modify the partition table before you write it to the device. +.sp +And vice\-versa it is possible to write the current in\-memory disk layout to the script file by command \(aqO\(aq. +.sp +The script files are compatible between \fBcfdisk\fP(8), \fBsfdisk\fP(8), \fBfdisk\fP and other libfdisk applications. For more details see \fBsfdisk\fP(8). +.SH "DISK LABELS" +.sp +\fBGPT (GUID Partition Table)\fP +.RS 4 +GPT is modern standard for the layout of the partition table. GPT uses 64\-bit logical block addresses, checksums, UUIDs and names for partitions and an unlimited number of partitions (although the number of partitions is usually restricted to 128 in many partitioning tools). +.sp +Note that the first sector is still reserved for a \fBprotective MBR\fP in the GPT specification. It prevents MBR\-only partitioning tools from mis\-recognizing and overwriting GPT disks. +.sp +GPT is always a better choice than MBR, especially on modern hardware with a UEFI boot loader. +.RE +.sp +\fBDOS\-type (MBR)\fP +.RS 4 +A DOS\-type partition table can describe an unlimited number of partitions. In sector 0 there is room for the description of 4 partitions (called `primary\(aq). One of these may be an extended partition; this is a box holding logical partitions, with descriptors found in a linked list of sectors, each preceding the corresponding logical partitions. The four primary partitions, present or not, get numbers 1\-4. Logical partitions are numbered starting from 5. +.sp +In a DOS\-type partition table the starting offset and the size of each partition is stored in two ways: as an absolute number of sectors (given in 32 bits), and as a \fBCylinders/Heads/Sectors\fP triple (given in 10+8+6 bits). The former is OK \(em with 512\-byte sectors this will work up to 2 TB. The latter has two problems. First, these C/H/S fields can be filled only when the number of heads and the number of sectors per track are known. And second, even if we know what these numbers should be, the 24 bits that are available do not suffice. DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S. The \fBC/H/S addressing is deprecated\fP and may be unsupported in some later \fBfdisk\fP version. +.sp +\fBPlease, read the DOS\-mode section if you want DOS\-compatible partitions.\fP \fBfdisk\fP does not care about cylinder boundaries by default. +.RE +.sp +\fBBSD/Sun\-type\fP +.RS 4 +A BSD/Sun disklabel can describe 8 partitions, the third of which should be a `whole disk\(aq partition. Do not start a partition that actually uses its first sector (like a swap partition) at cylinder 0, since that will destroy the disklabel. Note that a \fBBSD label\fP is usually nested within a DOS partition. +.RE +.sp +\fBIRIX/SGI\-type\fP +.RS 4 +An IRIX/SGI disklabel can describe 16 partitions, the eleventh of which should be an entire `volume\(aq partition, while the ninth should be labeled `volume header\(aq. The volume header will also cover the partition table, i.e., it starts at block zero and extends by default over five cylinders. The remaining space in the volume header may be used by header directory entries. No partitions may overlap with the volume header. Also do not change its type or make some filesystem on it, since you will lose the partition table. Use this type of label only when working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux. +.sp +A sync() and an ioctl(BLKRRPART) (rereading the partition table from disk) are performed before exiting when the partition table has been updated. +.RE +.SH "DOS MODE AND DOS 6.X WARNING" +.sp +\fBNote that all this is deprecated. You don\(cqt have to care about things like\fP \fBgeometry and cylinders on modern operating systems. If you really want\fP \fBDOS\-compatible partitioning then you have to enable DOS mode and cylinder\fP \fBunits by using the \(aq\-c=dos \-u=cylinders\(aq fdisk command\-line options.\fP +.sp +The DOS 6.x FORMAT command looks for some information in the first sector of the data area of the partition, and treats this information as more reliable than the information in the partition table. DOS FORMAT expects DOS FDISK to clear the first 512 bytes of the data area of a partition whenever a size change occurs. DOS FORMAT will look at this extra information even if the /U flag is given \(em we consider this a bug in DOS FORMAT and DOS FDISK. +.sp +The bottom line is that if you use \fBfdisk\fP or \fBcfdisk\fP to change the size of a DOS partition table entry, then you must also use \fBdd\fP(1) to \fBzero the first 512 bytes\fP of that partition before using DOS FORMAT to format the partition. For example, if you were using \fBfdisk\fP to make a DOS partition table entry for \fI/dev/sda1\fP, then (after exiting \fBfdisk\fP and rebooting Linux so that the partition table information is valid) you would use the command \fBdd if=/dev/zero of=/dev/sda1 bs=512 count=1\fP to zero the first 512 bytes of the partition. +.sp +\fBfdisk\fP usually obtains the disk geometry automatically. This is not necessarily the physical disk geometry (indeed, modern disks do not really have anything like a physical geometry, certainly not something that can be described in the simplistic Cylinders/Heads/Sectors form), but it is the disk geometry that MS\-DOS uses for the partition table. +.sp +Usually all goes well by default, and there are no problems if Linux is the only system on the disk. However, if the disk has to be shared with other operating systems, it is often a good idea to let an \fBfdisk\fP from another operating system make at least one partition. When Linux boots it looks at the partition table, and tries to deduce what (fake) geometry is required for good cooperation with other systems. +.sp +Whenever a partition table is printed out in DOS mode, a consistency check is performed on the partition table entries. This check verifies that the physical and logical start and end points are identical, and that each partition starts and ends on a cylinder boundary (except for the first partition). +.sp +Some versions of MS\-DOS create a first partition which does not begin on a cylinder boundary, but on sector 2 of the first cylinder. Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but this is unlikely to cause difficulty unless you have OS/2 on your machine. +.sp +For best results, you should always use an OS\-specific partition table program. For example, you should make DOS partitions with the DOS FDISK program and Linux partitions with the Linux \fBfdisk\fP or Linux \fBcfdisk\fP(8) programs. +.SH "COLORS" +.sp +Implicit coloring can be disabled by an empty file \fI/etc/terminal\-colors.d/fdisk.disable\fP. +.sp +See \fBterminal\-colors.d\fP(5) for more details about colorization configuration. The logical color names supported by \fBfdisk\fP are: +.sp +\fBheader\fP +.RS 4 +The header of the output tables. +.RE +.sp +\fBhelp\-title\fP +.RS 4 +The help section titles. +.RE +.sp +\fBwarn\fP +.RS 4 +The warning messages. +.RE +.sp +\fBwelcome\fP +.RS 4 +The welcome message. +.RE +.SH "ENVIRONMENT" +.sp +\fBFDISK_DEBUG\fP=all +.RS 4 +enables fdisk debug output. +.RE +.sp +\fBLIBFDISK_DEBUG\fP=all +.RS 4 +enables libfdisk debug output. +.RE +.sp +\fBLIBBLKID_DEBUG\fP=all +.RS 4 +enables libblkid debug output. +.RE +.sp +\fBLIBSMARTCOLS_DEBUG\fP=all +.RS 4 +enables libsmartcols debug output. +.RE +.sp +\fBLIBSMARTCOLS_DEBUG_PADDING\fP=on +.RS 4 +use visible padding characters. Requires enabled \fBLIBSMARTCOLS_DEBUG\fP. +.RE +.sp +\fBLOCK_BLOCK_DEVICE\fP=<mode> +.RS 4 +use exclusive BSD lock. The mode is "1" or "0". See \fB\-\-lock\fP for more details. +.RE +.SH "AUTHORS" +.sp +.MTO "kzak\(atredhat.com" "Karel Zak" "," +.MTO "dave\(atgnu.org" "Davidlohr Bueso" "" +.sp +The original version was written by Andries E. Brouwer, A. V. Le Blanc and others. +.SH "SEE ALSO" +.sp +\fBcfdisk\fP(8), +\fBmkfs\fP(8), +\fBpartx\fP(8), +\fBsfdisk\fP(8) +.SH "REPORTING BUGS" +.sp +For bug reports, use the issue tracker at \c +.URL "https://github.com/karelzak/util\-linux/issues" "" "." +.SH "AVAILABILITY" +.sp +The \fBfdisk\fP command is part of the util\-linux package which can be downloaded from \c +.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "." diff --git a/pkg/util-linux/gen.sh b/pkg/util-linux/gen.sh @@ -0,0 +1,276 @@ +fetch git + +setv version 2.37.0 + +cflags " + -include $dir/config.h + -I $outdir/include/blkid + -I $outdir/internal + -I $srcdir/include + -I $srcdir/libblkid/src + -I $srcdir/libuuid/src + -isystem $pkgdir/linux-headers/include + -Wno-format + -Wno-variadic-macros + -Wno-return-type + -Wno-unused-parameter + -Wno-missing-field-initializers + -Wno-implicit-function-declaration + -Wno-implicit-fallthrough + -Wno-pedantic + -Wno-maybe-uninitialized +" + +build cat $outdir/internal/config.h " + $pkgdir/probe/HAVE__THREAD_LOCAL + $dir/config.h +" + +build sed $outdir/internal/libsmartcols.h $srcdir/libsmartcols/src/libsmartcols.h.in +bind expr 's,@LIBSMARTCOLS_VERSION@,$version,' +sync $srcdir/libsmartcols/src/libsmartcols.h.in + +build sed $outdir/internal/libfdisk.h $srcdir/libfdisk/src/libfdisk.h.in +bind expr " + -e s,@LIBFDISK_VERSION@,\$version, + -e /@LIBFDISK_MAJOR_VERSION@/d + -e /@LIBFDISK_MINOR_VERSION@/d + -e /@LIBFDISK_PATCH_VERSION@/d +" +sync $srcdir/libfdisk/src/libfdisk.h.in + +build copy $outdir/include/uuid/uuid.h $srcdir/libuuid/src/uuid.h +sync $srcdir/libuuid/src/uuid.h + +build sed $outdir/include/blkid/blkid.h $srcdir/libblkid/src/blkid.h.in +bind expr '-e /@LIBBLKID_VERSION@/d -e /@LIBBLKID_DATE@/d' +sync $srcdir/libblkid/src/blkid.h.in + +headers " + $outdir/include/blkid/blkid.h + $outdir/include/uuid/uuid.h +" + +dep " + $outdir/internal/config.h + $outdir/internal/libsmartcols.h + $outdir/internal/libfdisk.h + $outdir/include/blkid/blkid.h + linux-headers/headers +" + +lib libcommon.a " + lib/blkdev.c + lib/buffer.c + lib/canonicalize.c + lib/crc32.c + lib/crc32c.c + lib/encode.c + lib/env.c + lib/fileutils.c + lib/idcache.c + lib/jsonwrt.c + lib/mangle.c + lib/match.c + lib/mbsalign.c + lib/md5.c + lib/pager.c + lib/pwdutils.c + lib/randutils.c + lib/sha1.c + lib/signames.c + lib/strutils.c + lib/strv.c + lib/timeutils.c + lib/ttyutils.c + lib/linux_version.c + lib/procutils.c + lib/loopdev.c + lib/cpuset.c + lib/path.c + lib/sysfs.c +" + +lib libblkid.a " + libblkid/src/init.c + libblkid/src/cache.c + libblkid/src/config.c + libblkid/src/dev.c + libblkid/src/devname.c + libblkid/src/devno.c + libblkid/src/encode.c + libblkid/src/evaluate.c + libblkid/src/getsize.c + libblkid/src/probe.c + libblkid/src/read.c + libblkid/src/resolve.c + libblkid/src/save.c + libblkid/src/tag.c + libblkid/src/verify.c + libblkid/src/version.c + libblkid/src/partitions/aix.c + libblkid/src/partitions/atari.c + libblkid/src/partitions/bsd.c + libblkid/src/partitions/dos.c + libblkid/src/partitions/gpt.c + libblkid/src/partitions/mac.c + libblkid/src/partitions/minix.c + libblkid/src/partitions/partitions.c + libblkid/src/partitions/sgi.c + libblkid/src/partitions/solaris_x86.c + libblkid/src/partitions/sun.c + libblkid/src/partitions/ultrix.c + libblkid/src/partitions/unixware.c + libblkid/src/superblocks/adaptec_raid.c + libblkid/src/superblocks/apfs.c + libblkid/src/superblocks/bcache.c + libblkid/src/superblocks/befs.c + libblkid/src/superblocks/bfs.c + libblkid/src/superblocks/bitlocker.c + libblkid/src/superblocks/bluestore.c + libblkid/src/superblocks/btrfs.c + libblkid/src/superblocks/cramfs.c + libblkid/src/superblocks/ddf_raid.c + libblkid/src/superblocks/drbd.c + libblkid/src/superblocks/drbdproxy_datalog.c + libblkid/src/superblocks/drbdmanage.c + libblkid/src/superblocks/exfat.c + libblkid/src/superblocks/exfs.c + libblkid/src/superblocks/ext.c + libblkid/src/superblocks/f2fs.c + libblkid/src/superblocks/gfs.c + libblkid/src/superblocks/hfs.c + libblkid/src/superblocks/highpoint_raid.c + libblkid/src/superblocks/hpfs.c + libblkid/src/superblocks/iso9660.c + libblkid/src/superblocks/isw_raid.c + libblkid/src/superblocks/jfs.c + libblkid/src/superblocks/jmicron_raid.c + libblkid/src/superblocks/linux_raid.c + libblkid/src/superblocks/lsi_raid.c + libblkid/src/superblocks/luks.c + libblkid/src/superblocks/lvm.c + libblkid/src/superblocks/minix.c + libblkid/src/superblocks/mpool.c + libblkid/src/superblocks/netware.c + libblkid/src/superblocks/nilfs.c + libblkid/src/superblocks/ntfs.c + libblkid/src/superblocks/refs.c + libblkid/src/superblocks/nvidia_raid.c + libblkid/src/superblocks/ocfs.c + libblkid/src/superblocks/promise_raid.c + libblkid/src/superblocks/reiserfs.c + libblkid/src/superblocks/romfs.c + libblkid/src/superblocks/silicon_raid.c + libblkid/src/superblocks/squashfs.c + libblkid/src/superblocks/stratis.c + libblkid/src/superblocks/superblocks.c + libblkid/src/superblocks/swap.c + libblkid/src/superblocks/sysv.c + libblkid/src/superblocks/ubi.c + libblkid/src/superblocks/ubifs.c + libblkid/src/superblocks/udf.c + libblkid/src/superblocks/ufs.c + libblkid/src/superblocks/vdo.c + libblkid/src/superblocks/vfat.c + libblkid/src/superblocks/via_raid.c + libblkid/src/superblocks/vmfs.c + libblkid/src/superblocks/vxfs.c + libblkid/src/superblocks/xfs.c + libblkid/src/superblocks/zfs.c + libblkid/src/superblocks/zonefs.c + libblkid/src/superblocks/erofs.c + libblkid/src/topology/topology.c + libblkid/src/topology/dm.c + libblkid/src/topology/evms.c + libblkid/src/topology/ioctl.c + libblkid/src/topology/lvm.c + libblkid/src/topology/md.c + libblkid/src/topology/sysfs.c + $outdir/libcommon.a +" + +lib libuuid.a " + libuuid/src/clear.c + libuuid/src/compare.c + libuuid/src/copy.c + libuuid/src/gen_uuid.c + libuuid/src/isnull.c + libuuid/src/pack.c + libuuid/src/parse.c + libuuid/src/unpack.c + libuuid/src/unparse.c + libuuid/src/uuid_time.c + libuuid/src/predefined.c + $outdir/libcommon.a +" + +lib libfdisk.a " + libfdisk/src/init.c + libfdisk/src/field.c + libfdisk/src/item.c + libfdisk/src/test.c + libfdisk/src/ask.c + libfdisk/src/alignment.c + libfdisk/src/label.c + libfdisk/src/utils.c + libfdisk/src/context.c + libfdisk/src/parttype.c + libfdisk/src/partition.c + libfdisk/src/table.c + libfdisk/src/iter.c + libfdisk/src/script.c + libfdisk/src/version.c + libfdisk/src/wipe.c + libfdisk/src/sun.c + libfdisk/src/sgi.c + libfdisk/src/dos.c + libfdisk/src/bsd.c + libfdisk/src/gpt.c + $outdir/libcommon.a + $outdir/libblkid.a + $outdir/libuuid.a +" + +lib libtcolors.a " + lib/colors.c + lib/color-names.c +" + +lib libsmartcols.a " + libsmartcols/src/iter.c + libsmartcols/src/symbols.c + libsmartcols/src/cell.c + libsmartcols/src/column.c + libsmartcols/src/line.c + libsmartcols/src/table.c + libsmartcols/src/print.c + libsmartcols/src/print-api.c + libsmartcols/src/version.c + libsmartcols/src/buffer.c + libsmartcols/src/calculate.c + libsmartcols/src/grouping.c + libsmartcols/src/walk.c + libsmartcols/src/init.c + $outdir/libtcolors.a + $outdir/libcommon.a +" + +exe fdisk " + disk-utils/fdisk.c + disk-utils/fdisk-menu.c + disk-utils/fdisk-list.c + $outdir/libfdisk.a.d + $outdir/libsmartcols.a.d +" + +exe losetup " + sys-utils/losetup.c + $outdir/libsmartcols.a.d + $outdir/libcommon.a +" + +bin fdisk +bin losetup +man $dir/fdisk.8 +man $dir/losetup.8 diff --git a/pkg/util-linux/losetup.8 b/pkg/util-linux/losetup.8 @@ -0,0 +1,240 @@ +'\" t +.\" Title: losetup +.\" Author: [see the "AUTHOR(S)" section] +.\" Generator: Asciidoctor 2.0.15 +.\" Date: 2021-06-01 +.\" Manual: System Administration +.\" Source: util-linux {release-version} +.\" Language: English +.\" +.TH "LOSETUP" "8" "2021-06-01" "util\-linux {release\-version}" "System Administration" +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.ss \n[.ss] 0 +.nh +.ad l +.de URL +\fI\\$2\fP <\\$1>\\$3 +.. +.als MTO URL +.if \n[.g] \{\ +. mso www.tmac +. am URL +. ad l +. . +. am MTO +. ad l +. . +. LINKSTYLE blue R < > +.\} +.SH "NAME" +losetup \- set up and control loop devices +.SH "SYNOPSIS" +.sp +Get info: +.sp +\fBlosetup\fP [\fIloopdev\fP] +.sp +\fBlosetup\fP \fB\-l\fP [\fB\-a\fP] +.sp +\fBlosetup\fP \fB\-j\fP \fIfile\fP [\fB\-o\fP \fIoffset\fP] +.sp +Detach a loop device: +.sp +\fBlosetup\fP \fB\-d\fP \fIloopdev\fP ... +.sp +Detach all associated loop devices: +.sp +\fBlosetup\fP \fB\-D\fP +.sp +Set up a loop device: +.sp +\fBlosetup\fP [\fB\-o\fP \fIoffset\fP] [\fB\-\-sizelimit\fP \fIsize\fP] [\fB\-\-sector\-size\fP \fIsize\fP] [\fB\-Pr\fP] [\fB\-\-show\fP] \fB\-f\fP \fIloopdev file\fP +.sp +Resize a loop device: +.sp +\fBlosetup\fP \fB\-c\fP \fIloopdev\fP +.SH "DESCRIPTION" +.sp +\fBlosetup\fP is used to associate loop devices with regular files or block devices, to detach loop devices, and to query the status of a loop device. If only the \fIloopdev\fP argument is given, the status of the corresponding loop device is shown. If no option is given, all loop devices are shown. +.sp +Note that the old output format (i.e., \fBlosetup \-a\fP) with comma\-delimited strings is deprecated in favour of the \fB\-\-list\fP output format. +.sp +It\(cqs possible to create more independent loop devices for the same backing file. \fBThis setup may be dangerous, can cause data loss, corruption and overwrites.\fP Use \fB\-\-nooverlap\fP with \fB\-\-find\fP during setup to avoid this problem. +.sp +The loop device setup is not an atomic operation when used with \fB\-\-find\fP, and \fBlosetup\fP does not protect this operation by any lock. The number of attempts is internally restricted to a maximum of 16. It is recommended to use for example flock1 to avoid a collision in heavily parallel use cases. +.SH "OPTIONS" +.sp +The \fIsize\fP and \fIoffset\fP arguments may be followed by the multiplicative suffixes KiB (=1024), 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. +.sp +\fB\-a\fP, \fB\-\-all\fP +.RS 4 +Show the status of all loop devices. Note that not all information is accessible for non\-root users. See also \fB\-\-list\fP. The old output format (as printed without \fB\-\-list)\fP is deprecated. +.RE +.sp +\fB\-d\fP, \fB\-\-detach\fP \fIloopdev\fP... +.RS 4 +Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return \fBEBUSY\fP error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later. +.RE +.sp +\fB\-D\fP, \fB\-\-detach\-all\fP +.RS 4 +Detach all associated loop devices. +.RE +.sp +\fB\-f\fP, \fB\-\-find\fP [\fIfile\fP] +.RS 4 +Find the first unused loop device. If a \fIfile\fP argument is present, use the found device as loop device. Otherwise, just print its name. +.RE +.sp +\fB\-\-show\fP +.RS 4 +Display the name of the assigned loop device if the \fB\-f\fP option and a \fIfile\fP argument are present. +.RE +.sp +\fB\-L\fP, \fB\-\-nooverlap\fP +.RS 4 +Check for conflicts between loop devices to avoid situation when the same backing file is shared between more loop devices. If the file is already used by another device then re\-use the device rather than a new one. The option makes sense only with \fB\-\-find\fP. +.RE +.sp +\fB\-j\fP, \fB\-\-associated\fP \fIfile\fP [\fB\-o\fP \fIoffset\fP] +.RS 4 +Show the status of all loop devices associated with the given \fIfile\fP. +.RE +.sp +\fB\-o\fP, \fB\-\-offset\fP \fIoffset\fP +.RS 4 +The data start is moved \fIoffset\fP bytes into the specified file or device. The \fIoffset\fP may be followed by the multiplicative suffixes; see above. +.RE +.sp +\fB\-\-sizelimit\fP \fIsize\fP +.RS 4 +The data end is set to no more than \fIsize\fP bytes after the data start. The \fIsize\fP may be followed by the multiplicative suffixes; see above. +.RE +.sp +\fB\-b\fP, \fB\-\-sector\-size\fP \fIsize\fP +.RS 4 +Set the logical sector size of the loop device in bytes (since Linux 4.14). The option may be used when create a new loop device as well as stand\-alone command to modify sector size of the already existing loop device. +.RE +.sp +\fB\-c\fP, \fB\-\-set\-capacity\fP \fIloopdev\fP +.RS 4 +Force the loop driver to reread the size of the file associated with the specified loop device. +.RE +.sp +\fB\-P\fP, \fB\-\-partscan\fP +.RS 4 +Force the kernel to scan the partition table on a newly created loop device. Note that the partition table parsing depends on sector sizes. The default is sector size is 512 bytes, otherwise you need to use the option \fB\-\-sector\-size\fP together with \fB\-\-partscan\fP. +.RE +.sp +\fB\-r\fP, \fB\-\-read\-only\fP +.RS 4 +Set up a read\-only loop device. +.RE +.sp +\fB\-\-direct\-io\fP[\fB=on\fP|\fBoff\fP] +.RS 4 +Enable or disable direct I/O for the backing file. The optional argument can be either \fBon\fP or \fBoff\fP. If the argument is omitted, it defaults to \fBoff\fP. +.RE +.sp +\fB\-v\fP, \fB\-\-verbose\fP +.RS 4 +Verbose mode. +.RE +.sp +\fB\-l\fP, \fB\-\-list\fP +.RS 4 +If a loop device or the \fB\-a\fP option is specified, print the default columns for either the specified loop device or all loop devices; the default is to print info about all devices. See also \fB\-\-output\fP, \fB\-\-noheadings\fP, \fB\-\-raw\fP, and \fB\-\-json\fP. +.RE +.sp +\fB\-O\fP, \fB\-\-output\fP \fIcolumn\fP[,\fIcolumn\fP]... +.RS 4 +Specify the columns that are to be printed for the \fB\-\-list\fP output. Use \fB\-\-help\fP to get a list of all supported columns. +.RE +.sp +\fB\-\-output\-all\fP +.RS 4 +Output all available columns. +.RE +.sp +\fB\-n\fP, \fB\-\-noheadings\fP +.RS 4 +Don\(cqt print headings for \fB\-\-list\fP output format. +.RE +.sp +\fB\-\-raw\fP +.RS 4 +Use the raw \fB\-\-list\fP output format. +.RE +.sp +\fB\-J\fP, \fB\-\-json\fP +.RS 4 +Use JSON format for \fB\-\-list\fP output. +.RE +.sp +\fB\-V\fP, \fB\-\-version\fP +.RS 4 +Display version information and exit. +.RE +.sp +\fB\-h\fP, \fB\-\-help\fP +.RS 4 +Display help text and exit. +.RE +.SH "ENCRYPTION" +.sp +\fBCryptoloop is no longer supported in favor of dm\-crypt.\fP For more details see \fBcryptsetup\fP(8). +.SH "EXIT STATUS" +.sp +\fBlosetup\fP returns 0 on success, nonzero on failure. When \fBlosetup\fP displays the status of a loop device, it returns 1 if the device is not configured and 2 if an error occurred which prevented determining the status of the device. +.SH "NOTES" +.sp +Since version 2.37 \fBlosetup\fP uses \fBLOOP_CONFIGURE\fP ioctl to setup a new loop device by one ioctl call. The old versions use \fBLOOP_SET_FD\fP and \fBLOOP_SET_STATUS64\fP ioctls to do the same. +.SH "ENVIRONMENT" +.sp +LOOPDEV_DEBUG=all +.RS 4 +enables debug output. +.RE +.SH "FILES" +.sp +\fI/dev/loop[0..N]\fP +.RS 4 +loop block devices +.RE +.sp +\fI/dev/loop\-control\fP +.RS 4 +loop control device +.RE +.SH "EXAMPLE" +.sp +The following commands can be used as an example of using the loop device. +.sp +.if n .RS 4 +.nf +.fam C +# dd if=/dev/zero of=~/file.img bs=1024k count=10 +# losetup \-\-find \-\-show ~/file.img +/dev/loop0 +# mkfs \-t ext2 /dev/loop0 +# mount /dev/loop0 /mnt +\&... +# umount /dev/loop0 +# losetup \-\-detach /dev/loop0 +.fam +.fi +.if n .RE +.SH "AUTHORS" +.sp +.MTO "kzak\(atredhat.com" "Karel Zak" "," +based on the original version from +.MTO "tytso\(atathena.mit.edu" "Theodore Ts\(cqo" "." +.SH "REPORTING BUGS" +.sp +For bug reports, use the issue tracker at \c +.URL "https://github.com/karelzak/util\-linux/issues" "" "." +.SH "AVAILABILITY" +.sp +The \fBlosetup\fP command is part of the util\-linux package which can be downloaded from \c +.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "." diff --git a/pkg/util-linux/patch/0001-Don-t-omit-second-operand-to-operator.patch b/pkg/util-linux/patch/0001-Don-t-omit-second-operand-to-operator.patch @@ -0,0 +1,95 @@ +From 8dc30022b3a899eae7e323b99b5e4fb79518e216 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 18 Jun 2019 01:38:53 -0700 +Subject: [PATCH] Don't omit second operand to `?` operator + +--- + libfdisk/src/bsd.c | 2 +- + libfdisk/src/dos.c | 2 +- + libfdisk/src/gpt.c | 2 +- + libfdisk/src/parttype.c | 2 +- + libfdisk/src/sgi.c | 2 +- + libfdisk/src/sun.c | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c +index 313ae5ae0..0883915f6 100644 +--- a/libfdisk/src/bsd.c ++++ b/libfdisk/src/bsd.c +@@ -116,7 +116,7 @@ static struct fdisk_parttype *bsd_partition_parttype( + { + struct fdisk_parttype *t + = fdisk_label_get_parttype_from_code(cxt->label, p->p_fstype); +- return t ? : fdisk_new_unknown_parttype(p->p_fstype, NULL); ++ return t ? t : fdisk_new_unknown_parttype(p->p_fstype, NULL); + } + + +diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c +index 4368e5266..a8103ac72 100644 +--- a/libfdisk/src/dos.c ++++ b/libfdisk/src/dos.c +@@ -148,7 +148,7 @@ static struct fdisk_parttype *dos_partition_parttype( + { + struct fdisk_parttype *t + = fdisk_label_get_parttype_from_code(cxt->label, p->sys_ind); +- return t ? : fdisk_new_unknown_parttype(p->sys_ind, NULL); ++ return t ? t : fdisk_new_unknown_parttype(p->sys_ind, NULL); + } + + /* +diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c +index 97b161312..5fd9b4d73 100644 +--- a/libfdisk/src/gpt.c ++++ b/libfdisk/src/gpt.c +@@ -262,7 +262,7 @@ static struct fdisk_parttype *gpt_partition_parttype( + + guid_to_string(&guid, str); + t = fdisk_label_get_parttype_from_string(cxt->label, str); +- return t ? : fdisk_new_unknown_parttype(0, str); ++ return t ? t : fdisk_new_unknown_parttype(0, str); + } + + static void gpt_entry_set_type(struct gpt_entry *e, struct gpt_guid *uuid) +diff --git a/libfdisk/src/parttype.c b/libfdisk/src/parttype.c +index 3a5db9c28..b8d017a1d 100644 +--- a/libfdisk/src/parttype.c ++++ b/libfdisk/src/parttype.c +@@ -491,7 +491,7 @@ struct fdisk_parttype *fdisk_label_advparse_parttype( + + if (res) + DBG(PARTTYPE, ul_debugobj(res, "returns parsed '%s' [%s] partition type", +- res->name, res->typestr ? : "")); ++ res->name, res->typestr ? res->typestr : "")); + return res; + } + +diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c +index 64adf3454..02fd59650 100644 +--- a/libfdisk/src/sgi.c ++++ b/libfdisk/src/sgi.c +@@ -351,7 +351,7 @@ static struct fdisk_parttype *sgi_get_parttype(struct fdisk_context *cxt, size_t + return NULL; + + t = fdisk_label_get_parttype_from_code(cxt->label, sgi_get_sysid(cxt, n)); +- return t ? : fdisk_new_unknown_parttype(sgi_get_sysid(cxt, n), NULL); ++ return t ? t : fdisk_new_unknown_parttype(sgi_get_sysid(cxt, n), NULL); + } + + /* fdisk_get_partition() backend */ +diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c +index 4c3b1d8cb..7a5c63b5b 100644 +--- a/libfdisk/src/sun.c ++++ b/libfdisk/src/sun.c +@@ -827,7 +827,7 @@ static struct fdisk_parttype *sun_get_parttype( + + t = fdisk_label_get_parttype_from_code(cxt->label, + be16_to_cpu(sunlabel->vtoc.infos[n].id)); +- return t ? : fdisk_new_unknown_parttype(be16_to_cpu(sunlabel->vtoc.infos[n].id), NULL); ++ return t ? t : fdisk_new_unknown_parttype(be16_to_cpu(sunlabel->vtoc.infos[n].id), NULL); + } + + +-- +2.31.1 + diff --git a/pkg/util-linux/patch/0002-Avoid-a-few-unnecessary-statement-expressions.patch b/pkg/util-linux/patch/0002-Avoid-a-few-unnecessary-statement-expressions.patch @@ -0,0 +1,55 @@ +From edb05302e2c747253afd4698bc445e36c8726306 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 18 Jun 2019 02:29:07 -0700 +Subject: [PATCH] Avoid a few unnecessary statement expressions + +--- + include/c.h | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +diff --git a/include/c.h b/include/c.h +index b891ad480..b420b5187 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -176,9 +176,8 @@ + * @member: the name of the member within the struct. + */ + #ifndef container_of +-#define container_of(ptr, type, member) __extension__ ({ \ +- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ +- (type *)( (char *)__mptr - offsetof(type,member) );}) ++#define container_of(ptr, type, member) \ ++ ((type *)( (char *)ptr - offsetof(type,member) )) + #endif + + #ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME +@@ -256,11 +255,11 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) + + /* Don't use inline function to avoid '#include "nls.h"' in c.h + */ +-#define errtryhelp(eval) __extension__ ({ \ ++#define errtryhelp(eval) do { \ + fprintf(stderr, _("Try '%s --help' for more information.\n"), \ + program_invocation_short_name); \ + exit(eval); \ +-}) ++} while (0) + + /* After failed execvp() */ + #define EX_EXEC_FAILED 126 /* Program located, but not usable. */ +@@ -387,10 +386,10 @@ static inline int xusleep(useconds_t usec) + + #define UTIL_LINUX_VERSION _("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING + +-#define print_version(eval) __extension__ ({ \ ++#define print_version(eval) do { \ + printf(UTIL_LINUX_VERSION); \ + exit(eval); \ +-}) ++} while (0) + + /* + * seek stuff +-- +2.31.1 + diff --git a/pkg/util-linux/patch/0003-Don-t-use-min-to-determine-if-dflt-is-non-zero.patch b/pkg/util-linux/patch/0003-Don-t-use-min-to-determine-if-dflt-is-non-zero.patch @@ -0,0 +1,36 @@ +From 417ef5a41b19c9cc7ccdf3002453c0fec9caa960 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 18 Jun 2019 02:31:19 -0700 +Subject: [PATCH] Don't use min to determine if dflt is non-zero + +--- + libfdisk/src/bsd.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c +index 817f50c87..25e878c32 100644 +--- a/libfdisk/src/bsd.c ++++ b/libfdisk/src/bsd.c +@@ -576,8 +576,7 @@ static uint32_t ask_uint32(struct fdisk_context *cxt, + { + uintmax_t res; + +- if (fdisk_ask_number(cxt, min(dflt, (uint32_t) 1), dflt, +- UINT32_MAX, mesg, &res) == 0) ++ if (fdisk_ask_number(cxt, !!dflt, dflt, UINT32_MAX, mesg, &res) == 0) + return res; + return dflt; + } +@@ -587,8 +586,7 @@ static uint16_t ask_uint16(struct fdisk_context *cxt, + { + uintmax_t res; + +- if (fdisk_ask_number(cxt, min(dflt, (uint16_t) 1), +- dflt, UINT16_MAX, mesg, &res) == 0) ++ if (fdisk_ask_number(cxt, !!dflt, dflt, UINT16_MAX, mesg, &res) == 0) + return res; + return dflt; + } +-- +2.20.1 + diff --git a/pkg/util-linux/patch/0004-Remove-need-for-VLA-for-label-name.patch b/pkg/util-linux/patch/0004-Remove-need-for-VLA-for-label-name.patch @@ -0,0 +1,83 @@ +From 1c563b2cc82ee2f7ec5daeba5747346250fcc2e2 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 18 Jun 2019 11:54:57 -0700 +Subject: [PATCH] Remove need for VLA for label name + +--- + disk-utils/fdisk-list.c | 10 +++------- + libfdisk/src/label.c | 6 ++++-- + libfdisk/src/libfdisk.h.in | 2 +- + 3 files changed, 8 insertions(+), 10 deletions(-) + +diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c +index 62aa2b3f5..dafab3ca4 100644 +--- a/disk-utils/fdisk-list.c ++++ b/disk-utils/fdisk-list.c +@@ -469,19 +469,15 @@ void list_available_columns(FILE *out) + static int fieldname_to_id(const char *name, size_t namesz) + { + const struct fdisk_field *fl; +- char buf[namesz + 1]; + + assert(name); + assert(namesz); + assert(fields_label); + +- memcpy(buf, name, namesz); +- buf[namesz] = '\0'; +- +- fl = fdisk_label_get_field_by_name(fields_label, buf); ++ fl = fdisk_label_get_field_by_name(fields_label, name, namesz); + if (!fl) { +- warnx(_("%s unknown column: %s"), +- fdisk_label_get_name(fields_label), buf); ++ warnx(_("%s unknown column: %.*s"), ++ fdisk_label_get_name(fields_label), (int)namesz, name); + return -1; + } + return fdisk_field_get_id(fl); +diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c +index 524a2bfb4..e0ec7da43 100644 +--- a/libfdisk/src/label.c ++++ b/libfdisk/src/label.c +@@ -223,12 +223,14 @@ const struct fdisk_field *fdisk_label_get_field(const struct fdisk_label *lb, in + * fdisk_label_get_field_by_name + * @lb: label + * @name: field name ++ * @len: field name length + * + * Returns: pointer to static instance of the field. + */ + const struct fdisk_field *fdisk_label_get_field_by_name( + const struct fdisk_label *lb, +- const char *name) ++ const char *name, ++ size_t len) + { + size_t i; + +@@ -236,7 +238,7 @@ const struct fdisk_field *fdisk_label_get_field_by_name( + assert(name); + + for (i = 0; i < lb->nfields; i++) { +- if (lb->fields[i].name && strcasecmp(lb->fields[i].name, name) == 0) ++ if (lb->fields[i].name && strncasecmp(lb->fields[i].name, name, len) == 0 && lb->fields[i].name[len] == '\0') + return &lb->fields[i]; + } + +diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in +index 6f2e77d04..a0e7aa4b2 100644 +--- a/libfdisk/src/libfdisk.h.in ++++ b/libfdisk/src/libfdisk.h.in +@@ -466,7 +466,7 @@ extern int fdisk_label_get_fields_ids_all( + extern const struct fdisk_field *fdisk_label_get_field(const struct fdisk_label *lb, int id); + extern const struct fdisk_field *fdisk_label_get_field_by_name( + const struct fdisk_label *lb, +- const char *name); ++ const char *name, size_t len); + + extern void fdisk_label_set_changed(struct fdisk_label *lb, int changed); + extern int fdisk_label_is_changed(const struct fdisk_label *lb); +-- +2.31.1 + diff --git a/pkg/util-linux/patch/0005-Avoid-statement-expressions-min-max.patch b/pkg/util-linux/patch/0005-Avoid-statement-expressions-min-max.patch @@ -0,0 +1,285 @@ +From ad5d729e363236dbdcf15b82d8575bd5d9db77ea Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 12 Mar 2019 17:13:45 -0700 +Subject: [PATCH] Avoid statement expressions min/max + +--- + include/c.h | 24 ++++++++++-------------- + include/strutils.h | 3 ++- + lib/mbsalign.c | 2 +- + libblkid/src/superblocks/befs.c | 6 +++--- + libblkid/src/superblocks/exfat.c | 2 +- + libblkid/src/superblocks/iso9660.c | 4 ++-- + libblkid/src/superblocks/minix.c | 4 ++-- + libfdisk/src/alignment.c | 8 ++++---- + libfdisk/src/context.c | 4 ++-- + libfdisk/src/gpt.c | 4 ++-- + libsmartcols/src/calculate.c | 8 ++++---- + libsmartcols/src/column.c | 2 +- + 12 files changed, 34 insertions(+), 37 deletions(-) + +diff --git a/include/c.h b/include/c.h +index b420b5187..fe82a8847 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -141,21 +141,17 @@ + # define FALSE 0 + #endif + +-#ifndef min +-# define min(x, y) __extension__ ({ \ +- __typeof__(x) _min1 = (x); \ +- __typeof__(y) _min2 = (y); \ +- (void) (&_min1 == &_min2); \ +- _min1 < _min2 ? _min1 : _min2; }) +-#endif ++static inline uintmax_t ++umax(uintmax_t x, uintmax_t y) ++{ ++ return x > y ? x : y; ++} + +-#ifndef max +-# define max(x, y) __extension__ ({ \ +- __typeof__(x) _max1 = (x); \ +- __typeof__(y) _max2 = (y); \ +- (void) (&_max1 == &_max2); \ +- _max1 > _max2 ? _max1 : _max2; }) +-#endif ++static inline uintmax_t ++umin(uintmax_t x, uintmax_t y) ++{ ++ return x < y ? x : y; ++} + + #ifndef cmp_numbers + # define cmp_numbers(x, y) __extension__ ({ \ +diff --git a/include/strutils.h b/include/strutils.h +index 7969a84d0..45c1768f0 100644 +--- a/include/strutils.h ++++ b/include/strutils.h +@@ -70,7 +70,8 @@ static inline void xstrncpy(char *dest, const char *src, size_t n) + + if (!len) + return; +- len = min(len, n - 1); ++ if (n - 1 < len) ++ len = n - 1; + memcpy(dest, src, len); + dest[len] = 0; + } +diff --git a/lib/mbsalign.c b/lib/mbsalign.c +index e251202af..f3ea1a2df 100644 +--- a/lib/mbsalign.c ++++ b/lib/mbsalign.c +@@ -614,7 +614,7 @@ mbsalign_unibyte: + + dest = mbs_align_pad (dest, dest_end, start_spaces, padchar); + space_left = dest_end - dest; +- dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left)); ++ dest = mempcpy (dest, str_to_print, umin (n_used_bytes, space_left)); + mbs_align_pad (dest, dest_end, end_spaces, padchar); + } + #ifdef HAVE_WIDECHAR +diff --git a/libblkid/src/superblocks/befs.c b/libblkid/src/superblocks/befs.c +index 211feae9f..35c2b19c4 100644 +--- a/libblkid/src/superblocks/befs.c ++++ b/libblkid/src/superblocks/befs.c +@@ -257,7 +257,7 @@ static int32_t compare_keys(const char keys1[], uint16_t keylengths1[], + + key1 = &keys1[keystart1]; + +- result = strncmp(key1, key2, min(keylength1, keylength2)); ++ result = strncmp(key1, key2, umin(keylength1, keylength2)); + + if (result == 0) + return keylength1 - keylength2; +@@ -386,8 +386,8 @@ static int get_uuid(blkid_probe pr, const struct befs_super_block *bs, + + bi_size = (uint64_t)FS16_TO_CPU(bs->root_dir.len, fs_le) << + FS32_TO_CPU(bs->block_shift, fs_le); +- sd_total_size = min(bi_size - sizeof(struct befs_inode), +- (uint64_t)FS32_TO_CPU(bi->inode_size, fs_le)); ++ sd_total_size = umin(bi_size - sizeof(struct befs_inode), ++ (uint64_t)FS32_TO_CPU(bi->inode_size, fs_le)); + + offset = 0; + +diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c +index f586ec786..3c0448027 100644 +--- a/libblkid/src/superblocks/exfat.c ++++ b/libblkid/src/superblocks/exfat.c +@@ -126,7 +126,7 @@ static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) + label = find_label(pr, sb); + if (label) + blkid_probe_set_utf8label(pr, label->name, +- min((size_t) label->length * 2, sizeof(label->name)), ++ umin((size_t) label->length * 2, sizeof(label->name)), + UL_ENCODE_UTF16LE); + else if (errno) + return -errno; +diff --git a/libblkid/src/superblocks/iso9660.c b/libblkid/src/superblocks/iso9660.c +index 289a325c8..ac4cc274f 100644 +--- a/libblkid/src/superblocks/iso9660.c ++++ b/libblkid/src/superblocks/iso9660.c +@@ -228,8 +228,8 @@ static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag) + unsigned char *desc = + blkid_probe_get_buffer(pr, + off, +- max(sizeof(struct boot_record), +- sizeof(struct iso_volume_descriptor))); ++ umax(sizeof(struct boot_record), ++ sizeof(struct iso_volume_descriptor))); + + if (desc == NULL || desc[0] == ISO_VD_END) + break; +diff --git a/libblkid/src/superblocks/minix.c b/libblkid/src/superblocks/minix.c +index b521efb2b..d1fb64f64 100644 +--- a/libblkid/src/superblocks/minix.c ++++ b/libblkid/src/superblocks/minix.c +@@ -83,8 +83,8 @@ static int probe_minix(blkid_probe pr, + unsigned block_size; + + data = blkid_probe_get_buffer(pr, 1024, +- max(sizeof(struct minix_super_block), +- sizeof(struct minix3_super_block))); ++ umax(sizeof(struct minix_super_block), ++ sizeof(struct minix3_super_block))); + if (!data) + return errno ? -errno : 1; + version = get_minix_version(data, &swabme); +diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c +index 3ae721913..a1a05f48a 100644 +--- a/libfdisk/src/alignment.c ++++ b/libfdisk/src/alignment.c +@@ -38,7 +38,7 @@ + */ + static int lba_is_aligned(struct fdisk_context *cxt, uintmax_t lba) + { +- unsigned long granularity = max(cxt->phy_sector_size, cxt->min_io_size); ++ unsigned long granularity = umax(cxt->phy_sector_size, cxt->min_io_size); + uintmax_t offset; + + if (cxt->grain > granularity) +@@ -54,7 +54,7 @@ static int lba_is_aligned(struct fdisk_context *cxt, uintmax_t lba) + */ + static int lba_is_phy_aligned(struct fdisk_context *cxt, fdisk_sector_t lba) + { +- unsigned long granularity = max(cxt->phy_sector_size, cxt->min_io_size); ++ unsigned long granularity = umax(cxt->phy_sector_size, cxt->min_io_size); + uintmax_t offset = (lba * cxt->sector_size) % granularity; + + return !((granularity + cxt->alignment_offset - offset) % granularity); +@@ -103,7 +103,7 @@ fdisk_sector_t fdisk_align_lba(struct fdisk_context *cxt, fdisk_sector_t lba, in + * according the offset to be on the physical boundary. + */ + /* fprintf(stderr, "LBA: %llu apply alignment_offset\n", res); */ +- res -= (max(cxt->phy_sector_size, cxt->min_io_size) - ++ res -= (umax(cxt->phy_sector_size, cxt->min_io_size) - + cxt->alignment_offset) / cxt->sector_size; + + if (direction == FDISK_ALIGN_UP && res < lba) +@@ -398,7 +398,7 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt) + fdisk_reset_alignment(cxt); + + if (cxt->user_grain) { +- unsigned long granularity = max(cxt->phy_sector_size, cxt->min_io_size); ++ unsigned long granularity = umax(cxt->phy_sector_size, cxt->min_io_size); + + cxt->grain = cxt->user_grain < granularity ? granularity : cxt->user_grain; + DBG(CXT, ul_debugobj(cxt, "new grain: %lu", cxt->grain)); +diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c +index 083b255d3..a3bfff993 100644 +--- a/libfdisk/src/context.c ++++ b/libfdisk/src/context.c +@@ -919,7 +919,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + /* the current layout */ + fdisk_get_partitions(cxt, &tb); + /* maximal number of partitions */ +- nparts = max(fdisk_table_get_nents(tb), fdisk_table_get_nents(org)); ++ nparts = umax(fdisk_table_get_nents(tb), fdisk_table_get_nents(org)); + + while (fdisk_diff_tables(org, tb, &itr, &pa, &change) == 0) { + if (change == FDISK_DIFF_UNCHANGED) +@@ -976,7 +976,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + /* Let's follow the Linux kernel and reduce + * DOS extended partition to 1 or 2 sectors. + */ +- sz = min(sz, (uint64_t) 2); ++ sz = umin(sz, (uint64_t) 2); + + if (partx_add_partition(cxt->dev_fd, pa->partno + 1, + pa->start * ssf, sz) != 0) { +diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c +index 5fd9b4d73..97e23767d 100644 +--- a/libfdisk/src/gpt.c ++++ b/libfdisk/src/gpt.c +@@ -504,7 +504,7 @@ static int gpt_mknew_pmbr(struct fdisk_context *cxt) + pmbr->partition_record[0].end_track = 0xFF; + pmbr->partition_record[0].starting_lba = cpu_to_le32(1); + pmbr->partition_record[0].size_in_lba = +- cpu_to_le32((uint32_t) min( cxt->total_sectors - 1ULL, 0xFFFFFFFFULL) ); ++ cpu_to_le32((uint32_t) umin(cxt->total_sectors - 1ULL, 0xFFFFFFFFULL)); + + return 0; + } +@@ -956,7 +956,7 @@ static int valid_pmbr(struct fdisk_context *cxt) + /* Note that gpt_write_pmbr() overwrites PMBR, but we want to keep it valid already + * in memory too to disable warnings when valid_pmbr() called next time */ + pmbr->partition_record[part].size_in_lba = +- cpu_to_le32((uint32_t) min( cxt->total_sectors - 1ULL, 0xFFFFFFFFULL) ); ++ cpu_to_le32((uint32_t) umin(cxt->total_sectors - 1ULL, 0xFFFFFFFFULL)); + fdisk_label_set_changed(cxt->label, 1); + } + } +diff --git a/libsmartcols/src/calculate.c b/libsmartcols/src/calculate.c +index 974fc340c..0c11627a7 100644 +--- a/libsmartcols/src/calculate.c ++++ b/libsmartcols/src/calculate.c +@@ -57,7 +57,7 @@ static int count_cell_width(struct libscols_table *tb, + + if (len == (size_t) -1) /* ignore broken multibyte strings */ + len = 0; +- cl->width_max = max(len, cl->width_max); ++ cl->width_max = umax(len, cl->width_max); + + if (cl->is_extreme && cl->width_avg && len > cl->width_avg * 2) + return 0; +@@ -66,10 +66,10 @@ static int count_cell_width(struct libscols_table *tb, + cl->extreme_sum += len; + cl->extreme_count++; + } +- cl->width = max(len, cl->width); ++ cl->width = umax(len, cl->width); + if (scols_column_is_tree(cl)) { + size_t treewidth = buffer_get_safe_art_size(buf); +- cl->width_treeart = max(cl->width_treeart, treewidth); ++ cl->width_treeart = umax(cl->width_treeart, treewidth); + } + return 0; + } +@@ -115,7 +115,7 @@ static int count_column_width(struct libscols_table *tb, + if (data) { + size_t len = scols_table_is_noencoding(tb) ? + mbs_width(data) : mbs_safe_width(data); +- cl->width_min = max(cl->width_min, len); ++ cl->width_min = umax(cl->width_min, len); + } else + no_header = 1; + +diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c +index c11df69f5..1285d42e6 100644 +--- a/libsmartcols/src/column.c ++++ b/libsmartcols/src/column.c +@@ -347,7 +347,7 @@ size_t scols_wrapnl_chunksize(const struct libscols_column *cl __attribute__((un + mbs_width(data) : + mbs_safe_width(data); + } +- sum = max(sum, sz); ++ sum = umax(sum, sz); + data = p; + } + +-- +2.37.3 + diff --git a/pkg/util-linux/patch/0006-Avoid-initialization-of-flexible-array-in-struct.patch b/pkg/util-linux/patch/0006-Avoid-initialization-of-flexible-array-in-struct.patch @@ -0,0 +1,97 @@ +From 56273e92326b26a326c73e47b3d5929bbce9ac03 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 24 Jun 2019 22:48:57 -0700 +Subject: [PATCH] Avoid initialization of flexible array in struct + +--- + disk-utils/fdisk-menu.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c +index 71355f684..fb5b2e253 100644 +--- a/disk-utils/fdisk-menu.c ++++ b/disk-utils/fdisk-menu.c +@@ -37,7 +37,7 @@ struct menu { + const struct menu *, + const struct menu_entry *); + +- struct menu_entry entries[]; /* NULL terminated array */ ++ struct menu_entry *entries; /* NULL terminated array */ + }; + + struct menu_context { +@@ -92,7 +92,7 @@ DECLARE_MENU_CB(generic_menu_cb); + /* Generic menu */ + static const struct menu menu_generic = { + .callback = generic_menu_cb, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_BSEP(N_("Generic")), + MENU_ENT ('d', N_("delete a partition")), + MENU_ENT ('F', N_("list free unpartitioned space")), +@@ -134,7 +134,7 @@ static const struct menu menu_createlabel = { + .callback = createlabel_menu_cb, + .exclude = FDISK_DISKLABEL_BSD, + .nonested = 1, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_SEP(N_("Create a new label")), + MENU_ENT('g', N_("create a new empty GPT partition table")), + MENU_ENT('G', N_("create a new empty SGI (IRIX) partition table")), +@@ -151,7 +151,7 @@ static const struct menu menu_createlabel = { + static const struct menu menu_geo = { + .callback = geo_menu_cb, + .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_XSEP(N_("Geometry (for the current label)")), + MENU_XENT('c', N_("change number of cylinders")), + MENU_XENT('h', N_("change number of heads")), +@@ -163,7 +163,7 @@ static const struct menu menu_geo = { + static const struct menu menu_gpt = { + .callback = gpt_menu_cb, + .label = FDISK_DISKLABEL_GPT, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_BSEP(N_("GPT")), + MENU_XENT('i', N_("change disk GUID")), + MENU_XENT('n', N_("change partition name")), +@@ -184,7 +184,7 @@ static const struct menu menu_gpt = { + static const struct menu menu_sun = { + .callback = sun_menu_cb, + .label = FDISK_DISKLABEL_SUN, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_BSEP(N_("Sun")), + MENU_ENT('a', N_("toggle the read-only flag")), + MENU_ENT('c', N_("toggle the mountable flag")), +@@ -201,7 +201,7 @@ static const struct menu menu_sun = { + static const struct menu menu_sgi = { + .callback = sgi_menu_cb, + .label = FDISK_DISKLABEL_SGI, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_SEP(N_("SGI")), + MENU_ENT('a', N_("select bootable partition")), + MENU_ENT('b', N_("edit bootfile entry")), +@@ -214,7 +214,7 @@ static const struct menu menu_sgi = { + static const struct menu menu_dos = { + .callback = dos_menu_cb, + .label = FDISK_DISKLABEL_DOS, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_BSEP(N_("DOS (MBR)")), + MENU_ENT('a', N_("toggle a bootable flag")), + MENU_ENT('b', N_("edit nested BSD disklabel")), +@@ -232,7 +232,7 @@ static const struct menu menu_dos = { + static const struct menu menu_bsd = { + .callback = bsd_menu_cb, + .label = FDISK_DISKLABEL_BSD, +- .entries = { ++ .entries = (struct menu_entry[]){ + MENU_SEP(N_("BSD")), + MENU_ENT('e', N_("edit drive data")), + MENU_ENT('i', N_("install bootstrap")), +-- +2.25.0 + diff --git a/pkg/util-linux/patch/0007-Use-MAXIMUM_PARTS-instead-of-VLA.patch b/pkg/util-linux/patch/0007-Use-MAXIMUM_PARTS-instead-of-VLA.patch @@ -0,0 +1,28 @@ +From abcdd92972cc92840e8db22d7018c44dbb9ec2f4 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 24 Jun 2019 23:41:53 -0700 +Subject: [PATCH] Use MAXIMUM_PARTS instead of VLA + +This is the upper bound on the pte array, so just use it as the +static array length. +--- + libfdisk/src/dos.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c +index 7a1f6ea34..967b7bd19 100644 +--- a/libfdisk/src/dos.c ++++ b/libfdisk/src/dos.c +@@ -1624,8 +1624,7 @@ static int dos_verify_disklabel(struct fdisk_context *cxt) + { + size_t i, j; + fdisk_sector_t total = 1, n_sectors = cxt->total_sectors; +- fdisk_sector_t first[cxt->label->nparts_max], +- last[cxt->label->nparts_max]; ++ fdisk_sector_t first[MAXIMUM_PARTS], last[MAXIMUM_PARTS]; + struct dos_partition *p; + struct fdisk_dos_label *l = self_label(cxt); + int nerrors = 0; +-- +2.28.0 + diff --git a/pkg/util-linux/patch/0008-Use-alloca-if-VLAs-aren-t-supported.patch b/pkg/util-linux/patch/0008-Use-alloca-if-VLAs-aren-t-supported.patch @@ -0,0 +1,28 @@ +From 7943a7c1c795a1ffe79b2898eb4860cec60dec23 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 24 Jun 2019 23:54:21 -0700 +Subject: [PATCH] Use alloca if VLAs aren't supported + +--- + lib/path.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/lib/path.c b/lib/path.c +index 75fa85305..af90261a6 100644 +--- a/lib/path.c ++++ b/lib/path.c +@@ -982,7 +982,11 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i + { + FILE *f; + size_t setsize, len = maxcpus * 7; ++#ifndef __STDC_NO_VLA__ + char buf[len]; ++#else ++ char *buf = alloca(len); ++#endif + int rc; + + *set = NULL; +-- +2.28.0 + diff --git a/pkg/util-linux/patch/0009-Use-static-inline-function-for-cmp_numbers.patch b/pkg/util-linux/patch/0009-Use-static-inline-function-for-cmp_numbers.patch @@ -0,0 +1,37 @@ +From f9e192ecdbfd369fe42da4c9b8a3ab90cfa6f10f Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 25 Jun 2019 00:13:43 -0700 +Subject: [PATCH] Use static inline function for cmp_numbers + +All callers use it with an unsigned type, so just specialize for +uintmax_t. +--- + include/c.h | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/include/c.h b/include/c.h +index fe82a8847..eb48e7f77 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -153,13 +153,11 @@ umin(uintmax_t x, uintmax_t y) + return x < y ? x : y; + } + +-#ifndef cmp_numbers +-# define cmp_numbers(x, y) __extension__ ({ \ +- __typeof__(x) _a = (x); \ +- __typeof__(y) _b = (y); \ +- (void) (&_a == &_b); \ +- _a == _b ? 0 : _a > _b ? 1 : -1; }) +-#endif ++static inline uintmax_t ++cmp_numbers(uintmax_t x, uintmax_t y) ++{ ++ return x == y ? 0 : x > y ? 1 : -1; ++} + + #ifndef offsetof + #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +-- +2.31.1 + diff --git a/pkg/util-linux/patch/0010-Avoid-use-of-long-double.patch b/pkg/util-linux/patch/0010-Avoid-use-of-long-double.patch @@ -0,0 +1,44 @@ +From d9162eab76d43c1cbd289665c1b02a7e062a2017 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 6 Sep 2021 18:05:22 -0700 +Subject: [PATCH] Avoid use of long double + +--- + lib/strutils.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/strutils.c b/lib/strutils.c +index 5b5e686aa..ac1a0f527 100644 +--- a/lib/strutils.c ++++ b/lib/strutils.c +@@ -459,6 +459,7 @@ err: + errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); + } + ++#if 0 + long double strtold_or_err(const char *str, const char *errmesg) + { + double num; +@@ -479,6 +480,7 @@ err: + + errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); + } ++#endif + + long strtol_or_err(const char *str, const char *errmesg) + { +@@ -538,9 +540,9 @@ uintmax_t strtosize_or_err(const char *str, const char *errmesg) + + void strtotimeval_or_err(const char *str, struct timeval *tv, const char *errmesg) + { +- long double user_input; ++ double user_input; + +- user_input = strtold_or_err(str, errmesg); ++ user_input = strtod_or_err(str, errmesg); + tv->tv_sec = (time_t) user_input; + tv->tv_usec = (suseconds_t)((user_input - tv->tv_sec) * 1000000); + } +-- +2.32.0 + diff --git a/pkg/util-linux/repo b/pkg/util-linux/repo @@ -0,0 +1 @@ +Subproject commit 78ed62f2fca8a9c208721e4b0d38fc60646f2cea