]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: cleanup options
authorKarel Zak <kzak@redhat.com>
Thu, 8 Dec 2022 10:12:47 +0000 (11:12 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 8 Dec 2022 10:12:47 +0000 (11:12 +0100)
* add missing stuff to bash-completion
* reorder --help output
* reorder man page

Signed-off-by: Karel Zak <kzak@redhat.com>
bash-completion/hardlink
misc-utils/hardlink.1.adoc
misc-utils/hardlink.c

index 75b8b9ccfe9192df4154076f2fc3beb7870c1296..a7f197d48a43bb3f0f1f68fb8cf9b67a26f825ee 100644 (file)
@@ -9,6 +9,34 @@ _hardlink_module()
                        COMPREPLY=( $(compgen -W "regex" -- $cur) )
                        return 0
                        ;;
+               '-i'|'--include')
+                       COMPREPLY=( $(compgen -W "regex" -- $cur) )
+                       return 0
+                       ;;
+               '-s'|'--minimum-size')
+                       COMPREPLY=( $(compgen -W "number" -- $cur) )
+                       return 0
+                       ;;
+               '-S'|'--maximum-size')
+                       COMPREPLY=( $(compgen -W "number" -- $cur) )
+                       return 0
+                       ;;
+               '-b'|'--io-size')
+                       COMPREPLY=( $(compgen -W "number" -- $cur) )
+                       return 0
+                       ;;
+               '-r'|'--cache-size')
+                       COMPREPLY=( $(compgen -W "number" -- $cur) )
+                       return 0
+                       ;;
+               '-y'|'--method')
+                       COMPREPLY=( $(compgen -W "sha256 sha1 crc32c memcmp" -- $cur) )
+                       return 0
+                       ;;
+               '--reflink')
+                       COMPREPLY=( $(compgen -W "never always auto" -- $cur) )
+                       return 0
+                       ;;
                '-H'|'--help'|'-V'|'--version')
                        return 0
                        ;;
@@ -17,10 +45,19 @@ _hardlink_module()
                -*)
                OPTS="
                        --content
+                       --respect-dir
+                       --respect-name
+                       --maximize
+                       --minimize
                        --dry-run
+                       --ignore-owner
+                       --keep-oldest
+                       --ignore-mode
+                       --quiet
+                       --ignore-time
                        --verbose
-                       --force
-                       --exclude
+                       --respect-xattrs
+                       --skip-reflinks
                        --version
                        --help
                "
index b0feb08c866fedc2e8deb3436906a15025f0c34b..a91c627e02a7b05fac7559bd1f5b9c743243b1c7 100644 (file)
@@ -42,43 +42,79 @@ are very often different from the beginning.
 
 include::man-common/help-version.adoc[]
 
-*-v*, *--verbose*::
-Verbose output, explain to the user what is being done. If specified once, every hardlinked file is displayed. If specified twice, it also shows every comparison.
-
-*-q*, *--quiet*::
-Quiet mode, don't print anything.
+*-c* *--content*::
+Consider only file content, not attributes, when determining whether two files are equal. Same as *-pot*.
 
-*-n*, *--dry-run*::
-Do not act, just print what would happen.
+*-b*, *--io-size* _size_::
+The size of the *read*(2) or *sendfile*(2) buffer used when comparing file contents.
+The _size_ argument may be followed by the multiplicative suffixes KiB, MiB,
+etc.  The "iB" is optional, e.g., "K" has the same meaning as "KiB". The
+default is 8KiB for memcmp method and 1MiB for the other methods. The only
+memcmp method uses process memory for the buffer, other methods use zero-copy
+way and I/O operation is done in the kernel. The size may be altered on the fly
+to fit a number of cached content checksums.
 
-*-y*, *--method* _name_::
-Set the file content comparison method. The currently supported methods are
-sha256, sha1, crc32c and memcmp. The default is sha256, or memcmp if Linux
-Crypto API is not available. The methods based on checksums are implemented in
-zero-copy way, in this case file contents are not copied to the userspace and all
-calculation is done in kernel.
+*-d*, *--respect-dir*::
+Only try to link files with the same directory name. The top-level directory (as specified on the hardlink command line) is ignored. For example, *hardlink --respect-dir /foo /bar* will link /foo/some/file with /bar/some/file, but not /bar/other/file. If combined with *--respect-name*, then entire paths (except the top-level directory) are compared.
 
 *-f*, *--respect-name*::
 Only try to link files with the same (base)name. It's strongly recommended to use long options rather than *-f* which is interpreted in a different way by other *hardlink* implementations.
 
