summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2019-02-11 14:01:55 +0100
committerKarel Zak2019-02-11 14:01:55 +0100
commit985421192df68af82a9eaa93f6426d64bccf9cdc (patch)
tree3c0accf8cb9922b8ecbff6a215422b19d63361d0 /misc-utils
parenthardlink: rename function (diff)
downloadkernel-qcow2-util-linux-985421192df68af82a9eaa93f6426d64bccf9cdc.tar.gz
kernel-qcow2-util-linux-985421192df68af82a9eaa93f6426d64bccf9cdc.tar.xz
kernel-qcow2-util-linux-985421192df68af82a9eaa93f6426d64bccf9cdc.zip
hardlink: add long options
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/hardlink.139
-rw-r--r--misc-utils/hardlink.c21
2 files changed, 37 insertions, 23 deletions
diff --git a/misc-utils/hardlink.1 b/misc-utils/hardlink.1
index c7500b5a9..c564fd76a 100644
--- a/misc-utils/hardlink.1
+++ b/misc-utils/hardlink.1
@@ -2,8 +2,9 @@
.SH "NAME"
hardlink \- Consolidate duplicate files via hardlinks
.SH "SYNOPSIS"
-.PP
-\fBhardlink\fP [\fB-c\fP] [\fB-n\fP] [\fB-v\fP] [\fB-vv\fP] [\fB-x pattern\fP] [\fB-h\fP] directory1 [ directory2 ... ]
+.B hardlink
+[options]
+.RI [ directory ...]
.SH "DESCRIPTION"
.PP
This manual page documents \fBhardlink\fP, a
@@ -20,29 +21,37 @@ on a single filesystem contain many duplicate files.
Since hard links can only span a single filesystem, \fBhardlink\fP
is only useful when all directories specified are on the same filesystem.
.SH "OPTIONS"
-.PP
-.IP "\fB-c\fP" 10
+.TP
+.BR \-c , " \-\-content"
Compare only the contents of the files being considered for consolidation.
Disregards permission, ownership and other differences.
-.IP "\fB-f\fP" 10
+.TP
+.BR \-f , " \-\-force"
Force hardlinking across file systems.
-.IP "\fB-n\fP" 10
+.TP
+.BR \-n , " \-\-dry\-run"
Do not perform the consolidation; only print what would be changed.
-.IP "\fB-v\fP" 10
-Print summary after hardlinking.
-.IP "\fB-vv\fP" 10
-Print every hardlinked file and bytes saved. Also print summary after hardlinking.
-.IP "\fB-x pattern\fP" 10
+.TP
+.BR \-v , " \-\-verbose"
+Print summary after hardlinking. The option may be specified more than once. In
+this case (e.g. \fB-vv\fP) it prints every hardlinked file and bytes saved.
+.TP
+.BR \-x , " \-\-exclude " \fIregex\f
Exclude files and directories matching pattern from hardlinking.
-.IP "\fB-h\fP" 10
-Show help.
-.PP
+.sp
The optional pattern for excluding files and directories must be a PCRE2
compatible regular expression. Only the basename of the file or directory
is checked, not its path. Excluded directories' contents will not be examined.
+.TP
+.BR \-h , " \-\-help"
+Display help text and exit.
+.TP
+.BR \-V , " \-\-version"
+Display version information and exit.
.SH "AUTHOR"
.PP
-\fBhardlink\fP was written by Jakub Jelinek <jakub@redhat.com>.
+\fBhardlink\fP was written by Jakub Jelinek <jakub@redhat.com> and later modified by
+Ruediger Meier <ruediger.meier@ga-group.nl> and Karel Zak <kzak@redhat.com> for util-linux.
.PP
Man page written by Brian Long and later updated by Jindrich Novy <jnovy@redhat.com>
.SH "BUGS"
diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c
index 3e05ea505..1558573f7 100644
--- a/misc-utils/hardlink.c
+++ b/misc-utils/hardlink.c
@@ -141,12 +141,12 @@ static void __attribute__((__noreturn__)) usage(void)
puts(_("Consolidate duplicate files using hardlinks."));
fputs(USAGE_OPTIONS, stdout);
- puts(_(" -c when finding candidates for linking, compare only file contents"));
- puts(_(" -n don't actually link anything, just report what would be done"));
- puts(_(" -v print summary after hardlinking"));
- puts(_(" -vv print every hardlinked file and bytes saved + summary"));
- puts(_(" -f force hardlinking across filesystems"));
- puts(_(" -x <regex> exclude files matching pattern"));
+ puts(_(" -c, --content compare only contents, ignore permission, etc."));
+ puts(_(" -n, --dry-run don't actually link anything"));
+ puts(_(" -v, --verbose print summary after hardlinking"));
+ puts(_(" -vv print every hardlinked file and summary"));
+ puts(_(" -f, --force force hardlinking across filesystems"));
+ puts(_(" -x, --exclude <regex> exclude files matching pattern"));
fputs(USAGE_SEPARATOR, stdout);
printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */
@@ -400,8 +400,13 @@ int main(int argc, char **argv)
struct hardlink_dynstr nam1 = { NULL, 0 };
static const struct option longopts[] = {
- { "version", no_argument, NULL, 'V' },
+ { "content", no_argument, NULL, 'c' },
+ { "dry-run", no_argument, NULL, 'n' },
+ { "exclude", required_argument, NULL, 'x' },
+ { "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 },
};
@@ -429,7 +434,7 @@ int main(int argc, char **argv)
exclude_pattern = (PCRE2_SPTR) optarg;
#else
errx(EXIT_FAILURE,
- _("option -x not supported (built without pcre2)"));
+ _("option --exclude not supported (built without pcre2)"));
#endif
break;
case 'V':