Commit Graph

59 Commits

Author SHA1 Message Date
Karel Zak 8ff8b02782 hardlink: small regex stuff refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:58:14 +02:00
Karel Zak 634636301e hardlink: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:45:16 +02:00
Karel Zak 01480c61e1 hardlink: fix typo again
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-19 15:30:57 +02:00
Karel Zak 35d5db6ebb hardlink: fix typo
Reported-by: Mario Blättermann <mario.blaettermann@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-19 10:10:17 +02:00
Karel Zak 5c7cac85c9 hardlink: fix indention
The original Julian's hardlink.c code is pretty readable, but for
util-linux we use a little different indention (aka Linux kernel
coding style).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 4c467ebc5c hardlink: add --quiet option
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 5034cd9f2b hardlink: s/DEBUG/VERBOSE/
We usually use "debug" for very detailed information. For end-user
information is better to talk about "verbose" output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 82e32c0659 hardlink: translate verbose messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 053ef448a6 hardlink: cleanup summary
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 423e80c1e9 hardlink: use size_to_human_string()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 3c52b1c83c hardlink: use only err.h to print errors and warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 06d8fe8909 hardlink: use monotonic time like other utils
- use out gettime_monotonic()
- use timeval for calculation rather than double

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak ec194114e1 hardlink: use errx() when parse options
Don't waste time with some cleanup on --exclude and --include regex
errors.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak c12b639443 hardlink: use err() if possible
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 631e6865e3 hardlink: cleanup --minimum-size stuff
* use uintmax_t
* use strtosize_or_err()
* add info about suffixes to man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 9e7235e7e0 hardlink: move default to options initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak d2c3c5a684 hardlink: cleanup usage()
Let's make --help more util-linux compatible.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 0361f7440c hardlink: use our xalloc.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 40b119b990 hardlink: check and use sys/xattr.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 43989bad9e hardlink: use PRCE2 posix header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak cd6b8d3926 hardlink: cleanup includes and types
* use config.h like other code on package
* use c.h and remove from code stuff defined in the header file
* remove FALSE/TRUE redefinition

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 2180ecc81b hardlink: replace with code from Debian
The current version used in util-linux is based on original code from
Jakub Jelinek.

The new version is based on Debian implementation from
https://salsa.debian.org/jak/hardlink.  This new version uses nftw()
to walk on directories tree and organize internal data binary tree
(tsearch() and twalk()). This new version provides more features like
--ignore-{mode,owner,time}, --respect-xattrs, --respect-name,
--include, --keep-oldest, --minimize, --maximize, etc.

Note that the new version uses -f for --respect-name, the old version
uses -f to hardlinking across filesystems (very probably rarely unused
feature).

Addresses: https://github.com/karelzak/util-linux/issues/808
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Sami Kerola dab057ebd2 hardlink: fix hardlink pcre leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-16 11:25:11 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Karel Zak ac255c2b14 hardlink: avoid uninitialized variables [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:12:07 +02:00
Karel Zak 74a4d22078 hardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]
misc-utils/hardlink.c: In function ‘process_path’:
misc-utils/hardlink.c:287:30: warning: operand of ?: changes signedness from ‘off_t’ {aka ‘long int’} to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]

misc-utils/hardlink.c: In function ‘main’:
misc-utils/hardlink.c:455:5: warning: ‘exclude_pattern’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02 12:48:05 +02:00
Sami Kerola e2aa5d82b9
hardlink: retire NIOBUF in favour of more common BUFSIZ
Reason to retire NIOBUF is that it is obscure local definition, while BUFSIZ
is well understood and commonly used constant.  Besized sizes of these are
not far off, the NIOBUF was 4096 bytes and BUFSIZ tends to be 8192 bytes.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/783
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 20:19:19 +01:00
Sami Kerola 007b9874d8
hardlink: move global variables to a control structure
Well, sort of.  Due to use of ctl values in atexit() print_summary() there
is need for global control structure.

Secondly couple variables can be moved to more restricted scope, namely the
PCRE variables are now in main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:49:07 +01:00
Sami Kerola e87263aa13
hardlink: use flexible array member rather than zero-size array
This fixes two standards compliancy warnings.

hardlink.c:65:7: warning: ISO C forbids zero-size array ‘name’ [-Wpedantic]

Reference: https://en.wikipedia.org/wiki/Flexible_array_member
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:37:54 +01:00
Karel Zak 08a2cf7292 hardlink: remove \r from output
* remove \r from internationalized messages
* remove \r from all output to make it easy to use (see for example
  output file from "hardlink -vv --dry-run . &> log")

* remove unnecessary formatting stuff from output, just keep is simple
  and stupid...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-24 18:31:08 +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
Sami Kerola 123eb9ef8c hardlink, wall: fix variable shadowing
misc-utils/hardlink.c:91:65: warning: declaration shadows a variable in the global scope [-Wshadow]
misc-utils/hardlink.c:73:5: note: previous declaration is here
int content_only = 0;

term-utils/wall.c:114:40: warning: declaration shadows a variable in the global scope [-Wshadow]
term-utils/wall.c:129:65: warning: declaration shadows a variable in the global scope [-Wshadow]
/usr/include/bits/getopt_core.h:36:14: note: previous declaration is here
extern char *optarg;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:20:34 +01:00
Karel Zak 985421192d hardlink: add long options
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 14:01:55 +01:00
Karel Zak c8ca29beb2 hardlink: rename function
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:30:46 +01:00
Karel Zak bd7722af02 hardlink: make code more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:25:04 +01:00
Karel Zak 0b05aab402 hardlink: cleanup global variables
* remove NAMELEN, use PATH_MAX
* mark global variables as static
* move all global variables to the begin of the code

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:18:35 +01:00
Karel Zak 3807e71af4 hardlink: remove typedefs
- remove typedefs
- use long names for structs

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:00:18 +01:00
Karel Zak d55db6724c hardlink: cleanup error messages, use xalloc.h
- do not use magical doexit(), just use err()
- print summary on exit

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:23:54 +01:00
Karel Zak c545e62c68 hardlink: cleanup verbose and warning messages
- use warn()
- use stdout rather than stderr

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:14:01 +01:00
Ruediger Meier 7d50d36121 hardlink: util-linux usage
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:14 +01:00
Ruediger Meier 53071734aa hardlink: fix compiler warnings
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:04 +01:00
Ruediger Meier 55c000e1eb hardlink: style indentations and license header
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:44:39 +01:00
Ruediger Meier 04ae85a7e5 hardlink: enable build with and without pcre2
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:40:33 +01:00
Francisco Javier Tsao Santín c64d7e60b1 Fixed version number, added changelog about Todd Lewis' patch 2018-06-12 14:24:04 +02:00
Todd Lewis 551e8963f4 exclude files via pcre 2018-06-12 14:24:02 +02:00
Francisco Javier Tsao Santín 92c79dc79e Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989) 2018-06-12 14:23:57 +02:00
Francisco Javier Tsao Santín 4d072ba715 spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file 2018-06-12 14:23:55 +02:00
Francisco Javier Tsao Santín cbb0524c7c Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
This reverts commit bb9e76ae339794c2243ae294207942b7ea278364.
2018-06-12 14:23:52 +02:00
Francisco Javier Tsao Santín c11af66f0f spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file 2018-06-12 14:23:49 +02:00
Jindrich Novy c23b4a2305 do not allow to hardlink files across filesystems by default (#786719)
(use -f option to override)
2018-06-12 14:23:44 +02:00