Commit Graph

25 Commits

Author SHA1 Message Date
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak 374cb54381 fincore: remove unused variable [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:27:15 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 8945d9dc63 fincore: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:32:39 +02:00
Tobias Stoeckmann fcfe1a5cde fincore: Handle large files on 32 bit without LFS
If util-linux is installed on a system without large file support,
an out of memory issue can occur while processing a file which is
2 GB in size:

$ ./configure --disable-largefile && make

$ dd if=/dev/zero of=2gb-file seek=2147483646 count=1 bs=1
$ fincore 2gb-file
(endless loop)
fincore: failed to do mmap: 2gb-file: Cannot allocate memory

Even though iterating with "len" seems counter-intuitive, it fixes
this issue. The variable len is only in the last iteration not a
multiplication of pagesize -- which is the requirement for mmap.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Tobias Stoeckmann ea62c15276 fincore: Handle large files correctly on 32 bit
If a file is larger than 4 GB on a 32 bit system with large file
support (default), it can happen that not all pages are properly
processed. This happens due to an int truncation (off_t vs size_t).

You can reproduce this on 32 bit with these commands:

$ dd if=/dev/zero of=4gb-file seek=4294967295 count=1 bs=1
$ fincore 4gb-file
fincore: failed to do mmap: 4gb-file: Invalid argument

If a file is larger than 4 GB, the first few pages of a file won't
be properly processed. "len" will be smaller than window_size,
but the for-loop iterates "window_size" bytes, skipping some pages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Karel Zak 5794087292 fincore: make sure mmap(NULL, ...) [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 12:44:55 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
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>
2017-06-26 14:38:24 +02:00
Karel Zak c3a4cfc579 misc: consolidate usage() "Available columns"
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:09:53 +02:00
Yuri Chornoivan 0508f347c8 Fix minor typos 2017-05-24 00:22:20 +03:00
Karel Zak 780ce22cda misc: consolidate smartcols error messages
... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 11:39:34 +02:00
Karel Zak b7ebf49c9b fincore: check rc from smartcols stuff [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 13:08:33 +02:00
Sami Kerola b9dc8d071d fincore: fix file descriptor leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-10 15:40:39 +02:00
Karel Zak 452089fa2f fincore: use size_t everywhere
It seems better to avoid "int" at all from sizes calculations to make
the code more robust for future changes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-06 12:40:01 +02:00
Ruediger Meier 379c1a52a2 fincore: fix multiplication overflow
This failed on ppc64 with page size 64k.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-06 12:30:09 +02:00
Karel Zak e4e8b57be2 fincore: add column RES
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-27 13:08:40 +02:00
Karel Zak cff1c113fe fincore: fix error on open()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 15:28:05 +01:00
Karel Zak 9b48766fb3 fincore: add --raw and --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:34:12 +01:00
Karel Zak c5cb541299 fincore: add --output
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:27:42 +01:00
Karel Zak 3f91dd88ca fincore: add --bytes and --noheadings
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:17:46 +01:00
Karel Zak 3e37d7b773 fincore: use libsmartcols
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:09:20 +01:00
Karel Zak b57fe43cd4 fincore: cleanup return codes
Don't use EXIT_* macros as functions return code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 13:07:06 +01:00
Masatake YAMATO a921a7dea9 fincore: new command for counting pages of file contents in core
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 12:46:09 +01:00