Commit Graph

66 Commits

Author SHA1 Message Date
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
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>
2017-02-20 12:58:49 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak 2687686cf4 cramfs: revert crc32 changes
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>
2016-10-19 13:33:15 +02:00
Karel Zak 98fd13a169 cramfs: add missing includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-19 12:17:19 +02:00
Gustavo Zacarias 7f0d4d56a2 lib/crc32: prefix public functions
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>
2016-10-19 12:11:59 +02:00
Karel Zak 090d8c763a include/closestream: define exit codes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 13:35:06 +02:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak 101c80f316 mkfs.cramfs: remove dead code [coverity scan]
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>
2015-08-04 11:33:57 +02:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Sami Kerola 338a6bc55b textual: improve error messages
Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:22 +01:00
Sami Kerola 9cbf20040b mkfs.cramfs: use defined failure name rather than magic value
From manual page; 'On error, the value MAP_FAILED is returned, and errno
is set appropriately'.

Reference: http://man7.org/linux/man-pages/man2/mmap.2.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:32 +01:00
Ruediger Meier ae2f9c71ae mkfs.cramfs: fix crash when -b 0
Now -b 0 gives us the default (page size) like we do it in
fsck.cramfs.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-19 23:49:29 +02:00
Sami Kerola a149ad39e8 mkfs.cramfs: argument to free() is a constant address [clang-analyzer]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:25:08 +02:00
Benno Schulenberg 97b820bffd textual: improve clarity of some error messages
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:29:44 +02:00
Karel Zak 28b856ff88 mkfs.cramfs: use standard error message
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-14 23:54:07 +02:00
Sami Kerola 393fb46501 mkfs.cramfs: unify write check to a file descriptor
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:07 +02:00
Karel Zak 1544dea1c9 mkfs.cramfs: fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:18:33 +01:00
Karel Zak 985b351ed8 mkfs.cramfs: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:15:37 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola 9481c7b33b mkfs.cramfs: disallow unknown command line options
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Petr Uzel f9f19b8f7f mkfs.cramfs: remove unused 'MIN' macro definition
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-23 09:56:51 +02:00
Karel Zak 33fb5cfd49 disk-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:43:32 +02:00
Sami Kerola 45ca68ece7 disk-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 20:04:39 +02:00
Karel Zak 70b604b827 include/exitcodes: clean up names, add _EX_ suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Sami Kerola 2e24868683 mkfs.cramfs: check blocksize user input [cppcheck]
Enhance user input checking and error messaging, while fixing
cppcheck warning.

[disk-utils/mkfs.cramfs.c:729]: (style) Checking if unsigned variable 'blksize' is less than zero.

[kzak@redhat.com: fix coding style]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-08 12:46:11 +01:00
Sami Kerola 33f28cd7a7 mkfs.cramfs: close open file after usage [cppcheck]
[disk-utils/mkfs.cramfs.c:913]: (error) Resource leak: fd

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-08 12:39:10 +01:00
Arnaud Mouiche 8b472bfa73 small bug in mkfs.cramfs + patch
mkfs.cramfs on version v2.17.2 has a small bug when dealing with very small
filesystems.  look at upstream code on git, and the issue is still here.
ex:

         $ cd /tmp
         $ mkdir content
         $ echo hello > content/a
         $ echo hello > content/b
         $ mkfs.cramfs content content.cramfs
         not enough space allocated for ROM image (4090 allocated, 4096 used)

Here is a patch for fixing (simply rounding to page size AFTER eleminating
doubles).

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-23 13:29:32 +01:00
Benno Schulenberg f770a404bf mkfs.cramfs: clearer error message, "cannot close" instead of "closing"
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:18 +02:00
Sami Kerola b8f040cdd4 include: move disk-utils/mkfs.h -> include/exitcodes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:30:04 +02:00
Sami Kerola 18dad87a27 mkfs.cramfs: coding style
Clean up to two if clauses and fix to a version print out format.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:07:40 +02:00
Sami Kerola 2b760a594b mkfs.cramfs: include-what-you-use header check
add these lines:
 #include <stddef.h> // for size_t
 #include <zconf.h> // for Bytef, uLongf

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:00:28 +02:00
Sami Kerola 16154b1fcf mkfs.cramfs: error printing fixes
The patch will fix few starange looking errors such as:

