Bug fixed:
---
678: fdisk: ASK: asking for number ['Partition number', <1,4>, default=1, range: 1-4]
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 12345
678: fdisk: ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 1
678: fdisk: ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1):
678: fdisk: ASK: user's reply: >>>22345<<<
Value out of range.
---
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
The high-level readline API is crazy to use with signals. Fortunately
the library provides low-level rl_callback_* API. In this case we can
use poll() to wait for input and control all signals, etc.
This patch also a little changes fdisk behavior on CTRL+C and CTRL+D.
The signals does not kill fdisk, but forces fdisk to return to the
main menu, if already in the main menu then exit. If the disk layout
has been modified than ask "Do you really want to exit...".
Signed-off-by: Karel Zak <kzak@redhat.com>
make function wrapping rl_fgets() and fputs()&fgets() to remove
code duplication in get_user_reply().
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Earlier the command exit too early if one of the arguments failed. After
this change all arguments are examined, and command return value will have
information what happen during processing.
Based on patch from Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64
add extra warning when the ioctl is used for DM devices. It seems we
can avoid this ioctl when the device has dm/uuid.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532
Signed-off-by: Karel Zak <kzak@redhat.com>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We assume that users will have a kernel >= 2.6.0 and removel
references to earlier kernels. There are still a few ones
left.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We are using better/shorter error messages and somtimes
also errtryhelp().
Here we fix all cases where the usage function took
an int argument for exit_code.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* '170622' of github.com:jwpi/util-linux:
Docs: move option naming to howto-contribute.txt
Docs: update howto-usage-function.txt
Docs: add a comment for constants to boilerplate.c
include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
As discussed on the mailing list. We fix all places
where the non-working define STRTOXX_EXIT_CODE was used.
Regarding tunelp, also see 7e3c80a7.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
These tools have special exit codes. They got changed mistakenly.
See:
findfs 0e1fa6b6
fsck 658c0891
fsck.cramfs 922ec175
mkfs.cramfs 16154b1f
tunelp 2ab428f6
FIXME: STRTOXX_EXIT_CODE doesn't work as it should.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Also cleanup usage() function, never write usage to stderr.
FIXME:
- currently strtou32_or_err() exits with wrong exit code.
- option -C does not use a safe strto*_err function
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
In same go fix error reporting when input file is not long enough.
$ touch empty
$ isosize empty
isosize: empty: might not be an ISO filesystem
isosize: read error on empty: Success
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
(Original patch and commit message edited by Rudi.)
gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.
We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/fsck.minix.c:421:30: runtime error: index 513 out of bounds for
type 'unsigned short [512]'
Addresses: https://github.com/karelzak/util-linux/issues/373
Reported-by: Hanno Bock <hanno@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The wipe operation is potentially dangerous. Let's inform about it
always by 'p' (list) command to make sure user knowns about it.
Command (m for help): p
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 204799 202752 99M 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Addresses: https://github.com/karelzak/util-linux/issues/437
Signed-off-by: Karel Zak <kzak@redhat.com>
fdformat:
Add --from, --to, and --repair options.
Commit: e0402441a1
fdisk:
Add --output [1], --bytes [2], --wipe [3], --wipe-partition [4], and
remove --geom- from from --cylinders, --heads, --sector options [5].
Commit [1]: fff8ad5882
Commit [2]: 354f8cc8cf
Commit [3]: cb9a4b0033
Commit [4]: ba465623d8
Commit [5]: 4b4e391a28
fsck.cramfs:
Broken since first commit.
Commit: bf60993cf2
mkswap:
Provide random uuid when completing --uuid argument.
partx:
Add --sector-size option. Fix also list of known partition types to
match with libblkid blkid_idinfo names. The fix is also applied to
manual page.
Commit: f8a4a0d4f2
Reference: git grep -A 4 blkid_idinfo libblkid/src/partitions | grep name
sfdisk:
Add --reoder, --delete, --mode-dataa, -no-tell-kernel, --wipe, and
--wipe-partitions options. In same go fix some option argument
completions.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Adding _FUNCTION_DEF definition will exclude compatibility type definitions
that do include void key word in empty argument list.
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function
declaration of function 'Function'
These functions has been replaced by set of new ones in readline 4.2 (April
2001), and removed in 6.3 (February 2014).
Reference: https://cnswww.cns.cwru.edu/php/chet/readline/CHANGES
Rererence: https://blueslugs.com/blog/2016-10-23-updating-cppfunction-in-old-readline-consumers/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer
Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.
Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/cfdisk.c:1066:29: error: cannot size expression
One should use sizeof() only when variable size can be known at time of
compilation. That is not the case with variable length arrays.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
/dev/sdc is 4K disk:
# fdisk -l /dev/sdc
Disk /dev/sdc: 100 MiB, 104857600 bytes, 25600 sectors
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 1024 25599 24576 96M 83 Linux
let's use it as disk image:
# dd if=/dev/sdc of=~/sdc.img
# losetup -f ~/sdc.img
old version:
# partx --show /dev/loop0
NR START END SECTORS SIZE NAME UUID
1 1024 25599 24576 12M 6a4ba75b-01
new version:
# partx --show /dev/loop0 --sector-size 4096
NR START END SECTORS SIZE NAME UUID
1 8192 204799 196608 96M 6a4ba75b-01
Addresses: https://github.com/karelzak/util-linux/issues/396
Signed-off-by: Karel Zak <kzak@redhat.com>
ninodes in the superblock needs to be set after inodes is checked
against MINIX_MAX_INODES otherwise a value larger than MINIX_MAX_INODES
can be attempted to be stored in the superblock.
Without this change the command "mkfs.minix -2 -i 65530 <dev>" would
write a minix superblock with ninodes set to 0.
Signed-off-by: Nate Clark <nate@neworld.us>
In the majority of pages, pathnames are formatted as Italic,
which is the norm. However, there are several cases where they
are formatted as bold. This patch fixes a number of those
exceptions.
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
By default sfdisk creates partition table when a first partition is
specified, otherwise the device is not modified. This force users to
create at least one partition.
This commit allows to create empty label without partitions if "label:
<name>" header line is specified by script.
The commit also modifies "New situation:" output to list label name
and label identifier.
Addresses: https://github.com/karelzak/util-linux/issues/374
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch does only the following:
* Order SEE ALSO entries first by section name, then alphabetically
within section
* Adds one or two missing commas in SEE ALSO lists
* Removes one or two periods that were (inconsistently) used
at the end of SEE ALSO lists.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
disk-utils/fdisk-menu.c: In function ‘gpt_menu_cb’:
disk-utils/fdisk-menu.c:709: warning: passing argument 6 of ‘fdisk_ask_number’ from incompatible pointer type
./libfdisk/src/libfdisk.h:688: note: expected ‘uintmax_t *’ but argument is of type ‘long unsigned int *’
Signed-off-by: Karel Zak <kzak@redhat.com>
We cannot use our crc32 without changes in the code, because our
ul_crc32() assumes that post-conditioning (xor) is done by
application. The zlib implementation does everything.
Signed-off-by: Karel Zak <kzak@redhat.com>
Make the publicly-visible crc32 library functions prefixed by ul_, such
as crc32() -> ul_crc32().
This is because it clashes with the crc32() function from zlib.
For newer versions of glib (2.50+) zlib and libblkid are required
dependencies and otherwise results in build failure when building
statically.
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
This env.variable forces libsmartcols to use visible padding chars.
The standard debug has to be enabled (to minimize overhead for
non-debug execution).
For example:
$ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> ~/log
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's force users to read fs-specific man pages rather than try to be
smart and maintain some non-fsck options in fsck.8.
Reported-by: Matej Cepl <mcepl@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The option forces sfdisk to not call re-read partitions ioctl after
write PT.
Requested-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
# echo -e ',1M\n,2M' | sfdisk /dev/sdc
Old version:
>>> Created a new DOS disklabel with disk identifier 0x8fc7d065.
Created a new partition 1 of type 'Linux' and of size 1 MiB.
/dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
/dev/sdc3:
New version:
>>> Created a new DOS disklabel with disk identifier 0x9afe17c0.
/dev/sdc1: Created a new partition 1 of type 'Linux' and of size 1 MiB.
/dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
/dev/sdc3: Done.
Addresses: https://github.com/karelzak/util-linux/issues/337
Signed-off-by: Karel Zak <kzak@redhat.com>
The list of the partition types is too long. Let's try to use $PAGER.
Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
--show-pt-geometry existed since cf3f26bf (2006), and it is used by third party
tools. To prevent failure of these tools, add a minimal compatibility code.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
This reverts commit 14f644f386.
It seems we have mess in reread-after-write:
all old versions to v2.20 -- returns 0
from v2.20 to v2.26 -- returns 1
since v2.26 -- returns 0
I think re-read errors should not be interpreted as fatal errors,
because it's pretty common that you want to modify only one partition
(e.g. resize) and then another partitions are probably still in use
and re-read all PT does not make sense.
What we need is to improve granularity for re-read and calls it only
when really necessary (all PT modified) and otherwise call BLKPG
(add/delete/resize) ioctls.
Reported-by: Nikhil Valluru <vvnikhil@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It seems there is no elegant way how to recovery if a directory i_zone
(and i_size) is out of reality. Let's require human interaction to
avoid endless loop when executed with --auto, etc.
Addresses: https://github.com/karelzak/util-linux/issues/228
Signed-off-by: Karel Zak <kzak@redhat.com>
This typo fix is backwards compatible in that fdisk will accept both
the GPT attribute RequiredPartition and RequiredPartiton with the typo.
Update documentation and tests to all use the new attribute name.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
The field s_ninodes in super-block is used for memory allocation and
division without verifications. The memory allocation increments the
unchecked value by 1, making it vulnerable to an integer overflow
on 32 bit systems with minix 3 file systems. I did not find a (good)
way to exploit this by crafting a malicious file system, so I consider
it as a reliability issue. If it's 0, a division by zero occurs when
"-v" has been used. A filesystem without any inodes is definitely
wrong, because it means that there's not even the root inode, which is
accessed unchecked later on.
The field s_firstdatazone has to be checked against s_(n)zones. If it
is larger than the highest allowed index, the file system is definitely
corrupted -- hard to say which value is wrong though, therefore I
decided to simply call die(). A maliciously created file system could
do more harm in this way: single bits inside the memory area could be
flipped because range checks would fail. Hard to consider it as a
security issue though, because these addresses are not arbitrarily
accessible without very careful crafting (if at all possible).
[kzak@redhat.com: - fix compiler warning (cast get_nzones()) [-Wsign-compare]]
Signed-off-by: Karel Zak <kzak@redhat.com>
Use the return value of fdisk_reread_partition_table in write_changes so that
sfdisk exits with error if re-reading the partition table fails.
Signed-off-by: Victor Dodon <dodonvictor@gmail.com>
The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).
The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.
Signed-off-by: Karel Zak <kzak@redhat.com>
The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).
The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.
Signed-off-by: Karel Zak <kzak@redhat.com>
It might be that the underlying filesystem just doesn't support SELinux
labeling. This fixes creating swap on vfat live media:
# livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ...
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Earlier printout had strange looking 'Success'.
$ isosize --sectors /dev/urandom
isosize: /dev/urandom: might not be an ISO filesystem
isosize: 733error: le=-1971599244 be=1633181607: Success
...
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
clang warning:
libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever
'if' condition is true [-Wsometimes-uninitialized]
if (!mpc)
^~~~
icc printf warnings:
libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing"));
^
login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
: _("You are using shadow passwords on this system.\n"));
^
icc enum warnings:
disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type
.exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
^
libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type
&width, align,
^
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary),
but needed on many places. It seems better to keep it in c.h.
Signed-off-by: Karel Zak <kzak@redhat.com>
Use "when" as argument, to match the argument of --color,
that can have the same three values.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux
libraries have been moving away from including sysmacros.h implicitly via
sys/types.h, so include it directly.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* 'fix-minix' of https://github.com/rudimeier/util-linux:
tests: minix, add a useful non-root check
tests: fix minix tests for big endian
mkfs.minix: fix v2/v3 .badblocks inode number for big endian
fsck.minix: fix v3 version offset
tests: minix, some corrections and cleanup
tests: minix, use hexdump instead of md5sum
I have validated that we are still compatible at least back to
- openSUSE 11.4
- SLE 11
- RHEL/CentOS 6
- OSX 10.10.x, (Xcode 6.3)
- FreeBSD 10.2
Confirmed incompatibility:
- OSX 10.9.x, (Xcode 6.2)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
For minix v2/v3 on big endian systems the inode number of the unwanted
".badblocks" file was not set to zero. This was introduced when v3 was
added in a2657ae3.
Actually it did not seem to cause any problems but since we zero it out
at all we should do it correctly. Now we zero out the whole directory
entry (inclusive ".badblocks" file name, also for v1). Unfortunately we
have to update the test data checksums.
CC: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Our test-suite discoverd it on big endian systems, but it was also
broken on little endian for inode numbers > 0xffff.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 'port-osx' of https://github.com/rudimeier/util-linux:
include: fix sys/sysinfo.h
libblkid: don't include endian.h
lib: fix ismounted includes for FreeBSD
lib: remove unused variable
lsns: use xcalloc()
include: remove unused mntent.h
include: check for sys/sysmacros.h
lib: define LOGIN_NAME_MAX fallback
include: provide MAP_ANONYMOUS on OSX
lib: rename strmode() and setmode()
tests: fix ts_option helpers
build-sys: fix [g]libtoolize version for OSX
build-sys: check linker support for version scripts
build-sys: portable usage of find command
travis: minor cleanup
This patch changes sfdisk behavior and it wipes foreign signatures
from the device to avoid collisions. The wipe functionality is
automatically enabled in the interactive mode only (user is always
warned about it), otherwise it's possible to control all by --wipe
<auto|never|always>.
The program does not change behavior when executed in scripts (echo
<something> | sfdisk), the option "--wipe=always" is required to enable
in this case.
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch changes fdisk behavior and it wipes foreign signatures
from the device to avoid collisions. The wipe functionality is
automatically enabled in the interactive mode only (user is always
warned about it), otherwise it's possible to control all by --wipe
<auto|never|always>.
The program does not change behavior when executed in scripts (echo
<something> | fdisk), the option "--wipe=always" is required to enable
in this case.
Signed-off-by: Karel Zak <kzak@redhat.com>
Fix the warnings below for OSX clang and add a few more
casts for timeval:
lib/at.c:131:27: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') [-Wformat]
printf("%16jd bytes ", st.st_size);
~~~~~ ^~~~~~~~~~
lib/strutils.c:522:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix);
~~~ ^~~~
lib/sysfs.c:468:42: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
len = snprintf(buf, sizeof(buf), "%ju", num);
~~~ ^~~
libuuid/src/gen_uuid.c:316:34: warning: format specifies type 'unsigned long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
clock_seq, last.tv_sec, last.tv_usec, adjustment);
^~~~~~~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Almost any code calling get_terminal_width() checks returned width for
non-positive values and sets it to some default value (say, 80). So,
let's pass this default value directly to the function.
[kzak@redhat.com: - get_terminal_width() refactoring]
Signed-off-by: Karel Zak <kzak@redhat.com>
Most, if not all, linux file systems allow this and there should not be a
reason why bfs could not do the same.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The stat(3) and access(3) are in this case almost interchangeable, so choose
the lightweight function with additional advantage checking the file is
executable.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The libmount provides way how to deal with parsing errors in fstab --
on error callback function is executed and according to the return
libmount manipulate with the malformed line, possible are three
states:
1/ fatal error; all file ignored (callback rc < 0)
2/ recoverable error; malformed line ignored (callback rc > 0)
3/ ignore the error (callback rc == 0)
The 2/ is the default if no callback specified.
Unfortunately our utils uses 3/. The correct way is to use 2/.
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/zramctl.c: In function 'get_mm_stat':
sys-utils/zramctl.c:276:58: warning: declaration of 'inbytes' shadows a global declaration [-Wshadow]
static char *get_mm_stat(struct zram *z, size_t idx, int inbytes)
sys-utils/zramctl.c:119:39: note: shadowed declaration is here
static unsigned int raw, no_headings, inbytes;
libmount/src/tab.c: In function 'mnt_table_get_fs_root':
libmount/src/tab.c:1221:22: warning: declaration of 'fs' shadows a parameter [-Wshadow]
struct libmnt_fs *fs = mnt_table_find_mountpoint(tb,
libmount/src/tab.c:1197:24: note: shadowed declaration is here
struct libmnt_fs *fs,
disk-utils/fsck.minix.c: In function 'main':
disk-utils/fsck.minix.c:1364:17: warning: declaration of 'i' shadows a previous local [-Wshadow]
unsigned long i, free;
disk-utils/fsck.minix.c:1250:6: note: shadowed declaration is here
int i;
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
There two possible ways, print error and exit on too long names or
truncate the filename -- but it's impossible to do both in the same
code :-) It seems that code already assumes warning on long names, so
let's remove errx() and keep the behavior in dependence on -E.
Signed-off-by: Karel Zak <kzak@redhat.com>
Needed in order to create reproducable file systems image files, so that
out come of mkfs.minix can be checksum'ed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use real table to device list, add missing new paragraph markers, remove
braces that cause reader to wonder if test is meant or not, squeeze error
code list, move references to bottom of the manual, and use mail or web
address macro when possible.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier user could define more blocks than device, or backing file for
loopback file system, had available. That lead to a system crash with
following commands;
fallocate --length 64KiB test-file
mkfs.minix -3 -i 842160 test-file 104882174
mkdir test-file.d
mount test-file test-file.d
cp /etc/service test-file.d
Killed
sudo umount test-file.d
The minix driver should probably not hang the whole kernel, but the least
that mkfs.minix ought to do is not to let users to get that condition
quite as easily.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
File name lenght and version input needs to be checked against each
other, which will determine what version of file system is in question.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Checks about inodes vs block sizes does not add much robustness. Both
values are derived at compilation time from struct minix_inode size, and
they form full definition circle.
Bad block check for none-block devices should not be supressed, user
requested it so let him have it.
Check for st_rdev == 0x0300 || st_rdev == 0x0340 was unreachable.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mkfs.minix misbehaves when attempting to create a large v2 or v3
filesystem. I finally traced it down to attempting to create too many
inodes so that the first zone is past 65535 blocks in. This obviously
doesn't work as the on-disk superblock says this is a 16 bit integer.
I wrote a patch that catches this, clamps to the absolute v2/v3 limit
(like it already does for v1), and sets the blocks per inode to a more
reasonable ratio when exceeding half a gigabyte. Having a half-gig
filesystem with most files being smaller than 3k isn't really reasonable.
I suppose if you don't want to adjust inode sizes automatically you could
take that part out, and it will just crab sooner.
Given the non-attention in the code, I suspect nobody ever had cause to
try such a big minix filesystem. Well I have my reasons involving some
deeply embedded work where ext2 would place too much strain on the
hardware.
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Joshua Hudson <joshudson@gmail.com>
To make true the help text line that says that all commands
can be entered with either upper or lower case.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
For example when you move from a Partition to the FreeSapce then we
need to remove old extra info and draw nothing.
Signed-off-by: Karel Zak <kzak@redhat.com>
[disk-utils/cfdisk.c:1181] -> [disk-utils/cfdisk.c:1181]: (warning)
Possible null pointer dereference: data - otherwise it is redundant to
check it against null.
Signed-off-by: Boris Egorov <egorov@linux.com>
* removes list() label operation from internal API
The list() has been based on fdisk_info() it was useless for
anything else than print on stdout...
* add a new get_item() label operation and fdisk_get_disklabel_item() public API
The new API provides abstract and pretty simple way how to get label
specific disk label information, for example
fdisk_get_disklabel_item(cxt, GPT_LABELITEM_ENTRIESLBA, &iterm);
return LBA of the array with GPT entries.
Note that this patch does not implement public functions to get
data from the @item object.
* removes get_id() label operation -- it's subset of the new get_item()
* the new internal API is also used to implement backwardly compatible
fdisk_list_disklabel() and fdisk_get_disklabel_id()
Signed-off-by: Karel Zak <kzak@redhat.com>
Add the 'i'nfo command to fdisk that prints details about a specific partition.
Details are everything the function 'fdisk_label_get_field' can return.
Signed-off-by: Jean-Loup 'clippix' Bogalho <clippix@lse.epita.fr>
Fix regression introduced by commit 658c089: -r cannot be used as a last
option:
fsck -r /dev/sda1
fsck: invalid argument -r: '/dev/sda1'
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Make possible sending of statistics to a dedicated file descriptor.
Rationale: When UI is calling fsck from a remote terminal, fsck progress
needs to be sent to stdout. It is mixed there with output of statistics,
and it is impossible to parse the output to get the statistics.
Now it will be possible e. g. with "fsck -C -r 3 /dev/sda1"
Note: Code in if and else is intentionally partially duplicated. Current
human readable output of floats does not conform to locale conventions,
and may be changed in future. But we want to keep machine readable output
exactly same as it is now.
[kzak@redhat.com: - don't use report_stats_fd globally]
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
It's overkill to support all the obscure paths like /sbin/fs.d. We
have PATH for customization, that's enough.
It still seems like a good idea to keep fsck robust, because it's used
by boot scripts/systemd. For this reason fsck fallbacks to "/sbin" if
PATH is undefined or empty.
Signed-off-by: Karel Zak <kzak@redhat.com>
Rather than maintain a hardcoded search path for looking up tools and
override the user's PATH env setting, respect whatever the user has.
This matches the convention of just about every other tool out there.
It might break on systems that don't have /sbin in their PATH and they
try to run /sbin/mkfs directly, but so be it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The function uses "int" as argument, but for array size (and index) is better
to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk)
and "int" in lib/strutils.c then result is unexpected behavior on
ppc64.
# sfdisk --list -o DEVICE,START,SIZE /dev/sdb
Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 32768 bytes
Disklabel type: gpt
Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539
lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed.
The patch cleanup all code to use size_t everywhere.
Signed-off-by: Karel Zak <kzak@redhat.com>