-*-d*, *--respect-dir*::
-Only try to link files with the same directory name. The top-level directory (as specified on the hardlink command line) is ignored. For example, *hardlink --respect-dir /foo /bar* will link /foo/some/file with /bar/some/file, but not /bar/other/file. If combined with *--respect-name*, then entire paths (except the top-level directory) are compared.
+*-i*, *--include* _regex_::
+A regular expression to include files. If the option *--exclude* has been given, this option re-includes files which would otherwise be excluded. If the option is used without *--exclude*, only files matched by the pattern are included.
 
-*-p*, *--ignore-mode*::
-Link and compare files even if their mode is different. Results may be slightly unpredictable.
+*-m*, *--maximize*::
+Among equal files, keep the file with the highest link count.
+
+*-M*, *--minimize*::
+Among equal files, keep the file with the lowest link count.
+
+*-n*, *--dry-run*::
+Do not act, just print what would happen.
 
 *-o*, *--ignore-owner*::
 Link and compare files even if their owner information (user and group) differs. Results may be unpredictable.
 
+*-O*, *--keep-oldest*::
+Among equal files, keep the oldest file (least recent modification time). By default, the newest file is kept. If *--maximize* or *--minimize* is specified, the link count has a higher precedence than the time of modification.
+
+*-p*, *--ignore-mode*::
+Link and compare files even if their mode is different. Results may be slightly unpredictable.
+
+*-q*, *--quiet*::
+Quiet mode, don't print anything.
+
+*-r*, *--cache-size* _size_::
+The size of the cache for content checksums. All non-memcmp methods calculate checksum for each
+file content block (see *--io-size*), these checksums are cached for the next comparison. The
+size is important for large files or a large sets of files of the same size. The default is
+10MiB.
+
+*-s*, *--minimum-size* _size_::
+The minimum size to consider. By default this is 1, so empty files will not be linked. The _size_ argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
+
+*-S*, *--maximum-size* _size_::
+The maximum size to consider. By default this is 0 and 0 has the special meaning of unlimited. The _size_ argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
+
 *-t*, *--ignore-time*::
 Link and compare files even if their time of modification is different. This is usually a good choice.
 
-*-c* *--content*::
-Consider only file content, not attributes, when determining whether two files are equal. Same as *-pot*.
+*-v*, *--verbose*::
+Verbose output, explain to the user what is being done. If specified once, every hardlinked file is displayed. If specified twice, it also shows every comparison.
+
+*-x*, *--exclude* _regex_::
+A regular expression which excludes files from being compared and linked.
 
 *-X*, *--respect-xattrs*::
 Only try to link files with the same extended attributes.
 
+*-y*, *--method* _name_::
+Set the file content comparison method. The currently supported methods are
+sha256, sha1, crc32c and memcmp. The default is sha256, or memcmp if Linux
+Crypto API is not available. The methods based on checksums are implemented in
+zero-copy way, in this case file contents are not copied to the userspace and all
+calculation is done in kernel.
+
 *--reflink*[=_when_]::
 Create copy-on-write clones (aka reflinks) rather than hardlinks. The reflinked files
 share only on-disk data, but the file mode and owner can be different. It's recommended
@@ -94,41 +130,6 @@ only reflinks are allowed.
 *--skip-reflinks*::
 Ignore already cloned files. This option may be used without *--reflink* when creating classic hardlinks.
 
-*-m*, *--maximize*::
-Among equal files, keep the file with the highest link count.
-
-*-M*, *--minimize*::
-Among equal files, keep the file with the lowest link count.
-
-*-O*, *--keep-oldest*::
-Among equal files, keep the oldest file (least recent modification time). By default, the newest file is kept. If *--maximize* or *--minimize* is specified, the link count has a higher precedence than the time of modification.
-
-*-x*, *--exclude* _regex_::
-A regular expression which excludes files from being compared and linked.
-
-*-i*, *--include* _regex_::
-A regular expression to include files. If the option *--exclude* has been given, this option re-includes files which would otherwise be excluded. If the option is used without *--exclude*, only files matched by the pattern are included.
-
-*-s*, *--minimum-size* _size_::
-The minimum size to consider. By default this is 1, so empty files will not be linked. The _size_ argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
-
-*-S*, *--maximum-size* _size_::
-The maximum size to consider. By default this is 0 and 0 has the special meaning of unlimited. The _size_ argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
-
-*-b*, *--io-size* _size_::
-The size of the *read*(2) or *sendfile*(2) buffer used when comparing file contents.
-The _size_ argument may be followed by the multiplicative suffixes KiB, MiB,
-etc.  The "iB" is optional, e.g., "K" has the same meaning as "KiB". The
-default is 8KiB for memcmp method and 1MiB for the other methods. The only
-memcmp method uses process memory for the buffer, other methods use zero-copy
-way and I/O operation is done in the kernel. The size may be altered on the fly
-to fit a number of cached content checksums.
-
-*-r*, *--cache-size* _size_::
-The size of the cache for content checksums. All non-memcmp methods calculate checksum for each
-file content block (see *--io-size*), these checksums are cached for the next comparison. The
-size is important for large files or a large sets of files of the same size. The default is
-10MiB.
 
 == ARGUMENTS
 