$ mkfs.cramfs -N foo
invalid endianness given. Must be 'big', 'little', or 'host': Success

to be more sensible:
mkfs.cramfs: invalid endianness given. Must be 'big', 'little', or 'host'

And there are couple new return value checks to stop command if
out file cannot be opened, or an IO error occurs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:00:28 +02:00
Sami Kerola 11bcb6523a mkfs.cramfs: convert spaces to tabs
The conversion is applied only to the line beginnings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:00:27 +02:00
Sami Kerola 64ab88d770 mkfs.cramfs: validate numeric user inputs
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:00:10 +02:00
Sami Kerola 9d9fb355a1 mkfs.cramfs: few symbolic exit codes where missing
This makes commit 89f56db184 complete.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:49 +02:00
Sami Kerola e429d14106 md5: use symbolical digest length
Magic hash lenght number 16 is turned to a definition MD5LENGTH,
and put into use everywhere where md5 checksum is in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:48 +02:00
Sami Kerola 5260748c28 mkfs.cramfs: use program_invocation_short_name
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:48 +02:00
Sami Kerola ccaa52754e mkfs.cramfs: use xalloc.h
Before this commit two strdup calls, in line 366 and 374, where
able to fail silently and cause a rare bug.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:48 +02:00
Sami Kerola d51f37a368 cramfs: use stdint.h instead of u{8,16,32}
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 22:49:48 +02:00
Davidlohr Bueso 06f2558508 cramfs: remove cramfs_common.h
We currently have cramfs.h and cramfs_common.h, this makes no sense, so remove
unite them and keep just cramfs.h

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-05-17 16:30:08 +02:00
Davidlohr Bueso 9fae6c27d3 mkfs.minix: remove die()
Get rid of this function and use errx(3) instead. This patch also
introduces a mkfs.h header and defines general purpose mkfs related
exit codes.

[kzak@redhat.com: - fix "warning: too many arguments for format" errors]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-04 14:56:41 +02:00
Sami Kerola 89f56db184 mkfs.cramfs: use symbolic exit codes
For some reason original author had defined symbolic exit codes,
but had not use them. One could argue the symbolic exit codes for
mkfs should go to local exit header which would be included to
all commands that exit with non zero or one return code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-01-17 17:11:20 +01:00
Karel Zak 6f68ab6af0 mkfs.cramfs: fix gcc warning (incompatible pointer type)
mkfs.cramfs.c: In function ‘parse_directory’:
mkfs.cramfs.c:310: warning: passing argument 4 of ‘scandir’ from incompatible pointer type

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-29 13:56:37 +02:00
Roy Peled c17e59b4b3 mkfs.cramfs: lower memory requirements for layouts with duplicate files
mkfs.cramfs allocates memory based on a calculated upper-bound
of required filesystem size. If there are duplicate files
or hard links, the current implementation unnecessarily increases
the upper-bound per each copy of the file, even though cramfs does
not store copies of contents of identical files.

This patch improves the calculation of fslen_ub, the upper bound
of required filesystem size, by making the upper bound aware of
duplicate files.

This is very helpful for layouts that hold a lot of hard links,
which are seen as duplicate files by mkfs.cramfs. For example,
this drastically reduces the memory requirements for creating
a standard Busybox layout.

Signed-off-by: Roy Peled <the.roy.peled@gmail.com>
2009-02-04 15:08:20 +01:00
Signed-off-by: Roy Peled fbaec83bc0 mkfs.cramfs: add endianness support to cramfs tools
cramfs is an endianness dependent file system.  So far, the cramfs
utilities did not support cramfs images of different endianness than
the host machine.

A separate utility, cramfsswap, was required in order to change the
endianness of the image before and after using cramfs utilities. The
extra utility introduced extra maintenance and an additional step in
the process.

This patch adds endianness support to mkfs.cramfs and fsck.cramfs.
fsck.cramfs now automatically detects the image endianness, and can
work on images of either endianness.  mkfs.cramfs now accepts a new
optional parameter (-N) that allows creating the cramfs image in
either endianness.

Signed-off-by: Roy Peled <the.roy.peled@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-04 14:56:54 +01:00
Pedro Ribeiro 5044f6d7f0 mkfs.cramfs: several strings without gettext calls
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-10-03 08:35:16 +02:00