Commit Graph

39 Commits

Author SHA1 Message Date
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
Jindrich Novy 94b040b06b fix possible buffer overflows, integer overflows, update man page 2018-06-12 14:23:41 +02:00
Jindrich Novy 0cd6b1d353 fix URL and remove mmap() (#676962, #672917) 2018-06-12 14:23:38 +02:00
Jindrich Novy a272f143e7 - update docs to describe highest verbosity -vv option (#210816)
- use dist Resolves: 210816
2018-06-12 14:23:35 +02:00
Jindrich Novy b4ece7768f mostly spec cleanup 2018-06-12 14:23:31 +02:00
Jindrich Novy cabf1c1cb7 add -h option 2018-06-12 14:23:25 +02:00
Dave Jones a810992a72 Document hardlink command line options. (Ville Skytta) (#161738) 2018-06-12 14:23:03 +02:00
Jeremy Katz a16d7294a8 - don't try to hardlink 0 byte files (#154404) 2018-06-12 14:22:59 +02:00
Dave Jones 5edefc9242 kill warning 2018-06-12 14:22:54 +02:00
Dave Jones 0ec20db824 auto-import hardlink-1.0-1.1 on branch devel from hardlink-1.0-1.1.src.rpm 2018-06-12 14:22:47 +02:00