index d73974be90f78f75f063f69b00db3dd21f1d0f6e..3a6b5df8ace578f067f65cdd63ba5734acd184e6 100644 (file)
@@ -1161,37 +1161,36 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_("Consolidate duplicate files using hardlinks.\n"), out);
 
        fputs(USAGE_OPTIONS, out);
-       fputs(_(" -v, --verbose              verbose output (repeat for more verbosity)\n"), out);
-       fputs(_(" -q, --quiet                quiet mode - don't print anything\n"), out);
-       fputs(_(" -n, --dry-run              don't actually link anything\n"), out);
-       fputs(_(" -y, --method <name>        file content comparison method\n"), out);
-
-       fputs(_(" -f, --respect-name         filenames have to be identical\n"), out);
+       fputs(_(" -c, --content              compare only file contents, same as -pot\n"), out);
+       fputs(_(" -b, --io-size <size>       I/O buffer size for file reading\n"
+               "                              (speedup, using more RAM)\n"), out);
        fputs(_(" -d, --respect-dir          directory names have to be identical\n"), out);
-       fputs(_(" -p, --ignore-mode          ignore changes of file mode\n"), out);
+       fputs(_(" -f, --respect-name         filenames have to be identical\n"), out);
+       fputs(_(" -i, --include <regex>      regular expression to include files/dirs\n"), out);
+       fputs(_(" -m, --maximize             maximize the hardlink count, remove the file with\n"
+               "                              lowest hardlink count\n"), out);
+       fputs(_(" -M, --minimize             reverse the meaning of -m\n"), out);
+       fputs(_(" -n, --dry-run              don't actually link anything\n"), out);
        fputs(_(" -o, --ignore-owner         ignore owner changes\n"), out);
+       fputs(_(" -O, --keep-oldest          keep the oldest file of multiple equal files\n"
+               "                              (lower precedence than minimize/maximize)\n"), out);
+       fputs(_(" -p, --ignore-mode          ignore changes of file mode\n"), out);
+       fputs(_(" -q, --quiet                quiet mode - don't print anything\n"), out);
+       fputs(_(" -r, --cache-size <size>    memory limit for cached file content data\n"), out);
+       fputs(_(" -s, --minimum-size <size>  minimum size for files.\n"), out);
+       fputs(_(" -S, --maximum-size <size>  maximum size for files.\n"), out);
        fputs(_(" -t, --ignore-time          ignore timestamps (when testing for equality)\n"), out);
-       fputs(_(" -c, --content              compare only file contents, same as -pot\n"), out);
+       fputs(_(" -v, --verbose              verbose output (repeat for more verbosity)\n"), out);
+       fputs(_(" -x, --exclude <regex>      regular expression to exclude files\n"), out);
 #ifdef USE_XATTR
        fputs(_(" -X, --respect-xattrs       respect extended attributes\n"), out);
 #endif
+       fputs(_(" -y, --method <name>        file content comparison method\n"), out);
+
 #ifdef USE_REFLINK
        fputs(_("     --reflink[=<when>]     create clone/CoW copies (auto, always, never)\n"), out);
        fputs(_("     --skip-reflinks        skip already cloned files (enabled on --reflink)\n"), out);
 #endif
-       fputs(_(" -m, --maximize             maximize the hardlink count, remove the file with\n"
-               "                              lowest hardlink count\n"), out);
-       fputs(_(" -M, --minimize             reverse the meaning of -m\n"), out);
-       fputs(_(" -O, --keep-oldest          keep the oldest file of multiple equal files\n"
-               "                              (lower precedence than minimize/maximize)\n"), out);
-       fputs(_(" -x, --exclude <regex>      regular expression to exclude files\n"), out);
-       fputs(_(" -i, --include <regex>      regular expression to include files/dirs\n"), out);
-       fputs(_(" -s, --minimum-size <size>  minimum size for files.\n"), out);
-       fputs(_(" -S, --maximum-size <size>  maximum size for files.\n"), out);
-       fputs(_(" -b, --io-size <size>       I/O buffer size for file reading\n"
-               "                              (speedup, using more RAM)\n"), out);
-       fputs(_(" -r, --cache-size <size>    memory limit for cached file content data\n"), out);
-
        fputs(USAGE_SEPARATOR, out);
        printf(USAGE_HELP_OPTIONS(28));
        printf(USAGE_MAN_TAIL("hardlink(1)"));