mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
187 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc8689a07c | ||
|
|
bec53850b7 | ||
|
|
541b026b11 | ||
|
|
606f54d157 | ||
|
|
6e2b4769cc | ||
|
|
3dc8657648 | ||
|
|
30039cb23a | ||
|
|
c0f02a8f5b | ||
|
|
a51af43294 | ||
|
|
ecb2fecdf9 | ||
|
|
4cb2742d70 | ||
|
|
26fd96a96c | ||
|
|
6259593ac7 | ||
|
|
f77a6352fb | ||
|
|
c45fcb2ed2 | ||
|
|
e0cce6b62a | ||
|
|
7ebbeeb03d | ||
|
|
7b2064216c | ||
|
|
5a1d00e450 | ||
|
|
ff42adb55e | ||
|
|
193449b173 | ||
|
|
91e69cd2d0 | ||
|
|
1913bfcf57 | ||
|
|
5d3fd24f42 | ||
|
|
425b8a2f53 | ||
|
|
07a69fc3ba | ||
|
|
a46f34bb56 | ||
|
|
bf73a7602a | ||
|
|
48cd67663d | ||
|
|
dda89eb5d3 | ||
|
|
c07a7d999e | ||
|
|
b8d1b00e21 | ||
|
|
c7f422940a | ||
|
|
0cafa1524f | ||
|
|
00a34a05f5 | ||
|
|
9a50494875 | ||
|
|
44c9578a08 | ||
|
|
ab4ffc8503 | ||
|
|
c1cf5148a1 | ||
|
|
7b92e9fb26 | ||
|
|
9d8890d872 | ||
|
|
fea833591b | ||
|
|
c877c7c1ee | ||
|
|
6cd2d5e533 | ||
|
|
fcfba90d0d | ||
|
|
e397ba1a31 | ||
|
|
f3bcb59ebd | ||
|
|
79c628901d | ||
|
|
f2e70e2d19 | ||
|
|
df5fa309c2 | ||
|
|
45411e3fc6 | ||
|
|
feda512e97 | ||
|
|
49912bac28 | ||
|
|
9907b6f5dc | ||
|
|
3bbdb39388 | ||
|
|
10be42f033 | ||
|
|
d9dc02b09a | ||
|
|
7f57ac2d20 | ||
|
|
9b6c25510b | ||
|
|
a357cfb021 | ||
|
|
e82af7c2e6 | ||
|
|
430663cb35 | ||
|
|
8e3b0feb1d | ||
|
|
ad4a9d02f5 | ||
|
|
01e52b9adc | ||
|
|
0a33c5384f | ||
|
|
e298046727 | ||
|
|
0fee70a9ff | ||
|
|
aed1aa29db | ||
|
|
d39c523728 | ||
|
|
afa5d70c0d | ||
|
|
f85472082c | ||
|
|
76604db7d2 | ||
|
|
6ec1fb46ab | ||
|
|
c01ee18934 | ||
|
|
aa50ea55ea | ||
|
|
c4c5ed8f4e | ||
|
|
b09dc6306e | ||
|
|
f07f5b008f | ||
|
|
a966dcdb69 | ||
|
|
752ccef3eb | ||
|
|
a9e4725773 | ||
|
|
b8f0502bb1 | ||
|
|
8a757c220b | ||
|
|
1f651f4b3d | ||
|
|
9e67ccd745 | ||
|
|
76ec516242 | ||
|
|
ebb985dc41 | ||
|
|
4dda343663 | ||
|
|
9cc8d6ff59 | ||
|
|
98d463ef5d | ||
|
|
343b8d7ba7 | ||
|
|
c343bee1b5 | ||
|
|
63e9f1ae61 | ||
|
|
da091b3ab3 | ||
|
|
0d9547474d | ||
|
|
4de72b7d9f | ||
|
|
49c8dab5b2 | ||
|
|
9becda5d93 | ||
|
|
0ee8b03422 | ||
|
|
73d119f4f8 | ||
|
|
615167cc4d | ||
|
|
74b9d6a6e8 | ||
|
|
0ed9d1823a | ||
|
|
77201c506f | ||
|
|
3bee7c9754 | ||
|
|
a72b7823b4 | ||
|
|
a257b63ce7 | ||
|
|
23e26ed972 | ||
|
|
3e0d7787e6 | ||
|
|
4c15a1b6e6 | ||
|
|
394b29aaff | ||
|
|
7f2c97a241 | ||
|
|
56e9acb292 | ||
|
|
bd45f0963c | ||
|
|
ba5017b65a | ||
|
|
11b01fc21f | ||
|
|
2709bea0f4 | ||
|
|
a3ce33c106 | ||
|
|
8d60cd8ad6 | ||
|
|
5602342a16 | ||
|
|
4edb14d20f | ||
|
|
684e810ae2 | ||
|
|
2f3d9524bb | ||
|
|
0292a5678a | ||
|
|
f7e25d5bb5 | ||
|
|
8c735f6585 | ||
|
|
60bd7bad9d | ||
|
|
dcc1514d9a | ||
|
|
f4a59d453e | ||
|
|
5f538c27a1 | ||
|
|
d733f2ec26 | ||
|
|
2e0dcd87bf | ||
|
|
caa716803a | ||
|
|
378dc38f48 | ||
|
|
a2434d3e58 | ||
|
|
0c46704832 | ||
|
|
de4e704273 | ||
|
|
2245a95806 | ||
|
|
f40c6b5cf2 | ||
|
|
6b8b1f9e77 | ||
|
|
8d41285fe4 | ||
|
|
769ace51e8 | ||
|
|
9ecc4f4e44 | ||
|
|
a6064bb864 | ||
|
|
17a9e79023 | ||
|
|
bee39b93f5 | ||
|
|
31076e8689 | ||
|
|
a6648d4102 | ||
|
|
fc1822a042 | ||
|
|
14d35d5bad | ||
|
|
c5a210a9c8 | ||
|
|
fb51f74ff6 | ||
|
|
092f8178c0 | ||
|
|
c80a538d96 | ||
|
|
6c16044d8d | ||
|
|
17bddc047b | ||
|
|
654700ba5d | ||
|
|
2593502290 | ||
|
|
d24a117707 | ||
|
|
8367b95a13 | ||
|
|
3564e3a572 | ||
|
|
3b0f5b9971 | ||
|
|
75e24853b7 | ||
|
|
c7ec75a276 | ||
|
|
3cff27ddc1 | ||
|
|
a66a4b77a5 | ||
|
|
67324bf19c | ||
|
|
69bd8be403 | ||
|
|
68f4c238ca | ||
|
|
217d68104a | ||
|
|
65a1c5b441 | ||
|
|
9cd52bd999 | ||
|
|
5f97136160 | ||
|
|
de4a5220f2 | ||
|
|
74439d15d7 | ||
|
|
850a056441 | ||
|
|
8ed8d003f1 | ||
|
|
07f8ec6bff | ||
|
|
af21374071 | ||
|
|
e0326b0473 | ||
|
|
2c902cc288 | ||
|
|
50e99b59bf | ||
|
|
75bf3c00d3 | ||
|
|
8463f41e4d | ||
|
|
cbb6dfec55 | ||
|
|
632beba630 |
2
.github/ISSUE_TEMPLATE.txt
vendored
2
.github/ISSUE_TEMPLATE.txt
vendored
@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.txt
vendored
2
.github/PULL_REQUEST_TEMPLATE.txt
vendored
@@ -88,7 +88,7 @@ in this matter.
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -87,6 +87,7 @@
|
||||
/lib/math.h
|
||||
/lib/netdb.h
|
||||
/lib/netinet/in.h
|
||||
/lib/obstack.h
|
||||
/lib/parse-datetime-gen.h
|
||||
/lib/parse-datetime.c
|
||||
/lib/poll.h
|
||||
|
||||
@@ -1 +1 @@
|
||||
9.3
|
||||
9.4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Suppress valgrind diagnostics we don't care about.
|
||||
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
2
HACKING
2
HACKING
@@ -616,7 +616,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
|
||||
xdg-open doc/coverage/index.html
|
||||
|
||||
========================================================================
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1990-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1990-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -94,7 +94,7 @@ dist-hook: gen-ChangeLog
|
||||
$(AM_V_at)touch $(distdir)/doc/constants.texi \
|
||||
$(distdir)/doc/coreutils.info
|
||||
|
||||
gen_start_ver = 8.30
|
||||
gen_start_ver = 8.31
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
$(AM_V_GEN)if test -d .git; then \
|
||||
|
||||
133
NEWS
133
NEWS
@@ -1,5 +1,136 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 9.5 (2024-03-28) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chmod -R now avoids a race where an attacker may replace a traversed file
|
||||
with a symlink, causing chmod to operate on an unintended file.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
cp, mv, and install no longer issue spurious diagnostics like "failed
|
||||
to preserve ownership" when copying to GNU/Linux CIFS file systems.
|
||||
They do this by working around some Linux CIFS bugs.
|
||||
|
||||
cp --no-preserve=mode will correctly maintain set-group-ID bits
|
||||
for created directories. Previously on systems that didn't support ACLs,
|
||||
cp would have reset the set-group-ID bit on created directories.
|
||||
[bug introduced in coreutils-8.20]
|
||||
|
||||
join and uniq now support multi-byte characters better.
|
||||
For example, 'join -tX' now works even if X is a multi-byte character,
|
||||
and both programs now treat multi-byte characters like U+3000
|
||||
IDEOGRAPHIC SPACE as blanks if the current locale treats them so.
|
||||
|
||||
numfmt options like --suffix no longer have an arbitrary 127-byte limit.
|
||||
[bug introduced with numfmt in coreutils-8.21]
|
||||
|
||||
mktemp with --suffix now better diagnoses templates with too few X's.
|
||||
Previously it conflated the insignificant --suffix in the error.
|
||||
[bug introduced in coreutils-8.1]
|
||||
|
||||
sort again handles thousands grouping characters in single-byte locales
|
||||
where the grouping character is greater than CHAR_MAX. For e.g. signed
|
||||
character platforms with a 0xA0 (aka  ) grouping character.
|
||||
[bug introduced in coreutils-9.1]
|
||||
|
||||
split --line-bytes with a mixture of very long and short lines
|
||||
no longer overwrites the heap (CVE-2024-0684).
|
||||
[bug introduced in coreutils-9.2]
|
||||
|
||||
tail no longer mishandles input from files in /proc and /sys file systems,
|
||||
on systems with a page size larger than the stdio BUFSIZ.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
timeout avoids a narrow race condition, where it might kill arbitrary
|
||||
processes after a failed process fork.
|
||||
[bug introduced with timeout in coreutils-7.0]
|
||||
|
||||
timeout avoids a narrow race condition, where it might fail to
|
||||
kill monitored processes immediately after forking them.
|
||||
[bug introduced with timeout in coreutils-7.0]
|
||||
|
||||
wc no longer fails to count unprintable characters as parts of words.
|
||||
[bug introduced in textutils-2.1]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
base32 and base64 no longer require padding when decoding.
|
||||
Previously an error was given for non padded encoded data.
|
||||
|
||||
base32 and base64 have improved detection of corrupted encodings.
|
||||
Previously encodings with non zero padding bits were accepted.
|
||||
|
||||
basenc --base16 -d now supports lower case hexadecimal characters.
|
||||
Previously an error was given for lower case hex digits.
|
||||
|
||||
cp --no-clobber, and mv -n no longer exit with failure status if
|
||||
existing files are encountered in the destination. Instead they revert
|
||||
to the behavior from before v9.2, silently skipping existing files.
|
||||
|
||||
ls --dired now implies long format output without hyperlinks enabled,
|
||||
and will take precedence over previously specified formats or hyperlink mode.
|
||||
|
||||
numfmt will accept lowercase 'k' to indicate Kilo or Kibi units on input,
|
||||
and uses lowercase 'k' when outputting such units in '--to=si' mode.
|
||||
|
||||
pinky no longer tries to canonicalize the user's login location by default,
|
||||
rather requiring the new --lookup option to enable this often slow feature.
|
||||
|
||||
wc no longer ignores encoding errors when counting words.
|
||||
Instead, it treats them as non white space.
|
||||
|
||||
** New features
|
||||
|
||||
chgrp now accepts the --from=OWNER:GROUP option to restrict changes to files
|
||||
with matching current OWNER and/or GROUP, as already supported by chown(1).
|
||||
|
||||
chmod adds support for -h, -H,-L,-P, and --dereference options, providing
|
||||
more control over symlink handling. This supports more secure handling of
|
||||
CLI arguments, and is more consistent with chown, and chmod on other systems.
|
||||
|
||||
cp now accepts the --keep-directory-symlink option (like tar), to preserve
|
||||
and follow existing symlinks to directories in the destination.
|
||||
|
||||
cp and mv now accept the --update=none-fail option, which is similar
|
||||
to the --no-clobber option, except that existing files are diagnosed,
|
||||
and the command exits with failure status if existing files.
|
||||
The -n,--no-clobber option is best avoided due to platform differences.
|
||||
|
||||
env now accepts the -a,--argv0 option to override the zeroth argument
|
||||
of the command being executed.
|
||||
|
||||
mv now accepts an --exchange option, which causes the source and
|
||||
destination to be exchanged. It should be combined with
|
||||
--no-target-directory (-T) if the destination is a directory.
|
||||
The exchange is atomic if source and destination are on a single
|
||||
file system that supports atomic exchange; --exchange is not yet
|
||||
supported in other situations.
|
||||
|
||||
od now supports printing IEEE half precision floating point with -t fH,
|
||||
or brain 16 bit floating point with -t fB, where supported by the compiler.
|
||||
|
||||
tail now supports following multiple processes, with repeated --pid options.
|
||||
|
||||
** Improvements
|
||||
|
||||
cp,mv,install,cat,split now read and write a minimum of 256KiB at a time.
|
||||
This was previously 128KiB and increasing to 256KiB was seen to increase
|
||||
throughput by 10-20% when reading cached files on modern systems.
|
||||
|
||||
env,kill,timeout now support unnamed signals. kill(1) for example now
|
||||
supports sending such signals, and env(1) will list them appropriately.
|
||||
|
||||
SELinux operations in file copy operations are now more efficient,
|
||||
avoiding unneeded MCS/MLS label translation.
|
||||
|
||||
sort no longer dynamically links to libcrypto unless -R is used.
|
||||
This decreases startup overhead in the typical case.
|
||||
|
||||
wc is now much faster in single-byte locales and somewhat faster in
|
||||
multi-byte locales.
|
||||
|
||||
|
||||
* Noteworthy changes in release 9.4 (2023-08-29) [stable]
|
||||
|
||||
** Bug fixes
|
||||
@@ -5765,7 +5896,7 @@ packages, see ./old/*/NEWS.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
2
README
2
README
@@ -131,7 +131,7 @@ Please see the file COPYING for copying conditions.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -101,7 +101,7 @@ each program. One way to do this is to use vc-dwim
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
# Convert this package for use with valgrind.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -238,7 +238,6 @@ Greg McGary gkm@gnu.org
|
||||
Greg Metcalfe metcalfegreg@qwest.net
|
||||
Greg Schafer gschafer@zip.com.au
|
||||
Greg Troxel gdt@bbn.com
|
||||
Greg Wooledge gawooledge@sherwin.com
|
||||
Gregory Leblanc gleblanc@cu-portland.edu
|
||||
Guido Leenders guido.leenders@invantive.com
|
||||
Guntram Blohm Extern.Guntram.Blohm@AUDI.DE
|
||||
@@ -412,6 +411,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com
|
||||
Masami Takikawa takikawm@CS.ORST.EDU
|
||||
Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matheus Afonso Martins Moreira matheus.a.m.moreira@gmail.com
|
||||
Mathias Brodala info@noctus.net
|
||||
Matias A. Fonzo selk@dragora.org
|
||||
Matt Kraai kraai@ftbfs.org
|
||||
@@ -566,7 +566,6 @@ Rudolf Kastl rkastl@redhat.com
|
||||
Sahil Amoli sahilamoli@gmail.com
|
||||
Sami Farin sfarin@ratol.fi
|
||||
Samuel Neves sneves@dei.uc.pt
|
||||
Samuel Tardieu sam@rfc1149.net
|
||||
Samuel Thibault samuel.thibault@ens-lyon.org
|
||||
Samuli Karkkainen Samuli.Karkkainen@hut.fi
|
||||
Sander van Malssen svm@kozmix.ow.nl
|
||||
|
||||
4
TODO
4
TODO
@@ -18,7 +18,7 @@ document the following in coreutils.texi:
|
||||
Suggestion from Paul Eggert:
|
||||
More generally, there's not that much use for imaxtostr nowadays,
|
||||
since the inttypes module and newer versions of gettext allow things
|
||||
like _("truncating %s at %" PRIdMAX " bytes") to work portably.
|
||||
like _("truncating %s at %jd bytes") to work portably.
|
||||
I suspect that (if someone cares to take the time) we can remove
|
||||
all instances of imaxtostr and umaxtostr in coreutils and gnulib.
|
||||
|
||||
@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
20
bootstrap
20
bootstrap
@@ -3,9 +3,9 @@
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
scriptversion=2023-07-01.18; # UTC
|
||||
scriptversion=2023-12-10.18; # UTC
|
||||
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -37,9 +37,9 @@ medir=`dirname "$me"`
|
||||
|
||||
# A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
|
||||
|
||||
scriptlibversion=2023-07-01.17; # UTC
|
||||
scriptlibversion=2023-12-10.18; # UTC
|
||||
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -659,7 +659,9 @@ Optional environment variables:
|
||||
Use this if you already have gnulib sources
|
||||
and history on your machine, and do not want
|
||||
to waste your bandwidth downloading them again.
|
||||
GNULIB_URL Cloneable URL of the gnulib repository.
|
||||
GNULIB_URL URL of the gnulib repository. The default is
|
||||
$default_gnulib_url,
|
||||
which is Gnulib's upstream repository.
|
||||
|
||||
Options:
|
||||
--bootstrap-sync if this bootstrap script is not identical to
|
||||
@@ -775,7 +777,7 @@ autopull()
|
||||
if $use_gnulib || $bootstrap_sync; then
|
||||
prepare_GNULIB_SRCDIR
|
||||
if $bootstrap_sync; then
|
||||
upgrade_bootstrap
|
||||
upgrade_bootstrap "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1347,7 +1349,9 @@ Optional environment variables:
|
||||
have gnulib sources on your machine, and
|
||||
do not want to waste your bandwidth downloading
|
||||
them again.
|
||||
GNULIB_URL Cloneable URL of the gnulib repository.
|
||||
GNULIB_URL URL of the gnulib repository. The default is
|
||||
$default_gnulib_url,
|
||||
which is Gnulib's upstream repository.
|
||||
|
||||
Options:
|
||||
|
||||
@@ -1492,7 +1496,7 @@ check_build_prerequisites $use_git
|
||||
|
||||
if $bootstrap_sync; then
|
||||
prepare_GNULIB_SRCDIR
|
||||
upgrade_bootstrap
|
||||
upgrade_bootstrap "$@"
|
||||
# Since we have now upgraded if needed, no need to try it a second time below.
|
||||
bootstrap_sync=false
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -20,6 +20,8 @@
|
||||
avoided_gnulib_modules='
|
||||
--avoid=canonicalize-lgpl
|
||||
--avoid=dummy
|
||||
--avoid=mbuiter
|
||||
--avoid=mbuiterf
|
||||
'
|
||||
|
||||
# gnulib modules used by this package.
|
||||
@@ -39,23 +41,24 @@ gnulib_modules="
|
||||
assure
|
||||
attribute
|
||||
autobuild
|
||||
backupfile
|
||||
backup-rename
|
||||
backupfile
|
||||
base32
|
||||
base64
|
||||
btowc
|
||||
btoc32
|
||||
buffer-lcm
|
||||
byteswap
|
||||
c-strcase
|
||||
cl-strtod
|
||||
cl-strtold
|
||||
calloc-gnu
|
||||
c32iscntrl
|
||||
c32isspace
|
||||
c32width
|
||||
canon-host
|
||||
canonicalize
|
||||
chmodat
|
||||
chown
|
||||
chownat
|
||||
cloexec
|
||||
cl-strtod
|
||||
cl-strtold
|
||||
closein
|
||||
closeout
|
||||
config-h
|
||||
@@ -117,7 +120,6 @@ gnulib_modules="
|
||||
fts
|
||||
full-read
|
||||
full-write
|
||||
getgroups
|
||||
gethrxtime
|
||||
getline
|
||||
getloadavg
|
||||
@@ -125,19 +127,14 @@ gnulib_modules="
|
||||
getndelim2
|
||||
getopt-gnu
|
||||
getpagesize
|
||||
getpass-gnu
|
||||
gettext-h
|
||||
gettime
|
||||
gettime-res
|
||||
getugroups
|
||||
getusershell
|
||||
git-version-gen
|
||||
gitlog-to-changelog
|
||||
gnu-make
|
||||
gnu-web-doc-update
|
||||
gnumakefile
|
||||
gnupload
|
||||
group-member
|
||||
hard-locale
|
||||
hash
|
||||
hash-triple
|
||||
@@ -154,7 +151,6 @@ gnulib_modules="
|
||||
isblank
|
||||
largefile
|
||||
lchmod
|
||||
lchown
|
||||
ldtoastr
|
||||
lib-ignore
|
||||
libgmp
|
||||
@@ -168,18 +164,19 @@ gnulib_modules="
|
||||
malloc-gnu
|
||||
manywarnings
|
||||
mbrlen
|
||||
mbrtoc32
|
||||
mbrtowc
|
||||
mbsalign
|
||||
mbschr
|
||||
mbslen
|
||||
mbswidth
|
||||
mbszero
|
||||
mcel-prefer
|
||||
memcasecmp
|
||||
memchr
|
||||
memcmp2
|
||||
mempcpy
|
||||
memrchr
|
||||
minmax
|
||||
mgetgroups
|
||||
mkancesdirs
|
||||
mkdir
|
||||
mkdir-p
|
||||
@@ -190,13 +187,12 @@ gnulib_modules="
|
||||
mkostemp
|
||||
mkstemp
|
||||
mktime
|
||||
nullptr
|
||||
modechange
|
||||
mountlist
|
||||
mpsort
|
||||
netinet_in
|
||||
nproc
|
||||
nstrftime
|
||||
nullptr
|
||||
obstack
|
||||
open
|
||||
openat-safer
|
||||
@@ -224,19 +220,15 @@ gnulib_modules="
|
||||
randperm
|
||||
rawmemchr
|
||||
read-file
|
||||
readlink
|
||||
readtokens
|
||||
readtokens0
|
||||
readutmp
|
||||
realloc-gnu
|
||||
regex
|
||||
remove
|
||||
rename
|
||||
renameat
|
||||
renameatu
|
||||
rmdir
|
||||
root-dev-ino
|
||||
rpmatch
|
||||
safe-read
|
||||
same
|
||||
save-cwd
|
||||
@@ -248,6 +240,7 @@ gnulib_modules="
|
||||
settime
|
||||
sig2str
|
||||
sigaction
|
||||
skipchars
|
||||
smack
|
||||
ssize_t
|
||||
stat-macros
|
||||
@@ -257,9 +250,8 @@ gnulib_modules="
|
||||
stdckdint
|
||||
stdlib-safer
|
||||
stpcpy
|
||||
stpncpy
|
||||
strdup-posix
|
||||
strncat
|
||||
strnlen
|
||||
strnumcmp
|
||||
strsignal
|
||||
strtoimax
|
||||
@@ -276,7 +268,6 @@ gnulib_modules="
|
||||
timer-time
|
||||
timespec
|
||||
tmpdir
|
||||
tzset
|
||||
uname
|
||||
unicodeio
|
||||
unistd-safer
|
||||
@@ -296,9 +287,6 @@ gnulib_modules="
|
||||
verify
|
||||
verror
|
||||
version-etc-fsf
|
||||
wchar-single
|
||||
wcswidth
|
||||
wcwidth
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
write-any-file
|
||||
|
||||
@@ -71,6 +71,7 @@ override_single() {
|
||||
override_single dir ls
|
||||
override_single vdir ls
|
||||
override_single arch uname
|
||||
override_single chgrp chown
|
||||
|
||||
for cmd in $ALL_PROGRAMS; do
|
||||
echo "# Command $cmd"
|
||||
|
||||
10
cfg.mk
10
cfg.mk
@@ -1,5 +1,5 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -48,7 +48,7 @@ export VERBOSE = yes
|
||||
# 4914152 9e
|
||||
export XZ_OPT = -8e
|
||||
|
||||
old_NEWS_hash = c550e6659b8350f62d9cd0483bf0c199
|
||||
old_NEWS_hash = d66ee7a9fdb974017a4a17cf358d047d
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = \
|
||||
@@ -841,7 +841,8 @@ exclude_file_name_regexp--sc_trailing_blank = \
|
||||
exclude_file_name_regexp--sc_system_h_headers = \
|
||||
^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
|
||||
|
||||
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
|
||||
_src := (false|lbracket|chown-(chgrp|chown)
|
||||
_src := $(_src)|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
|
||||
_gl_src = (xdecto.max|cl-strtold)
|
||||
exclude_file_name_regexp--sc_require_config_h_first = \
|
||||
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
|
||||
@@ -926,6 +927,9 @@ _gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
|
||||
# Normally, the rule would detect its declaration, but that uses a
|
||||
# different name, __clz_tab.
|
||||
_gl_TS_unmarked_extern_vars = factor_clz_tab
|
||||
# Avoid tight_scope rule stating these should be static
|
||||
# as there is no way to achieve that with the way these are defined.
|
||||
_gl_TS_unmarked_extern_vars += ptr_MD5_.*
|
||||
# Other tight_scope settings
|
||||
_gl_TS_dir = .
|
||||
_gl_TS_obj_files = src/*.$(OBJEXT)
|
||||
|
||||
179
configure.ac
179
configure.ac
@@ -1,7 +1,7 @@
|
||||
# -*- autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1991-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -55,7 +55,6 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK])
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CPP
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_EGREP
|
||||
AC_PROG_LN_S
|
||||
@@ -64,6 +63,26 @@ gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
|
||||
gl_INIT
|
||||
coreutils_MACROS
|
||||
|
||||
# These are safe, since 'sort', coreutils's only multithreaded app,
|
||||
# does not use the relevant modules.
|
||||
AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call 'exclude' functions from a single thread.])
|
||||
AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call 'regex' functions from a single thread.])
|
||||
# Although 'sort' is multithreaded and can use these functions,
|
||||
# it uses them only from the main thread.
|
||||
AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
|
||||
[Define to 1 if apps call mbrtowc, mbrtoc32, and 'regex' functions
|
||||
from a single thread.])
|
||||
# This is safe, since all apps set locale early.
|
||||
AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
|
||||
[Define to 1 if apps don't set the locale after calling
|
||||
locale-sensitive functions like mbrtowc and wcwidth.])
|
||||
|
||||
AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
|
||||
[Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
|
||||
that glibc does not support.])
|
||||
|
||||
# The test suite needs to know if we have a working perl.
|
||||
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
|
||||
|
||||
@@ -153,6 +172,13 @@ AC_ARG_ENABLE([gcc-warnings],
|
||||
&& gl_gcc_warnings=yes])]
|
||||
)
|
||||
|
||||
# clang is unduly picky about some things, even by default.
|
||||
if test "$gl_cv_compiler_clang" = yes; then
|
||||
gl_WARN_ADD([-Wno-format-extra-args])
|
||||
gl_WARN_ADD([-Wno-implicit-const-int-float-conversion])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
if test $gl_gcc_warnings != no; then
|
||||
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||
AC_SUBST([WERROR_CFLAGS])
|
||||
@@ -213,21 +239,6 @@ if test $gl_gcc_warnings != no; then
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-format-nonliteral])
|
||||
|
||||
# clang is unduly picky about some things.
|
||||
AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#ifndef __clang__
|
||||
#error "not clang"
|
||||
#endif
|
||||
]])],
|
||||
[utils_cv_clang=yes],
|
||||
[utils_cv_clang=no])])
|
||||
if test $utils_cv_clang = yes; then
|
||||
gl_WARN_ADD([-Wno-format-extra-args])
|
||||
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
|
||||
fi
|
||||
|
||||
gl_WARN_ADD([-fdiagnostics-show-option])
|
||||
gl_WARN_ADD([-funit-at-a-time])
|
||||
|
||||
@@ -340,6 +351,51 @@ if test $utils_cv_localtime_cache = yes; then
|
||||
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
|
||||
fi
|
||||
|
||||
# Find the library for dynamic loading of shared libraries.
|
||||
AC_SEARCH_LIBS([dlopen], [dl])
|
||||
AS_CASE([$ac_cv_search_dlopen],
|
||||
[no | 'none required'],
|
||||
[LIB_DL=],
|
||||
[*],
|
||||
[LIB_DL="$ac_cv_search_dlopen"])
|
||||
AC_SUBST([LIB_DL])
|
||||
|
||||
# Should 'sort' link libcrypto dynamically?
|
||||
AS_CASE([$LIB_CRYPTO],
|
||||
[-lcrypto],
|
||||
[# Check for dlopen and libcrypto dynamic linking in one program,
|
||||
# as there's little point to checking them separately.
|
||||
AC_CACHE_CHECK([for dlopen and whether libcrypto is linked dynamically],
|
||||
[utils_cv_dlopen_libcrypto],
|
||||
[utils_cv_dlopen_libcrypto=no
|
||||
saved_LIBS=$LIBS
|
||||
LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <dlfcn.h>
|
||||
#include <openssl/sha.h>
|
||||
/* Use SHA512 rather than MD5 here to avoid deprecation warnings.
|
||||
So need to check HAVE_OPENSSL_MD5.. with DLOPEN_LIBCRYPTO. */
|
||||
]],
|
||||
[[return !(dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL)
|
||||
&& SHA512 (0, 0, 0));]])],
|
||||
[# readelf works with cross-builds; ldd works on more platforms.
|
||||
LIBCRYPTO_SONAME="`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
|
||||
) 2>/dev/null |
|
||||
sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
|
||||
AS_CASE([$LIBCRYPTO_SONAME],
|
||||
[*libcrypto*],
|
||||
[utils_cv_dlopen_libcrypto=yes])])
|
||||
LIBS=$saved_LIBS])
|
||||
AS_CASE([$utils_cv_dlopen_libcrypto],
|
||||
[yes],
|
||||
[AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
|
||||
[Define to 1 if dlopen exists and libcrypto is
|
||||
linked dynamically.])
|
||||
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
|
||||
[versioned libcrypto])
|
||||
])])
|
||||
|
||||
# macOS >= 10.12
|
||||
AC_CHECK_FUNCS([fclonefileat])
|
||||
|
||||
@@ -471,11 +527,6 @@ if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
|
||||
[Define if your system defines TIOCGWINSZ in sys/pty.h.])
|
||||
fi
|
||||
|
||||
# For src/kill.c.
|
||||
AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#include <signal.h>])
|
||||
|
||||
# Build df only if there's a point to it.
|
||||
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
|
||||
gl_ADD_PROG([optional_bin_progs], [df])
|
||||
@@ -493,7 +544,8 @@ gl_WARN_ADD([-errwarn], [CFLAGS])
|
||||
AC_MSG_CHECKING([whether this system supports stdbuf])
|
||||
CFLAGS="-fPIC $CFLAGS"
|
||||
LDFLAGS="-shared $LDFLAGS"
|
||||
stdbuf_supported=no
|
||||
AC_CACHE_VAL([utils_cv_stdbuf_supported],[
|
||||
utils_cv_stdbuf_supported=no
|
||||
# Note we only LINK here rather than RUN to support cross compilation
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
@@ -507,18 +559,68 @@ AC_LINK_IFELSE(
|
||||
if (stdbuf != 1)
|
||||
return 1;]])
|
||||
],
|
||||
[stdbuf_supported=yes])
|
||||
AC_MSG_RESULT([$stdbuf_supported])
|
||||
if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
|
||||
[utils_cv_stdbuf_supported=yes])])
|
||||
AC_MSG_RESULT([$utils_cv_stdbuf_supported])
|
||||
if test "$utils_cv_stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
|
||||
gl_ADD_PROG([optional_bin_progs], [stdbuf])
|
||||
fi
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
LDFLAGS=$ac_save_LDFLAGS
|
||||
ac_c_werror_flag=$cu_save_c_werror_flag
|
||||
|
||||
# Test compiler support for half precision floating point types (for od)
|
||||
AC_MSG_CHECKING([IEEE 16 bit floating point])
|
||||
AC_CACHE_VAL([utils_cv_ieee_16_bit_supported],[
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
volatile _Float16 hf = 1;
|
||||
float f = hf; /* Ensure compiler can promote to float. */
|
||||
return !(f == 1.0f);
|
||||
}
|
||||
]])
|
||||
],[
|
||||
utils_cv_ieee_16_bit_supported=yes
|
||||
],[
|
||||
utils_cv_ieee_16_bit_supported=no
|
||||
],[
|
||||
utils_cv_ieee_16_bit_supported=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_ieee_16_bit_supported])
|
||||
if test $utils_cv_ieee_16_bit_supported = yes; then
|
||||
AC_DEFINE([FLOAT16_SUPPORTED], [1], [IEEE 16 bit float supported])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([Brain 16 bit floating point])
|
||||
AC_CACHE_VAL([utils_cv_brain_16_bit_supported],[
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
volatile __bf16 hf = 1;
|
||||
float f = hf; /* Ensure compiler can promote to float. */
|
||||
return !(f == 1.0f);
|
||||
}
|
||||
]])
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=yes
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=no
|
||||
],[
|
||||
utils_cv_brain_16_bit_supported=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_brain_16_bit_supported])
|
||||
if test $utils_cv_brain_16_bit_supported = yes; then
|
||||
AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
|
||||
fi
|
||||
|
||||
ac_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-mavx -mpclmul $CFLAGS"
|
||||
AC_MSG_CHECKING([if pclmul intrinsic exists])
|
||||
AC_CACHE_VAL([utils_cv_pclmul_intrinsic_exists],[
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <x86intrin.h>
|
||||
@@ -533,21 +635,22 @@ AC_LINK_IFELSE(
|
||||
}
|
||||
]])
|
||||
],[
|
||||
pclmul_intrinsic_exists=yes
|
||||
utils_cv_pclmul_intrinsic_exists=yes
|
||||
],[
|
||||
pclmul_intrinsic_exists=no
|
||||
])
|
||||
AC_MSG_RESULT([$pclmul_intrinsic_exists])
|
||||
if test $pclmul_intrinsic_exists = yes; then
|
||||
utils_cv_pclmul_intrinsic_exists=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_pclmul_intrinsic_exists])
|
||||
if test $utils_cv_pclmul_intrinsic_exists = yes; then
|
||||
AC_DEFINE([USE_PCLMUL_CRC32], [1],
|
||||
[CRC32 calculation by pclmul hardware instruction enabled])
|
||||
fi
|
||||
AM_CONDITIONAL([USE_PCLMUL_CRC32],
|
||||
[test $pclmul_intrinsic_exists = yes])
|
||||
[test $utils_cv_pclmul_intrinsic_exists = yes])
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
|
||||
CFLAGS="-mavx2 $CFLAGS"
|
||||
AC_MSG_CHECKING([for avx2 intrinsics])
|
||||
AC_CACHE_VAL([utils_cv_avx2_intrinsic_exists],[
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <x86intrin.h>
|
||||
@@ -561,16 +664,16 @@ AC_LINK_IFELSE(
|
||||
}
|
||||
]])
|
||||
],[
|
||||
avx2_intrinsic_exists=yes
|
||||
utils_cv_avx2_intrinsic_exists=yes
|
||||
],[
|
||||
avx2_intrinsic_exists=no
|
||||
])
|
||||
AC_MSG_RESULT([$avx2_intrinsic_exists])
|
||||
if test $avx2_intrinsic_exists = yes; then
|
||||
utils_cv_avx2_intrinsic_exists=no
|
||||
])])
|
||||
AC_MSG_RESULT([$utils_cv_avx2_intrinsic_exists])
|
||||
if test $utils_cv_avx2_intrinsic_exists = yes; then
|
||||
AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
|
||||
fi
|
||||
AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
|
||||
[test $avx2_intrinsic_exists = yes])
|
||||
[test $utils_cv_avx2_intrinsic_exists = yes])
|
||||
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
# Make coreutils documentation. -*-Makefile-*-
|
||||
# This is included by the top-level Makefile.am.
|
||||
|
||||
# Copyright (C) 1995-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c File mode bits
|
||||
|
||||
@c Copyright (C) 1994--2023 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 1994--2024 Free Software Foundation, Inc.
|
||||
|
||||
@c Permission is granted to copy, distribute and/or modify this document
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c GNU Version-sort ordering documentation
|
||||
|
||||
@c Copyright (C) 2019--2023 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 2019--2024 Free Software Foundation, Inc.
|
||||
|
||||
@c Permission is granted to copy, distribute and/or modify this document
|
||||
@c under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* buffer-lcm.c - compute a good buffer size for dealing with two files
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert string to double in the current locale, falling back on the C locale.
|
||||
|
||||
Copyright 2019-2023 Free Software Foundation, Inc.
|
||||
Copyright 2019-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -14,12 +14,6 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Without this pragma, gcc suggests that (given !HAVE_POSIX_FADVISE)
|
||||
the fdadvise function might be a candidate for attribute 'const'. */
|
||||
#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include "fadvise.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Invoke open, but return either a desired file descriptor or -1.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Invoke open, but return either a desired file descriptor or -1.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady. */
|
||||
|
||||
#include <config.h>
|
||||
#include "mbsalign.h"
|
||||
|
||||
#include "minmax.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
/* Replace non printable chars.
|
||||
Note \t and \n etc. are non printable.
|
||||
Return 1 if replacement made, 0 otherwise. */
|
||||
|
||||
static bool
|
||||
wc_ensure_printable (wchar_t *wchars)
|
||||
{
|
||||
bool replaced = false;
|
||||
wchar_t *wc = wchars;
|
||||
while (*wc)
|
||||
{
|
||||
if (!iswprint ((wint_t) *wc))
|
||||
{
|
||||
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
|
||||
replaced = true;
|
||||
}
|
||||
wc++;
|
||||
}
|
||||
return replaced;
|
||||
}
|
||||
|
||||
/* Truncate wchar string to width cells.
|
||||
* Returns number of cells used. */
|
||||
|
||||
static size_t
|
||||
wc_truncate (wchar_t *wc, size_t width)
|
||||
{
|
||||
size_t cells = 0;
|
||||
int next_cells = 0;
|
||||
|
||||
while (*wc)
|
||||
{
|
||||
next_cells = wcwidth (*wc);
|
||||
if (next_cells == -1) /* non printable */
|
||||
{
|
||||
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
|
||||
next_cells = 1;
|
||||
}
|
||||
if (cells + next_cells > width)
|
||||
break;
|
||||
cells += next_cells;
|
||||
wc++;
|
||||
}
|
||||
*wc = L'\0';
|
||||
return cells;
|
||||
}
|
||||
|
||||
/* Write N_SPACES space characters to DEST while ensuring
|
||||
nothing is written beyond DEST_END. A terminating NUL
|
||||
is always added to DEST.
|
||||
A pointer to the terminating NUL is returned. */
|
||||
|
||||
static char *
|
||||
mbs_align_pad (char *dest, char const *dest_end, size_t n_spaces)
|
||||
{
|
||||
/* FIXME: Should we pad with "figure space" (\u2007)
|
||||
if non ascii data present? */
|
||||
while (n_spaces-- && (dest < dest_end))
|
||||
*dest++ = ' ';
|
||||
*dest = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* Align a string, SRC, in a field of *WIDTH columns, handling multi-byte
|
||||
characters; write the result into the DEST_SIZE-byte buffer, DEST.
|
||||
ALIGNMENT specifies whether to left- or right-justify or to center.
|
||||
If SRC requires more than *WIDTH columns, truncate it to fit.
|
||||
When centering, the number of trailing spaces may be one less than the
|
||||
number of leading spaces.
|
||||
Return the length in bytes required for the final result, not counting
|
||||
the trailing NUL. A return value of DEST_SIZE or larger means there
|
||||
wasn't enough space. DEST will be NUL terminated in any case.
|
||||
Return SIZE_MAX upon error (invalid multi-byte sequence in SRC,
|
||||
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
|
||||
Update *WIDTH to indicate how many columns were used before padding. */
|
||||
|
||||
size_t
|
||||
mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t ret = SIZE_MAX;
|
||||
size_t src_size = strlen (src) + 1;
|
||||
char *newstr = nullptr;
|
||||
wchar_t *str_wc = nullptr;
|
||||
char const *str_to_print = src;
|
||||
size_t n_cols = src_size - 1;
|
||||
size_t n_used_bytes = n_cols; /* Not including NUL */
|
||||
size_t n_spaces = 0;
|
||||
bool conversion = false;
|
||||
bool wc_enabled = false;
|
||||
|
||||
/* In multi-byte locales convert to wide characters
|
||||
to allow easy truncation. Also determine number
|
||||
of screen columns used. */
|
||||
if (!(flags & MBA_UNIBYTE_ONLY) && MB_CUR_MAX > 1)
|
||||
{
|
||||
size_t src_chars = mbstowcs (nullptr, src, 0);
|
||||
if (src_chars == SIZE_MAX)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
src_chars += 1; /* make space for NUL */
|
||||
str_wc = malloc (src_chars * sizeof (wchar_t));
|
||||
if (str_wc == nullptr)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
if (mbstowcs (str_wc, src, src_chars) != 0)
|
||||
{
|
||||
str_wc[src_chars - 1] = L'\0';
|
||||
wc_enabled = true;
|
||||
conversion = wc_ensure_printable (str_wc);
|
||||
n_cols = wcswidth (str_wc, src_chars);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we transformed or need to truncate the source string
|
||||
then create a modified copy of it. */
|
||||
if (wc_enabled && (conversion || (n_cols > *width)))
|
||||
{
|
||||
if (conversion)
|
||||
{
|
||||
/* May have increased the size by converting
|
||||
\t to \uFFFD for example. */
|
||||
src_size = wcstombs (nullptr, str_wc, 0) + 1;
|
||||
}
|
||||
newstr = malloc (src_size);
|
||||
if (newstr == nullptr)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
str_to_print = newstr;
|
||||
n_cols = wc_truncate (str_wc, *width);
|
||||
n_used_bytes = wcstombs (newstr, str_wc, src_size);
|
||||
}
|
||||
|
||||
mbsalign_unibyte:
|
||||
|
||||
if (n_cols > *width) /* Unibyte truncation required. */
|
||||
{
|
||||
n_cols = *width;
|
||||
n_used_bytes = n_cols;
|
||||
}
|
||||
|
||||
if (*width > n_cols) /* Padding required. */
|
||||
n_spaces = *width - n_cols;
|
||||
|
||||
/* indicate to caller how many cells needed (not including padding). */
|
||||
*width = n_cols;
|
||||
|
||||
{
|
||||
size_t start_spaces, end_spaces;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case MBS_ALIGN_LEFT:
|
||||
start_spaces = 0;
|
||||
end_spaces = n_spaces;
|
||||
break;
|
||||
case MBS_ALIGN_RIGHT:
|
||||
start_spaces = n_spaces;
|
||||
end_spaces = 0;
|
||||
break;
|
||||
case MBS_ALIGN_CENTER:
|
||||
default:
|
||||
start_spaces = n_spaces / 2 + n_spaces % 2;
|
||||
end_spaces = n_spaces / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & MBA_NO_LEFT_PAD)
|
||||
start_spaces = 0;
|
||||
if (flags & MBA_NO_RIGHT_PAD)
|
||||
end_spaces = 0;
|
||||
|
||||
/* Write as much NUL terminated output to DEST as possible. */
|
||||
if (dest_size != 0)
|
||||
{
|
||||
size_t space_left;
|
||||
char *dest_end = dest + dest_size - 1;
|
||||
|
||||
dest = mbs_align_pad (dest, dest_end, start_spaces);
|
||||
space_left = dest_end - dest;
|
||||
dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
|
||||
mbs_align_pad (dest, dest_end, end_spaces);
|
||||
}
|
||||
|
||||
/* indicate to caller how many bytes needed (not including NUL). */
|
||||
ret = n_used_bytes + ((start_spaces + end_spaces) * 1);
|
||||
}
|
||||
|
||||
mbsalign_cleanup:
|
||||
|
||||
free (str_wc);
|
||||
free (newstr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* A wrapper around mbsalign() to dynamically allocate the
|
||||
minimum amount of memory to store the result.
|
||||
Return nullptr on failure. */
|
||||
|
||||
char *
|
||||
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t orig_width = *width;
|
||||
size_t size = *width; /* Start with enough for unibyte mode. */
|
||||
size_t req = size;
|
||||
char *buf = nullptr;
|
||||
|
||||
while (req >= size)
|
||||
{
|
||||
char *nbuf;
|
||||
size = req + 1; /* Space for NUL. */
|
||||
nbuf = realloc (buf, size);
|
||||
if (nbuf == nullptr)
|
||||
{
|
||||
free (buf);
|
||||
buf = nullptr;
|
||||
break;
|
||||
}
|
||||
buf = nbuf;
|
||||
*width = orig_width;
|
||||
req = mbsalign (src, buf, size, width, align, flags);
|
||||
if (req == SIZE_MAX)
|
||||
{
|
||||
free (buf);
|
||||
buf = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
|
||||
|
||||
enum {
|
||||
/* Use unibyte mode for invalid multibyte strings
|
||||
or when heap memory is exhausted. */
|
||||
MBA_UNIBYTE_FALLBACK = 0x0001,
|
||||
|
||||
/* As an optimization, don't do multibyte processing
|
||||
when we know no multibyte characters are present. */
|
||||
MBA_UNIBYTE_ONLY = 0x0002,
|
||||
|
||||
/* Don't add leading padding. */
|
||||
MBA_NO_LEFT_PAD = 0x0004,
|
||||
|
||||
/* Don't add trailing padding. */
|
||||
MBA_NO_RIGHT_PAD = 0x0008
|
||||
|
||||
#if 0 /* Other possible options. */
|
||||
/* Skip invalid multibyte chars rather than failing. */
|
||||
MBA_IGNORE_INVALID
|
||||
|
||||
/* Align multibyte strings using "figure space" (\u2007). */
|
||||
MBA_USE_FIGURE_SPACE
|
||||
|
||||
/* Don't truncate. */
|
||||
MBA_NO_TRUNCATE
|
||||
|
||||
/* Ensure no leading whitespace. */
|
||||
MBA_LSTRIP
|
||||
|
||||
/* Ensure no trailing whitespace. */
|
||||
MBA_RSTRIP
|
||||
#endif
|
||||
};
|
||||
|
||||
size_t
|
||||
mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
_GL_ATTRIBUTE_NONNULL ();
|
||||
|
||||
char *
|
||||
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
||||
_GL_ATTRIBUTE_NONNULL ();
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
|
||||
|
||||
Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Colin Plumb.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
|
||||
|
||||
Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Colin Plumb.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -41,7 +41,7 @@ main (int argc, char **argv)
|
||||
struct randint_source *ints = randint_all_new (name, SIZE_MAX);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
printf ("%"PRIuMAX"\n", randint_choose (ints, choices));
|
||||
printf ("%ju\n", randint_choose (ints, choices));
|
||||
|
||||
return (randint_all_free (ints) == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random permutations.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,9 +46,9 @@
|
||||
#include "xalloc.h"
|
||||
|
||||
#if _STRING_ARCH_unaligned || _STRING_INLINE_unaligned
|
||||
# define ALIGNED_POINTER(ptr, type) true
|
||||
# define POINTER_IS_ALIGNED(ptr, type) true
|
||||
#else
|
||||
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
|
||||
# define POINTER_IS_ALIGNED(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
|
||||
#endif
|
||||
|
||||
/* The maximum buffer size used for reads of random data. Using the
|
||||
@@ -271,7 +271,7 @@ readisaac (struct isaac *isaac, void *p, size_t size)
|
||||
|
||||
/* If P is aligned, write to *P directly to avoid the overhead
|
||||
of copying from the buffer. */
|
||||
if (ALIGNED_POINTER (p, isaac_word))
|
||||
if (POINTER_IS_ALIGNED (p, isaac_word))
|
||||
{
|
||||
isaac_word *wp = p;
|
||||
while (ISAAC_BYTES <= size)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* root-dev-ino.c -- get the device and inode numbers for '/'.
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Root device and inode number checking.
|
||||
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,7 +28,7 @@ get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
|
||||
--preserve-root and --no-preserve-root options. */
|
||||
|
||||
# define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \
|
||||
(Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino))
|
||||
(Root_dev_ino && PSAME_INODE (Dir_statbuf, Root_dev_ino))
|
||||
|
||||
# define ROOT_DEV_INO_WARN(Dirname) \
|
||||
do \
|
||||
|
||||
3
gl/lib/skipchars.c
Normal file
3
gl/lib/skipchars.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <config.h>
|
||||
#define SKIPCHARS_INLINE _GL_EXTERN_INLINE
|
||||
#include <skipchars.h>
|
||||
56
gl/lib/skipchars.h
Normal file
56
gl/lib/skipchars.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Skipping sequences of characters satisfying a predicate
|
||||
|
||||
Copyright 2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "mcel.h"
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef SKIPCHARS_INLINE
|
||||
# define SKIPCHARS_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
/* Return the address just past the leading sequence of possibly
|
||||
multi-byte characters or encoding errors G in STR that satisfy
|
||||
PREDICATE (G) if OK is true, or that do not satisfy the predicate
|
||||
call if OK is false. */
|
||||
|
||||
SKIPCHARS_INLINE char *
|
||||
skip_str_matching (char const *str, bool (*predicate) (mcel_t), bool ok)
|
||||
{
|
||||
char const *s = str;
|
||||
for (mcel_t g; *s && predicate (g = mcel_scanz (s)) == ok;
|
||||
s += g.len)
|
||||
continue;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
/* Return the address just past the leading sequence of possibly
|
||||
multi-byte characters or encoding errors G in BUF (which ends at LIM)
|
||||
that satisfy PREDICATE (G) if OK is true, or that do not satisfy
|
||||
the predicate call if OK is false. */
|
||||
|
||||
SKIPCHARS_INLINE char *
|
||||
skip_buf_matching (char const *buf, char const *lim,
|
||||
bool (*predicate) (mcel_t), bool ok)
|
||||
{
|
||||
char const *s = buf;
|
||||
for (mcel_t g; s < lim && predicate (g = mcel_scan (s, lim)) == ok;
|
||||
s += g.len)
|
||||
continue;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Include and determine availability of smack routines
|
||||
Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare integer strings.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings. This is an internal include file.
|
||||
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -114,8 +114,8 @@ static inline int _GL_ATTRIBUTE_PURE
|
||||
numcompare (char const *a, char const *b,
|
||||
int decimal_point, int thousands_sep)
|
||||
{
|
||||
unsigned char tmpa = *a;
|
||||
unsigned char tmpb = *b;
|
||||
char tmpa = *a;
|
||||
char tmpb = *b;
|
||||
int tmp;
|
||||
size_t log_a;
|
||||
size_t log_b;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings.
|
||||
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2004-2023 Free Software Foundation, Inc.
|
||||
Copyright 2004-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2022-2023 Free Software Foundation, Inc.
|
||||
Copyright 2022-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert decimal strings with bounds checking and exit on error.
|
||||
|
||||
Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2014-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,9 +24,9 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
#include <error.h>
|
||||
#include <quote.h>
|
||||
#include <xstrtol.h>
|
||||
|
||||
/* Parse numeric string N_STR of base BASE, and return the value.
|
||||
Exit on parse error or if MIN or MAX are exceeded.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Convert decimal strings with bounds checking and exit on error.
|
||||
|
||||
Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2014-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* xfts.c -- a wrapper for fts_open
|
||||
|
||||
Copyright (C) 2003-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
Description:
|
||||
Align/Truncate a string in a given screen width.
|
||||
|
||||
Files:
|
||||
lib/mbsalign.c
|
||||
lib/mbsalign.h
|
||||
|
||||
Depends-on:
|
||||
minmax
|
||||
wchar
|
||||
wctype
|
||||
wcwidth
|
||||
mempcpy
|
||||
stdint
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += mbsalign.c mbsalign.h
|
||||
|
||||
Include:
|
||||
"mbsalign.h"
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Pádraig Brady
|
||||
@@ -1,11 +0,0 @@
|
||||
Files:
|
||||
tests/test-mbsalign.c
|
||||
tests/macros.h
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-mbsalign
|
||||
check_PROGRAMS += test-mbsalign
|
||||
24
gl/modules/skipchars
Normal file
24
gl/modules/skipchars
Normal file
@@ -0,0 +1,24 @@
|
||||
Description:
|
||||
Skip sequences of multi-byte characters or encoding errors
|
||||
|
||||
Files:
|
||||
lib/skipchars.c
|
||||
lib/skipchars.h
|
||||
|
||||
Depends-on:
|
||||
extern-inline
|
||||
mcel
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += skipchars.c
|
||||
|
||||
Include:
|
||||
"skipchars.h"
|
||||
|
||||
License:
|
||||
GPL
|
||||
|
||||
Maintainer:
|
||||
all
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Test that fadvise works as advertised.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/* Test that mbsalign works as advertised.
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mbsalign.h"
|
||||
#include "macros.h"
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char dest[4 * 16 + 1];
|
||||
size_t width, n;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
|
||||
"C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
|
||||
locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
|
||||
that is, effectively the "C.UTF-8" locale. */
|
||||
if (MB_CUR_MAX == 1)
|
||||
#endif
|
||||
{
|
||||
/* Test unibyte truncation. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 4);
|
||||
}
|
||||
|
||||
/* Test center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test center alignment, with no trailing padding. */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 3);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test left alignment, with no trailing padding. (truncate only). */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
|
||||
MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 2);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test center alignment, with no padding. (truncate only). */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_LEFT_PAD | MBA_NO_RIGHT_PAD);
|
||||
ASSERT (n == 2);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
|
||||
|
||||
/* Test center alignment, with no left padding. (may be useful for RTL?) */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
|
||||
MBA_NO_LEFT_PAD);
|
||||
ASSERT (n == 3);
|
||||
ASSERT (*dest == 'e' && *(dest + n - 1) == ' ');
|
||||
|
||||
if (setlocale (LC_ALL, "en_US.UTF8"))
|
||||
{
|
||||
/* Check invalid input is flagged. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == (size_t) -1);
|
||||
|
||||
/* Check invalid input is treated as unibyte */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK);
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test multibyte center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
|
||||
/* Test multibyte left alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
|
||||
|
||||
/* Test multibyte right alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
|
||||
ASSERT (n == 5);
|
||||
ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
|
||||
|
||||
/* multibyte multicell truncation. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("日月火水", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 2 characters */
|
||||
|
||||
/* multibyte unicell truncation. */
|
||||
width = 3; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 3 characters */
|
||||
|
||||
/* Check independence from dest buffer. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 9); /* 4 characters */
|
||||
|
||||
/* Check that width is updated with cells required before padding. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (width == 3);
|
||||
|
||||
/* Test case where output is larger than input
|
||||
(as tab converted to multi byte replacement char). */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
|
||||
&width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 7);
|
||||
|
||||
/* Test forced unibyte truncation. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
|
||||
MBA_UNIBYTE_ONLY);
|
||||
ASSERT (n == 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
|
||||
|
||||
Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: bb5bb43a1e...259829e78b
2
init.cfg
2
init.cfg
@@ -1,6 +1,6 @@
|
||||
# This file is sourced by init.sh, *before* its initialization.
|
||||
|
||||
# Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Exercise chdir-long's sample main program.
|
||||
|
||||
# Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#serial 27
|
||||
# Check declarations for this package.
|
||||
|
||||
dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#serial 2
|
||||
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#serial 114 -*- autoconf -*-
|
||||
#serial 115 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -67,16 +67,11 @@ AC_DEFUN([coreutils_MACROS],
|
||||
fallocate
|
||||
fchown
|
||||
fchmod
|
||||
ftruncate
|
||||
iswspace
|
||||
mkfifo
|
||||
mbrlen
|
||||
setgroups
|
||||
sethostname
|
||||
siginterrupt
|
||||
sync
|
||||
syncfs
|
||||
sysctl
|
||||
sysinfo
|
||||
tcgetpgrp
|
||||
])
|
||||
@@ -94,22 +89,6 @@ AC_DEFUN([coreutils_MACROS],
|
||||
dnl This can't use AC_REQUIRE; I'm not quite sure why.
|
||||
cu_PREREQ_STAT_PROG
|
||||
|
||||
# for dd.c and shred.c
|
||||
#
|
||||
# Use fdatasync only if declared. On MacOS X 10.7, fdatasync exists but
|
||||
# is not declared, and is ineffective.
|
||||
LIB_FDATASYNC=
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
AC_CHECK_DECLS_ONCE([fdatasync])
|
||||
if test $ac_cv_have_decl_fdatasync = yes; then
|
||||
coreutils_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS([fdatasync], [rt posix4],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
AC_CHECK_FUNCS([fdatasync])
|
||||
LIBS=$coreutils_saved_libs
|
||||
fi
|
||||
|
||||
# Check whether libcap is usable -- for ls --color support
|
||||
LIB_CAP=
|
||||
AC_ARG_ENABLE([libcap],
|
||||
|
||||
@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
|
||||
# directory of the coreutils package.
|
||||
|
||||
|
||||
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# stat-prog.m4 serial 7
|
||||
# Record the prerequisites of src/stat.c from the coreutils package.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2018-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2018-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
12
man/chmod.x
12
man/chmod.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
@@ -60,17 +60,19 @@ file's group, with the same values; and the fourth for other users not
|
||||
in the file's group, with the same values.
|
||||
.PP
|
||||
.B chmod
|
||||
never changes the permissions of symbolic links; the
|
||||
doesn't change the permissions of symbolic links; the
|
||||
.B chmod
|
||||
system call cannot change their permissions. This is not a problem
|
||||
since the permissions of symbolic links are never used.
|
||||
system call cannot change their permissions on most systems,
|
||||
and most systems ignore permissions of symbolic links.
|
||||
However, for each symbolic link listed on the command line,
|
||||
.B chmod
|
||||
changes the permissions of the pointed-to file.
|
||||
In contrast,
|
||||
.B chmod
|
||||
ignores symbolic links encountered during recursive directory
|
||||
traversals.
|
||||
traversals. Options that modify this behavior are described in the
|
||||
.B OPTIONS
|
||||
section.
|
||||
.SH "SETUID AND SETGID BITS"
|
||||
.B chmod
|
||||
clears the set-group-ID bit of a
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
2
man/df.x
2
man/df.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
2
man/du.x
2
man/du.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Make coreutils man pages. -*-Makefile-*-
|
||||
# This is included by the top-level Makefile.am.
|
||||
|
||||
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
readlink \- print resolved symbolic links or canonical file names
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
Note realpath(1) is the preferred command to use
|
||||
realpath(1) is a better command
|
||||
for canonicalization functionality.
|
||||
[SEE ALSO]
|
||||
readlink(2), realpath(1), realpath(3)
|
||||
|
||||
2
man/rm.x
2
man/rm.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -10,5 +10,4 @@ the first argument is used as the complete context. Any additional
|
||||
arguments after \fICOMMAND\fR are interpreted as arguments to the
|
||||
command.
|
||||
.PP
|
||||
Note that only carefully-chosen contexts are likely to successfully
|
||||
run.
|
||||
Only carefully-chosen contexts are likely to run successfully.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
||||
'\"
|
||||
'\" This is free software. You may redistribute copies of it under the terms
|
||||
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# List of files which contain translatable strings.
|
||||
# Copyright (C) 1996-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
|
||||
# These are nominally temporary...
|
||||
lib/argmatch.c
|
||||
@@ -38,7 +38,6 @@ src/basename.c
|
||||
src/basenc.c
|
||||
src/cat.c
|
||||
src/chcon.c
|
||||
src/chgrp.c
|
||||
src/chmod.c
|
||||
src/chown-core.c
|
||||
src/chown.c
|
||||
|
||||
@@ -164,7 +164,7 @@ By adding the directory to your $PATH, older versions can be easily used:
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2019-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2019-2024 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2019-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2019-2024 Free Software Foundation, Inc.
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification,
|
||||
# are permitted in any medium without royalty provided the copyright
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from file names
|
||||
Copyright (C) 1990-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
263
src/basenc.c
263
src/basenc.c
@@ -1,5 +1,5 @@
|
||||
/* Base64, base32, and similar encoding/decoding strings or files.
|
||||
Copyright (C) 2004-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "assure.h"
|
||||
#include "c-ctype.h"
|
||||
#include "fadvise.h"
|
||||
#include "quote.h"
|
||||
@@ -172,10 +173,37 @@ from any other non-alphabet bytes in the encoded stream.\n"),
|
||||
exit (status);
|
||||
}
|
||||
|
||||
#if BASE_TYPE != 64
|
||||
static int
|
||||
base32_required_padding (int len)
|
||||
{
|
||||
int partial = len % 8;
|
||||
return partial ? 8 - partial : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BASE_TYPE != 32
|
||||
static int
|
||||
base64_required_padding (int len)
|
||||
{
|
||||
int partial = len % 4;
|
||||
return partial ? 4 - partial : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BASE_TYPE == 42
|
||||
static int
|
||||
no_required_padding (int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ENC_BLOCKSIZE (1024 * 3 * 10)
|
||||
|
||||
#if BASE_TYPE == 32
|
||||
# define BASE_LENGTH BASE32_LENGTH
|
||||
# define REQUIRED_PADDING base32_required_padding
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
# define DEC_BLOCKSIZE (1024 * 5)
|
||||
@@ -188,9 +216,10 @@ static_assert (DEC_BLOCKSIZE % 40 == 0); /* Complete encoded blocks are used. */
|
||||
# define base_decode_context base32_decode_context
|
||||
# define base_decode_ctx_init base32_decode_ctx_init
|
||||
# define base_decode_ctx base32_decode_ctx
|
||||
# define isbase isbase32
|
||||
# define isubase isubase32
|
||||
#elif BASE_TYPE == 64
|
||||
# define BASE_LENGTH BASE64_LENGTH
|
||||
# define REQUIRED_PADDING base64_required_padding
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
# define DEC_BLOCKSIZE (1024 * 3)
|
||||
@@ -203,11 +232,12 @@ static_assert (DEC_BLOCKSIZE % 12 == 0); /* Complete encoded blocks are used. */
|
||||
# define base_decode_context base64_decode_context
|
||||
# define base_decode_ctx_init base64_decode_ctx_init
|
||||
# define base_decode_ctx base64_decode_ctx
|
||||
# define isbase isbase64
|
||||
# define isubase isubase64
|
||||
#elif BASE_TYPE == 42
|
||||
|
||||
|
||||
# define BASE_LENGTH base_length
|
||||
# define REQUIRED_PADDING required_padding
|
||||
|
||||
/* Note that increasing this may decrease performance if --ignore-garbage
|
||||
is used, because of the memmove operation below. */
|
||||
@@ -216,14 +246,15 @@ static_assert (DEC_BLOCKSIZE % 40 == 0); /* complete encoded blocks for base32*/
|
||||
static_assert (DEC_BLOCKSIZE % 12 == 0); /* complete encoded blocks for base64*/
|
||||
|
||||
static int (*base_length) (int i);
|
||||
static bool (*isbase) (char ch);
|
||||
static int (*required_padding) (int i);
|
||||
static bool (*isubase) (unsigned char ch);
|
||||
static void (*base_encode) (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen);
|
||||
|
||||
struct base16_decode_context
|
||||
{
|
||||
char nibble;
|
||||
bool have_nibble;
|
||||
/* Either a 4-bit nibble, or negative if we have no nibble. */
|
||||
signed char nibble;
|
||||
};
|
||||
|
||||
struct z85_decode_context
|
||||
@@ -319,10 +350,10 @@ base64url_encode (char const *restrict in, idx_t inlen,
|
||||
}
|
||||
|
||||
static bool
|
||||
isbase64url (char ch)
|
||||
isubase64url (unsigned char ch)
|
||||
{
|
||||
return (ch == '-' || ch == '_'
|
||||
|| (ch != '+' && ch != '/' && isbase64 (ch)));
|
||||
|| (ch != '+' && ch != '/' && isubase64 (ch)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -432,7 +463,7 @@ static const char base32_hex_to_norm[32 + 9] = {
|
||||
|
||||
|
||||
inline static bool
|
||||
isbase32hex (char ch)
|
||||
isubase32hex (unsigned char ch)
|
||||
{
|
||||
return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'V');
|
||||
}
|
||||
@@ -471,8 +502,8 @@ base32hex_decode_ctx_wrapper (struct base_decode_context *ctx,
|
||||
char *p = ctx->inbuf;
|
||||
while (i--)
|
||||
{
|
||||
if (isbase32hex (*in))
|
||||
*p = base32_hex_to_norm[ (int)*in - 0x30];
|
||||
if (isubase32hex (*in))
|
||||
*p = base32_hex_to_norm[*in - 0x30];
|
||||
else
|
||||
*p = *in;
|
||||
++p;
|
||||
@@ -485,12 +516,105 @@ base32hex_decode_ctx_wrapper (struct base_decode_context *ctx,
|
||||
|
||||
return b;
|
||||
}
|
||||
/* With this approach this file works independent of the charset used
|
||||
(think EBCDIC). However, it does assume that the characters in the
|
||||
Base32 alphabet (A-Z2-7) are encoded in 0..255. POSIX
|
||||
1003.1-2001 require that char and unsigned char are 8-bit
|
||||
quantities, though, taking care of that problem. But this may be a
|
||||
potential problem on non-POSIX C99 platforms.
|
||||
|
||||
IBM C V6 for AIX mishandles "#define B32(x) ...'x'...", so use "_"
|
||||
as the formal parameter rather than "x". */
|
||||
# define B16(_) \
|
||||
((_) == '0' ? 0 \
|
||||
: (_) == '1' ? 1 \
|
||||
: (_) == '2' ? 2 \
|
||||
: (_) == '3' ? 3 \
|
||||
: (_) == '4' ? 4 \
|
||||
: (_) == '5' ? 5 \
|
||||
: (_) == '6' ? 6 \
|
||||
: (_) == '7' ? 7 \
|
||||
: (_) == '8' ? 8 \
|
||||
: (_) == '9' ? 9 \
|
||||
: (_) == 'A' || (_) == 'a' ? 10 \
|
||||
: (_) == 'B' || (_) == 'b' ? 11 \
|
||||
: (_) == 'C' || (_) == 'c' ? 12 \
|
||||
: (_) == 'D' || (_) == 'd' ? 13 \
|
||||
: (_) == 'E' || (_) == 'e' ? 14 \
|
||||
: (_) == 'F' || (_) == 'f' ? 15 \
|
||||
: -1)
|
||||
|
||||
static signed char const base16_to_int[256] = {
|
||||
B16 (0), B16 (1), B16 (2), B16 (3),
|
||||
B16 (4), B16 (5), B16 (6), B16 (7),
|
||||
B16 (8), B16 (9), B16 (10), B16 (11),
|
||||
B16 (12), B16 (13), B16 (14), B16 (15),
|
||||
B16 (16), B16 (17), B16 (18), B16 (19),
|
||||
B16 (20), B16 (21), B16 (22), B16 (23),
|
||||
B16 (24), B16 (25), B16 (26), B16 (27),
|
||||
B16 (28), B16 (29), B16 (30), B16 (31),
|
||||
B16 (32), B16 (33), B16 (34), B16 (35),
|
||||
B16 (36), B16 (37), B16 (38), B16 (39),
|
||||
B16 (40), B16 (41), B16 (42), B16 (43),
|
||||
B16 (44), B16 (45), B16 (46), B16 (47),
|
||||
B16 (48), B16 (49), B16 (50), B16 (51),
|
||||
B16 (52), B16 (53), B16 (54), B16 (55),
|
||||
B16 (56), B16 (57), B16 (58), B16 (59),
|
||||
B16 (60), B16 (61), B16 (62), B16 (63),
|
||||
B16 (32), B16 (65), B16 (66), B16 (67),
|
||||
B16 (68), B16 (69), B16 (70), B16 (71),
|
||||
B16 (72), B16 (73), B16 (74), B16 (75),
|
||||
B16 (76), B16 (77), B16 (78), B16 (79),
|
||||
B16 (80), B16 (81), B16 (82), B16 (83),
|
||||
B16 (84), B16 (85), B16 (86), B16 (87),
|
||||
B16 (88), B16 (89), B16 (90), B16 (91),
|
||||
B16 (92), B16 (93), B16 (94), B16 (95),
|
||||
B16 (96), B16 (97), B16 (98), B16 (99),
|
||||
B16 (100), B16 (101), B16 (102), B16 (103),
|
||||
B16 (104), B16 (105), B16 (106), B16 (107),
|
||||
B16 (108), B16 (109), B16 (110), B16 (111),
|
||||
B16 (112), B16 (113), B16 (114), B16 (115),
|
||||
B16 (116), B16 (117), B16 (118), B16 (119),
|
||||
B16 (120), B16 (121), B16 (122), B16 (123),
|
||||
B16 (124), B16 (125), B16 (126), B16 (127),
|
||||
B16 (128), B16 (129), B16 (130), B16 (131),
|
||||
B16 (132), B16 (133), B16 (134), B16 (135),
|
||||
B16 (136), B16 (137), B16 (138), B16 (139),
|
||||
B16 (140), B16 (141), B16 (142), B16 (143),
|
||||
B16 (144), B16 (145), B16 (146), B16 (147),
|
||||
B16 (148), B16 (149), B16 (150), B16 (151),
|
||||
B16 (152), B16 (153), B16 (154), B16 (155),
|
||||
B16 (156), B16 (157), B16 (158), B16 (159),
|
||||
B16 (160), B16 (161), B16 (162), B16 (163),
|
||||
B16 (132), B16 (165), B16 (166), B16 (167),
|
||||
B16 (168), B16 (169), B16 (170), B16 (171),
|
||||
B16 (172), B16 (173), B16 (174), B16 (175),
|
||||
B16 (176), B16 (177), B16 (178), B16 (179),
|
||||
B16 (180), B16 (181), B16 (182), B16 (183),
|
||||
B16 (184), B16 (185), B16 (186), B16 (187),
|
||||
B16 (188), B16 (189), B16 (190), B16 (191),
|
||||
B16 (192), B16 (193), B16 (194), B16 (195),
|
||||
B16 (196), B16 (197), B16 (198), B16 (199),
|
||||
B16 (200), B16 (201), B16 (202), B16 (203),
|
||||
B16 (204), B16 (205), B16 (206), B16 (207),
|
||||
B16 (208), B16 (209), B16 (210), B16 (211),
|
||||
B16 (212), B16 (213), B16 (214), B16 (215),
|
||||
B16 (216), B16 (217), B16 (218), B16 (219),
|
||||
B16 (220), B16 (221), B16 (222), B16 (223),
|
||||
B16 (224), B16 (225), B16 (226), B16 (227),
|
||||
B16 (228), B16 (229), B16 (230), B16 (231),
|
||||
B16 (232), B16 (233), B16 (234), B16 (235),
|
||||
B16 (236), B16 (237), B16 (238), B16 (239),
|
||||
B16 (240), B16 (241), B16 (242), B16 (243),
|
||||
B16 (244), B16 (245), B16 (246), B16 (247),
|
||||
B16 (248), B16 (249), B16 (250), B16 (251),
|
||||
B16 (252), B16 (253), B16 (254), B16 (255)
|
||||
};
|
||||
|
||||
static bool
|
||||
isbase16 (char ch)
|
||||
isubase16 (unsigned char ch)
|
||||
{
|
||||
return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F');
|
||||
return ch < sizeof base16_to_int && 0 <= base16_to_int[ch];
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -499,18 +623,21 @@ base16_length (int len)
|
||||
return len * 2;
|
||||
}
|
||||
|
||||
static const char base16[16] = "0123456789ABCDEF";
|
||||
|
||||
static void
|
||||
base16_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
static const char base16[16] = "0123456789ABCDEF";
|
||||
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
*out++ = base16[c >> 4];
|
||||
*out++ = base16[c & 0x0F];
|
||||
++in;
|
||||
inlen--;
|
||||
outlen -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,7 +646,7 @@ static void
|
||||
base16_decode_ctx_init (struct base_decode_context *ctx)
|
||||
{
|
||||
init_inbuf (ctx);
|
||||
ctx->ctx.base16.have_nibble = false;
|
||||
ctx->ctx.base16.nibble = -1;
|
||||
ctx->i = 1;
|
||||
}
|
||||
|
||||
@@ -530,44 +657,42 @@ base16_decode_ctx (struct base_decode_context *ctx,
|
||||
char *restrict out, idx_t *outlen)
|
||||
{
|
||||
bool ignore_lines = true; /* for now, always ignore them */
|
||||
|
||||
*outlen = 0;
|
||||
char *out0 = out;
|
||||
signed char nibble = ctx->ctx.base16.nibble;
|
||||
|
||||
/* inlen==0 is request to flush output.
|
||||
if there is a dangling high nibble - we are missing the low nibble,
|
||||
so return false - indicating an invalid input. */
|
||||
if (inlen == 0)
|
||||
return !ctx->ctx.base16.have_nibble;
|
||||
{
|
||||
*outlen = 0;
|
||||
return nibble < 0;
|
||||
}
|
||||
|
||||
while (inlen--)
|
||||
{
|
||||
if (ignore_lines && *in == '\n')
|
||||
unsigned char c = *in++;
|
||||
if (ignore_lines && c == '\n')
|
||||
continue;
|
||||
|
||||
if (sizeof base16_to_int <= c || base16_to_int[c] < 0)
|
||||
{
|
||||
++in;
|
||||
continue;
|
||||
*outlen = out - out0;
|
||||
return false; /* garbage - return false */
|
||||
}
|
||||
|
||||
int nib = *in++;
|
||||
if ('0' <= nib && nib <= '9')
|
||||
nib -= '0';
|
||||
else if ('A' <= nib && nib <= 'F')
|
||||
nib -= 'A' - 10;
|
||||
if (nibble < 0)
|
||||
nibble = base16_to_int[c];
|
||||
else
|
||||
return false; /* garbage - return false */
|
||||
|
||||
if (ctx->ctx.base16.have_nibble)
|
||||
{
|
||||
/* have both nibbles, write octet */
|
||||
*out++ = (ctx->ctx.base16.nibble << 4) + nib;
|
||||
++(*outlen);
|
||||
*out++ = (nibble << 4) + base16_to_int[c];
|
||||
nibble = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Store higher nibble until next one arrives */
|
||||
ctx->ctx.base16.nibble = nib;
|
||||
}
|
||||
ctx->ctx.base16.have_nibble = !ctx->ctx.base16.have_nibble;
|
||||
}
|
||||
|
||||
ctx->ctx.base16.nibble = nibble;
|
||||
*outlen = out - out0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -583,7 +708,7 @@ z85_length (int len)
|
||||
}
|
||||
|
||||
static bool
|
||||
isz85 (char ch)
|
||||
isuz85 (unsigned char ch)
|
||||
{
|
||||
return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
|
||||
}
|
||||
@@ -765,7 +890,7 @@ z85_decode_ctx (struct base_decode_context *ctx,
|
||||
|
||||
|
||||
inline static bool
|
||||
isbase2 (char ch)
|
||||
isubase2 (unsigned char ch)
|
||||
{
|
||||
return ch == '0' || ch == '1';
|
||||
}
|
||||
@@ -781,7 +906,7 @@ inline static void
|
||||
base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -789,6 +914,7 @@ base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x80 ? '1' : '0';
|
||||
c <<= 1;
|
||||
}
|
||||
inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
@@ -798,7 +924,7 @@ inline static void
|
||||
base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
while (inlen--)
|
||||
while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -806,6 +932,7 @@ base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x01 ? '1' : '0';
|
||||
c >>= 1;
|
||||
}
|
||||
inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
@@ -844,7 +971,7 @@ base2lsbf_decode_ctx (struct base_decode_context *ctx,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isbase2 (*in))
|
||||
if (!isubase2 (*in))
|
||||
return false;
|
||||
|
||||
bool bit = (*in == '1');
|
||||
@@ -888,7 +1015,7 @@ base2msbf_decode_ctx (struct base_decode_context *ctx,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isbase2 (*in))
|
||||
if (!isubase2 (*in))
|
||||
return false;
|
||||
|
||||
bool bit = (*in == '1');
|
||||
@@ -1011,6 +1138,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
idx_t sum;
|
||||
struct base_decode_context ctx;
|
||||
|
||||
char padbuf[8] = "========";
|
||||
inbuf = xmalloc (BASE_LENGTH (DEC_BLOCKSIZE));
|
||||
outbuf = xmalloc (DEC_BLOCKSIZE);
|
||||
|
||||
@@ -1033,7 +1161,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
{
|
||||
for (idx_t i = 0; n > 0 && i < n;)
|
||||
{
|
||||
if (isbase (inbuf[sum + i]) || inbuf[sum + i] == '=')
|
||||
if (isubase (inbuf[sum + i]) || inbuf[sum + i] == '=')
|
||||
i++;
|
||||
else
|
||||
memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
|
||||
@@ -1053,10 +1181,25 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
telling it to flush what is in CTX. */
|
||||
for (int k = 0; k < 1 + !!feof (in); k++)
|
||||
{
|
||||
if (k == 1 && ctx.i == 0)
|
||||
break;
|
||||
if (k == 1)
|
||||
{
|
||||
if (ctx.i == 0)
|
||||
break;
|
||||
|
||||
/* auto pad input (at eof). */
|
||||
idx_t auto_padding = REQUIRED_PADDING (ctx.i);
|
||||
if (auto_padding && (sum == 0 || inbuf[sum - 1] != '='))
|
||||
{
|
||||
affirm (auto_padding <= sizeof (padbuf));
|
||||
IF_LINT (free (inbuf));
|
||||
sum = auto_padding;
|
||||
inbuf = padbuf;
|
||||
}
|
||||
else
|
||||
sum = 0; /* process ctx buffer only */
|
||||
}
|
||||
idx_t n = DEC_BLOCKSIZE;
|
||||
ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
ok = base_decode_ctx (&ctx, inbuf, sum, outbuf, &n);
|
||||
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
write_error ();
|
||||
@@ -1145,7 +1288,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
case BASE64_OPTION:
|
||||
base_length = base64_length_wrapper;
|
||||
isbase = isbase64;
|
||||
required_padding = base64_required_padding;
|
||||
isubase = isubase64;
|
||||
base_encode = base64_encode;
|
||||
base_decode_ctx_init = base64_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base64_decode_ctx_wrapper;
|
||||
@@ -1153,7 +1297,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE64URL_OPTION:
|
||||
base_length = base64_length_wrapper;
|
||||
isbase = isbase64url;
|
||||
required_padding = base64_required_padding;
|
||||
isubase = isubase64url;
|
||||
base_encode = base64url_encode;
|
||||
base_decode_ctx_init = base64url_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base64url_decode_ctx_wrapper;
|
||||
@@ -1161,7 +1306,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE32_OPTION:
|
||||
base_length = base32_length_wrapper;
|
||||
isbase = isbase32;
|
||||
required_padding = base32_required_padding;
|
||||
isubase = isubase32;
|
||||
base_encode = base32_encode;
|
||||
base_decode_ctx_init = base32_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base32_decode_ctx_wrapper;
|
||||
@@ -1169,7 +1315,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE32HEX_OPTION:
|
||||
base_length = base32_length_wrapper;
|
||||
isbase = isbase32hex;
|
||||
required_padding = base32_required_padding;
|
||||
isubase = isubase32hex;
|
||||
base_encode = base32hex_encode;
|
||||
base_decode_ctx_init = base32hex_decode_ctx_init_wrapper;
|
||||
base_decode_ctx = base32hex_decode_ctx_wrapper;
|
||||
@@ -1177,7 +1324,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE16_OPTION:
|
||||
base_length = base16_length;
|
||||
isbase = isbase16;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase16;
|
||||
base_encode = base16_encode;
|
||||
base_decode_ctx_init = base16_decode_ctx_init;
|
||||
base_decode_ctx = base16_decode_ctx;
|
||||
@@ -1185,7 +1333,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE2MSBF_OPTION:
|
||||
base_length = base2_length;
|
||||
isbase = isbase2;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase2;
|
||||
base_encode = base2msbf_encode;
|
||||
base_decode_ctx_init = base2_decode_ctx_init;
|
||||
base_decode_ctx = base2msbf_decode_ctx;
|
||||
@@ -1193,7 +1342,8 @@ main (int argc, char **argv)
|
||||
|
||||
case BASE2LSBF_OPTION:
|
||||
base_length = base2_length;
|
||||
isbase = isbase2;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isubase2;
|
||||
base_encode = base2lsbf_encode;
|
||||
base_decode_ctx_init = base2_decode_ctx_init;
|
||||
base_decode_ctx = base2lsbf_decode_ctx;
|
||||
@@ -1201,7 +1351,8 @@ main (int argc, char **argv)
|
||||
|
||||
case Z85_OPTION:
|
||||
base_length = z85_length;
|
||||
isbase = isz85;
|
||||
required_padding = no_required_padding;
|
||||
isubase = isuz85;
|
||||
base_encode = z85_encode;
|
||||
base_decode_ctx_init = z85_decode_ctx_init;
|
||||
base_decode_ctx = z85_decode_ctx;
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "blake2.h"
|
||||
|
||||
@@ -133,6 +127,11 @@ cleanup_buffer:
|
||||
|
||||
#if 0
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int blake2sp_stream( FILE *stream, void *resstream, size_t outbytes )
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdckdint.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
@@ -644,7 +643,7 @@ main (int argc, char **argv)
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
/* Optimal size of i/o operations of output. */
|
||||
idx_t outsize = io_blksize (stat_buf);
|
||||
idx_t outsize = io_blksize (&stat_buf);
|
||||
|
||||
/* Device and I-node number of the output. */
|
||||
dev_t out_dev = stat_buf.st_dev;
|
||||
@@ -698,7 +697,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Optimal size of i/o operations of input. */
|
||||
idx_t insize = io_blksize (stat_buf);
|
||||
idx_t insize = io_blksize (&stat_buf);
|
||||
|
||||
fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chcon -- change security context of files
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
315
src/chgrp.c
315
src/chgrp.c
@@ -1,315 +0,0 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "chown-core.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
#define PROGRAM_NAME "chgrp"
|
||||
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Jim Meyering")
|
||||
|
||||
#if ! HAVE_ENDGRENT
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
/* The argument to the --reference option. Use the group ID of this file.
|
||||
This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
DEREFERENCE_OPTION = CHAR_MAX + 1,
|
||||
NO_PRESERVE_ROOT,
|
||||
PRESERVE_ROOT,
|
||||
REFERENCE_FILE_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
|
||||
{"no-dereference", no_argument, nullptr, 'h'},
|
||||
{"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, nullptr, 'f'},
|
||||
{"silent", no_argument, nullptr, 'f'},
|
||||
{"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return the group ID of NAME, or -1 if no name was specified. */
|
||||
|
||||
static gid_t
|
||||
parse_group (char const *name)
|
||||
{
|
||||
gid_t gid = -1;
|
||||
|
||||
if (*name)
|
||||
{
|
||||
struct group *grp = getgrnam (name);
|
||||
if (grp)
|
||||
gid = grp->gr_gid;
|
||||
else
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (! (xstrtoumax (name, nullptr, 10, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= GID_T_MAX))
|
||||
error (EXIT_FAILURE, 0, _("invalid group: %s"),
|
||||
quote (name));
|
||||
gid = tmp;
|
||||
}
|
||||
endgrent (); /* Save a file descriptor. */
|
||||
}
|
||||
|
||||
return gid;
|
||||
}
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != EXIT_SUCCESS)
|
||||
emit_try_help ();
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... GROUP FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
Change the group of each FILE to GROUP.\n\
|
||||
With --reference, change the group of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose output a diagnostic for every file processed\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--dereference affect the referent of each symbolic link (this is\n\
|
||||
the default), rather than the symbolic link itself\n\
|
||||
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
(useful only on systems that can change the\n\
|
||||
ownership of a symlink)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve-root do not treat '/' specially (the default)\n\
|
||||
--preserve-root fail to operate recursively on '/'\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--reference=RFILE use RFILE's group rather than specifying a GROUP.\n\
|
||||
RFILE is always dereferenced if a symbolic link.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-R, --recursive operate on files and directories recursively\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The following options modify how a hierarchy is traversed when the -R\n\
|
||||
option is also specified. If more than one is specified, only the final\n\
|
||||
one takes effect.\n\
|
||||
\n\
|
||||
-H if a command line argument is a symbolic link\n\
|
||||
to a directory, traverse it\n\
|
||||
-L traverse every symbolic link to a directory\n\
|
||||
encountered\n\
|
||||
-P do not traverse any symbolic links (default)\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s staff /u Change the group of /u to \"staff\".\n\
|
||||
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_ancillary_info (PROGRAM_NAME);
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool preserve_root = false;
|
||||
gid_t gid;
|
||||
|
||||
/* Bit flags that control how fts works. */
|
||||
int bit_flags = FTS_PHYSICAL;
|
||||
|
||||
/* 1 if --dereference, 0 if --no-dereference, -1 if neither has been
|
||||
specified. */
|
||||
int dereference = -1;
|
||||
|
||||
struct Chown_option chopt;
|
||||
bool ok;
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
chopt_init (&chopt);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 'H': /* Traverse command-line symlinks-to-directories. */
|
||||
bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'L': /* Traverse all symlinks-to-directories. */
|
||||
bit_flags = FTS_LOGICAL;
|
||||
break;
|
||||
|
||||
case 'P': /* Traverse no symlinks-to-directories. */
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'h': /* --no-dereference: affect symlinks */
|
||||
dereference = 0;
|
||||
break;
|
||||
|
||||
case DEREFERENCE_OPTION: /* --dereference: affect the referent
|
||||
of each symlink */
|
||||
dereference = 1;
|
||||
break;
|
||||
|
||||
case NO_PRESERVE_ROOT:
|
||||
preserve_root = false;
|
||||
break;
|
||||
|
||||
case PRESERVE_ROOT:
|
||||
preserve_root = true;
|
||||
break;
|
||||
|
||||
case REFERENCE_FILE_OPTION:
|
||||
reference_file = optarg;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
chopt.recurse = true;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
chopt.verbosity = V_changes_only;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
chopt.force_silent = true;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
chopt.verbosity = V_high;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (chopt.recurse)
|
||||
{
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
}
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
gid = ref_stats.st_gid;
|
||||
chopt.group_name = gid_to_name (ref_stats.st_gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *group_name = argv[optind++];
|
||||
chopt.group_name = (*group_name ? xstrdup (group_name) : nullptr);
|
||||
gid = parse_group (group_name);
|
||||
}
|
||||
|
||||
if (chopt.recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == nullptr)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = chown_files (argv + optind, bit_flags,
|
||||
(uid_t) -1, gid,
|
||||
(uid_t) -1, (gid_t) -1, &chopt);
|
||||
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
111
src/chmod.c
111
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -74,6 +74,10 @@ static mode_t umask_value;
|
||||
/* If true, change the modes of directories recursively. */
|
||||
static bool recurse;
|
||||
|
||||
/* 1 if --dereference, 0 if --no-dereference, -1 if neither has been
|
||||
specified. */
|
||||
static int dereference = -1;
|
||||
|
||||
/* If true, force silence (suppress most of error messages). */
|
||||
static bool force_silent;
|
||||
|
||||
@@ -93,7 +97,8 @@ static struct dev_ino *root_dev_ino;
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
NO_PRESERVE_ROOT = CHAR_MAX + 1,
|
||||
DEREFERENCE_OPTION = CHAR_MAX + 1,
|
||||
NO_PRESERVE_ROOT,
|
||||
PRESERVE_ROOT,
|
||||
REFERENCE_FILE_OPTION
|
||||
};
|
||||
@@ -101,7 +106,9 @@ enum
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"no-dereference", no_argument, nullptr, 'h'},
|
||||
{"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
|
||||
{"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
|
||||
{"quiet", no_argument, nullptr, 'f'},
|
||||
@@ -205,8 +212,9 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
char const *file_full_name = ent->fts_path;
|
||||
char const *file = ent->fts_accpath;
|
||||
const struct stat *file_stats = ent->fts_statp;
|
||||
struct change_status ch = { 0, };
|
||||
struct change_status ch = {0};
|
||||
ch.status = CH_NO_STAT;
|
||||
struct stat stat_buf;
|
||||
|
||||
switch (ent->fts_info)
|
||||
{
|
||||
@@ -244,9 +252,30 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
break;
|
||||
|
||||
case FTS_SLNONE:
|
||||
if (! force_silent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quoteaf (file_full_name));
|
||||
if (dereference)
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quoteaf (file_full_name));
|
||||
break;
|
||||
}
|
||||
ch.status = CH_NOT_APPLIED;
|
||||
break;
|
||||
|
||||
case FTS_SL:
|
||||
if (dereference == 1)
|
||||
{
|
||||
if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("cannot dereference %s"),
|
||||
quoteaf (file_full_name));
|
||||
break;
|
||||
}
|
||||
|
||||
file_stats = &stat_buf;
|
||||
}
|
||||
ch.status = CH_NOT_APPLIED;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
@@ -272,19 +301,28 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ch.status == CH_NOT_APPLIED && ! S_ISLNK (file_stats->st_mode))
|
||||
if (ch.status == CH_NOT_APPLIED)
|
||||
{
|
||||
ch.old_mode = file_stats->st_mode;
|
||||
ch.new_mode = mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
|
||||
umask_value, change, nullptr);
|
||||
if (chmodat (fts->fts_cwd_fd, file, ch.new_mode) == 0)
|
||||
bool follow_symlink = !!dereference;
|
||||
if (dereference == -1) /* -H with/without -R, -P without -R. */
|
||||
follow_symlink = ent->fts_level == 0;
|
||||
if (fchmodat (fts->fts_cwd_fd, file, ch.new_mode,
|
||||
follow_symlink ? 0 : AT_SYMLINK_NOFOLLOW) == 0)
|
||||
ch.status = CH_SUCCEEDED;
|
||||
else
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("changing permissions of %s"),
|
||||
quoteaf (file_full_name));
|
||||
ch.status = CH_FAILED;
|
||||
if (! is_ENOTSUP (errno))
|
||||
{
|
||||
if (! force_silent)
|
||||
error (0, errno, _("changing permissions of %s"),
|
||||
quoteaf (file_full_name));
|
||||
|
||||
ch.status = CH_FAILED;
|
||||
}
|
||||
/* else treat not supported as not applied. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,6 +425,11 @@ With --reference, change the mode of each FILE to that of RFILE.\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose output a diagnostic for every file processed\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--dereference affect the referent of each symbolic link,\n\
|
||||
rather than the symbolic link itself\n\
|
||||
-h, --no-dereference affect each symbolic link, rather than the referent\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve-root do not treat '/' specially (the default)\n\
|
||||
@@ -399,6 +442,7 @@ With --reference, change the mode of each FILE to that of RFILE.\n\
|
||||
fputs (_("\
|
||||
-R, --recursive change files and directories recursively\n\
|
||||
"), stdout);
|
||||
emit_symlink_recurse_options ("-H");
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
@@ -423,6 +467,7 @@ main (int argc, char **argv)
|
||||
bool preserve_root = false;
|
||||
char const *reference_file = nullptr;
|
||||
int c;
|
||||
int bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -435,13 +480,35 @@ main (int argc, char **argv)
|
||||
recurse = force_silent = diagnose_surprises = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv,
|
||||
("Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::"
|
||||
("HLPRcfhvr::w::x::X::s::t::u::g::o::a::,::+::=::"
|
||||
"0::1::2::3::4::5::6::7::"),
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
case 'H': /* Traverse command-line symlinks-to-directories. */
|
||||
bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'L': /* Traverse all symlinks-to-directories. */
|
||||
bit_flags = FTS_LOGICAL;
|
||||
break;
|
||||
|
||||
case 'P': /* Traverse no symlinks-to-directories. */
|
||||
bit_flags = FTS_PHYSICAL;
|
||||
break;
|
||||
|
||||
case 'h': /* --no-dereference: affect symlinks */
|
||||
dereference = 0;
|
||||
break;
|
||||
|
||||
case DEREFERENCE_OPTION: /* --dereference: affect the referent
|
||||
of each symlink */
|
||||
dereference = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'w':
|
||||
case 'x':
|
||||
@@ -510,6 +577,20 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (recurse)
|
||||
{
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (dereference == -1 && bit_flags == FTS_LOGICAL)
|
||||
dereference = 1;
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
if (mode)
|
||||
@@ -564,8 +645,8 @@ main (int argc, char **argv)
|
||||
root_dev_ino = nullptr;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind,
|
||||
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
ok = process_files (argv + optind, bit_flags);
|
||||
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
2
src/chown-chgrp.c
Normal file
2
src/chown-chgrp.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "chown.h"
|
||||
int chown_mode = CHOWN_CHGRP;
|
||||
2
src/chown-chown.c
Normal file
2
src/chown-chown.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "chown.h"
|
||||
int chown_mode = CHOWN_CHOWN;
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown-core.c -- core functions for changing ownership.
|
||||
Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -43,7 +43,7 @@ enum RCH_status
|
||||
/* required_uid and/or required_gid are specified, but don't match */
|
||||
RC_excluded,
|
||||
|
||||
/* SAME_INODE check failed */
|
||||
/* The file was replaced by another file during the requested change. */
|
||||
RC_inode_changed,
|
||||
|
||||
/* open/fchown isn't needed, isn't safe, or doesn't work due to
|
||||
@@ -255,21 +255,16 @@ restricted_chown (int cwd_fd, char const *file,
|
||||
|
||||
if (fstat (fd, &st) != 0)
|
||||
status = RC_error;
|
||||
else if (! SAME_INODE (*orig_st, st))
|
||||
else if (! psame_inode (orig_st, &st))
|
||||
status = RC_inode_changed;
|
||||
else if ((required_uid == (uid_t) -1 || required_uid == st.st_uid)
|
||||
&& (required_gid == (gid_t) -1 || required_gid == st.st_gid))
|
||||
{
|
||||
#if HAVE_FCHOWN
|
||||
if (fchown (fd, uid, gid) == 0)
|
||||
{
|
||||
status = (close (fd) == 0
|
||||
? RC_ok : RC_error);
|
||||
return status;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = RC_error;
|
||||
}
|
||||
return close (fd) < 0 ? RC_error : RC_ok;
|
||||
#endif
|
||||
status = RC_error;
|
||||
}
|
||||
|
||||
int saved_errno = errno;
|
||||
@@ -425,7 +420,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
/* Ignore any error due to lack of support; POSIX requires
|
||||
this behavior for top-level symbolic links with -h, and
|
||||
implies that it's required for all symbolic links. */
|
||||
if (!ok && errno == EOPNOTSUPP)
|
||||
if (!ok && is_ENOTSUP (errno))
|
||||
{
|
||||
ok = true;
|
||||
symlink_changed = false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* chown-core.h -- types and prototypes shared by chown and chgrp.
|
||||
|
||||
Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
81
src/chown.c
81
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
/* chown, chgrp -- change user and group ownership of files
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "chown.h"
|
||||
#include "chown-core.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
@@ -29,7 +30,7 @@
|
||||
#include "userspec.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
#define PROGRAM_NAME "chown"
|
||||
#define PROGRAM_NAME (chown_mode == CHOWN_CHOWN ? "chown" : "chgrp")
|
||||
|
||||
#define AUTHORS \
|
||||
proper_name ("David MacKenzie"), \
|
||||
@@ -76,14 +77,23 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... [OWNER][:[GROUP]] FILE...\n\
|
||||
Usage: %s [OPTION]... %s FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
program_name,
|
||||
chown_mode == CHOWN_CHOWN ? _("[OWNER][:[GROUP]]") : _("GROUP"),
|
||||
program_name);
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
fputs (_("\
|
||||
Change the owner and/or group of each FILE to OWNER and/or GROUP.\n\
|
||||
With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
else
|
||||
fputs (_("\
|
||||
Change the group of each FILE to GROUP.\n\
|
||||
With --reference, change the group of each FILE to that of RFILE.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
@@ -101,9 +111,9 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--from=CURRENT_OWNER:CURRENT_GROUP\n\
|
||||
change the owner and/or group of each file only if\n\
|
||||
change the ownership of each file only if\n\
|
||||
its current owner and/or group match those specified\n\
|
||||
here. Either may be omitted, in which case a match\n\
|
||||
here. Either may be omitted, in which case a match\n\
|
||||
is not required for the omitted attribute\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -111,34 +121,25 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
--preserve-root fail to operate recursively on '/'\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--reference=RFILE use RFILE's owner and group rather than specifying\n\
|
||||
OWNER:GROUP values. RFILE is always dereferenced.\n\
|
||||
--reference=RFILE use RFILE's ownership rather than specifying values\n\
|
||||
RFILE is always dereferenced if a symbolic link.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-R, --recursive operate on files and directories recursively\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
The following options modify how a hierarchy is traversed when the -R\n\
|
||||
option is also specified. If more than one is specified, only the final\n\
|
||||
one takes effect.\n\
|
||||
\n\
|
||||
-H if a command line argument is a symbolic link\n\
|
||||
to a directory, traverse it\n\
|
||||
-L traverse every symbolic link to a directory\n\
|
||||
encountered\n\
|
||||
-P do not traverse any symbolic links (default)\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
emit_symlink_recurse_options ("-P");
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
fputs (_("\
|
||||
\n\
|
||||
Owner is unchanged if missing. Group is unchanged if missing, but changed\n\
|
||||
to login group if implied by a ':' following a symbolic OWNER.\n\
|
||||
OWNER and GROUP may be numeric as well as symbolic.\n\
|
||||
"), stdout);
|
||||
printf (_("\
|
||||
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s root /u Change the owner of /u to \"root\".\n\
|
||||
@@ -146,6 +147,14 @@ Examples:\n\
|
||||
%s -hR root /u Change the owner of /u and subfiles to \"root\".\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
else
|
||||
printf (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
%s staff /u Change the group of /u to \"staff\".\n\
|
||||
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_ancillary_info (PROGRAM_NAME);
|
||||
}
|
||||
exit (status);
|
||||
@@ -289,24 +298,38 @@ main (int argc, char **argv)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
uid = ref_stats.st_uid;
|
||||
if (chown_mode == CHOWN_CHOWN)
|
||||
{
|
||||
uid = ref_stats.st_uid;
|
||||
chopt.user_name = uid_to_name (ref_stats.st_uid);
|
||||
}
|
||||
gid = ref_stats.st_gid;
|
||||
chopt.user_name = uid_to_name (ref_stats.st_uid);
|
||||
chopt.group_name = gid_to_name (ref_stats.st_gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *ug = argv[optind];
|
||||
if (chown_mode == CHOWN_CHGRP)
|
||||
{
|
||||
ug = xmalloc (1 + strlen (argv[optind]) + 1);
|
||||
stpcpy (stpcpy (ug, ":"), argv[optind]);
|
||||
}
|
||||
|
||||
bool warn;
|
||||
char const *e = parse_user_spec_warn (argv[optind], &uid, &gid,
|
||||
char const *e = parse_user_spec_warn (ug, &uid, &gid,
|
||||
&chopt.user_name,
|
||||
&chopt.group_name, &warn);
|
||||
|
||||
if (ug != argv[optind])
|
||||
free (ug);
|
||||
|
||||
if (e)
|
||||
error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
|
||||
|
||||
/* If a group is specified but no user, set the user name to the
|
||||
empty string so that diagnostics say "ownership :GROUP"
|
||||
rather than "group GROUP". */
|
||||
if (!chopt.user_name && chopt.group_name)
|
||||
if (chown_mode == CHOWN_CHOWN && !chopt.user_name && chopt.group_name)
|
||||
chopt.user_name = xstrdup ("");
|
||||
|
||||
optind++;
|
||||
|
||||
7
src/chown.h
Normal file
7
src/chown.h
Normal file
@@ -0,0 +1,7 @@
|
||||
/* This is for the 'chown' program. */
|
||||
#define CHOWN_CHOWN 1
|
||||
|
||||
/* This is for the 'chgrp' program. */
|
||||
#define CHOWN_CHGRP 2
|
||||
|
||||
extern int chown_mode;
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chroot -- run command or shell with special root directory
|
||||
Copyright (C) 1995-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -17,6 +17,7 @@
|
||||
/* Written by Roland McGrath. */
|
||||
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX checksums and sizes of files
|
||||
Copyright (C) 1992-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX checksums and sizes of files
|
||||
Copyright (C) 1992-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
10
src/comm.c
10
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 1986-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -36,10 +36,6 @@
|
||||
proper_name ("Richard M. Stallman"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
/* True if the LC_COLLATE locale is hard. */
|
||||
static bool hard_LC_COLLATE;
|
||||
|
||||
@@ -149,7 +145,7 @@ and column three contains lines common to both files.\n\
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Note, comparisons honor the rules specified by 'LC_COLLATE'.\n\
|
||||
Comparisons honor the rules specified by 'LC_COLLATE'.\n\
|
||||
"), stdout);
|
||||
printf (_("\
|
||||
\n\
|
||||
@@ -319,7 +315,7 @@ compare_files (char **infiles)
|
||||
thisline[1]->buffer, thisline[1]->length - 1);
|
||||
else
|
||||
{
|
||||
size_t len = min (thisline[0]->length, thisline[1]->length) - 1;
|
||||
size_t len = MIN (thisline[0]->length, thisline[1]->length) - 1;
|
||||
order = memcmp (thisline[0]->buffer, thisline[1]->buffer, len);
|
||||
if (order == 0)
|
||||
order = ((thisline[0]->length > thisline[1]->length)
|
||||
|
||||
377
src/copy.c
377
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,6 @@
|
||||
/* Extracted from cp.c and librarified by Jim Meyering. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdckdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
@@ -92,11 +91,6 @@
|
||||
# include <sys/clonefile.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FCHOWN
|
||||
# define HAVE_FCHOWN false
|
||||
# define fchown(fd, uid, gid) (-1)
|
||||
#endif
|
||||
|
||||
#ifndef USE_ACL
|
||||
# define USE_ACL 0
|
||||
#endif
|
||||
@@ -772,7 +766,7 @@ copy_attr (char const *src_path, int src_fd,
|
||||
? check_selinux_attr : nullptr);
|
||||
|
||||
# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
|
||||
/* Pacify gcc -Wsuggest-attribute=format through at least GCC 11.2.1. */
|
||||
/* Pacify gcc -Wsuggest-attribute=format through at least GCC 13.2.1. */
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
|
||||
# endif
|
||||
@@ -881,6 +875,34 @@ copy_dir (char const *src_name_in, char const *dst_name_in,
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* Change the file mode bits of the file identified by DESC or
|
||||
DIRFD+NAME to MODE. Use DESC if DESC is valid and fchmod is
|
||||
available, DIRFD+NAME otherwise. */
|
||||
|
||||
static int
|
||||
fchmod_or_lchmod (int desc, int dirfd, char const *name, mode_t mode)
|
||||
{
|
||||
#if HAVE_FCHMOD
|
||||
if (0 <= desc)
|
||||
return fchmod (desc, mode);
|
||||
#endif
|
||||
return lchmodat (dirfd, name, mode);
|
||||
}
|
||||
|
||||
/* Change the ownership of the file identified by DESC or
|
||||
DIRFD+NAME to UID+GID. Use DESC if DESC is valid and fchown is
|
||||
available, DIRFD+NAME otherwise. */
|
||||
|
||||
static int
|
||||
fchown_or_lchown (int desc, int dirfd, char const *name, uid_t uid, gid_t gid)
|
||||
{
|
||||
#if HAVE_FCHOWN
|
||||
if (0 <= desc)
|
||||
return fchown (desc, uid, gid);
|
||||
#endif
|
||||
return lchownat (dirfd, name, uid, gid);
|
||||
}
|
||||
|
||||
/* Set the owner and owning group of DEST_DESC to the st_uid and
|
||||
st_gid fields of SRC_SB. If DEST_DESC is undefined (-1), set
|
||||
the owner and owning group of DST_NAME aka DST_DIRFD+DST_RELNAME
|
||||
@@ -927,34 +949,16 @@ set_owner (const struct cp_options *x, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
if (HAVE_FCHOWN && dest_desc != -1)
|
||||
{
|
||||
if (fchown (dest_desc, uid, gid) == 0)
|
||||
return 1;
|
||||
if (errno == EPERM || errno == EINVAL)
|
||||
{
|
||||
/* We've failed to set *both*. Now, try to set just the group
|
||||
ID, but ignore any failure here, and don't change errno. */
|
||||
int saved_errno = errno;
|
||||
ignore_value (fchown (dest_desc, -1, gid));
|
||||
errno = saved_errno;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lchownat (dst_dirfd, dst_relname, uid, gid) == 0)
|
||||
return 1;
|
||||
if (errno == EPERM || errno == EINVAL)
|
||||
{
|
||||
/* We've failed to set *both*. Now, try to set just the group
|
||||
ID, but ignore any failure here, and don't change errno. */
|
||||
int saved_errno = errno;
|
||||
ignore_value (lchownat (dst_dirfd, dst_relname, -1, gid));
|
||||
errno = saved_errno;
|
||||
}
|
||||
}
|
||||
if (fchown_or_lchown (dest_desc, dst_dirfd, dst_relname, uid, gid) == 0)
|
||||
return 1;
|
||||
|
||||
if (! chown_failure_ok (x))
|
||||
/* The ownership change failed. If the failure merely means we lack
|
||||
privileges to change owner+group, try to change just the group
|
||||
and ignore any failure of this. Otherwise, report an error. */
|
||||
if (chown_failure_ok (x))
|
||||
ignore_value (fchown_or_lchown (dest_desc, dst_dirfd, dst_relname,
|
||||
-1, gid));
|
||||
else
|
||||
{
|
||||
error (0, errno, _("failed to preserve ownership for %s"),
|
||||
quoteaf (dst_name));
|
||||
@@ -1016,23 +1020,23 @@ set_process_security_ctx (char const *src_name, char const *dst_name,
|
||||
/* Set the default context for the process to match the source. */
|
||||
bool all_errors = !x->data_copy_required || x->require_preserve_context;
|
||||
bool some_errors = !all_errors && !x->reduce_diagnostics;
|
||||
char *con;
|
||||
char *con_raw;
|
||||
|
||||
if (0 <= lgetfilecon (src_name, &con))
|
||||
if (0 <= lgetfilecon_raw (src_name, &con_raw))
|
||||
{
|
||||
if (setfscreatecon (con) < 0)
|
||||
if (setfscreatecon_raw (con_raw) < 0)
|
||||
{
|
||||
if (all_errors || (some_errors && !errno_unsupported (errno)))
|
||||
error (0, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (con));
|
||||
quote (con_raw));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
freecon (con);
|
||||
freecon (con_raw);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
freecon (con);
|
||||
freecon (con_raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1088,20 +1092,6 @@ set_file_security_ctx (char const *dst_name,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Change the file mode bits of the file identified by DESC or
|
||||
DIRFD+NAME to MODE. Use DESC if DESC is valid and fchmod is
|
||||
available, DIRFD+NAME otherwise. */
|
||||
|
||||
static int
|
||||
fchmod_or_lchmod (int desc, int dirfd, char const *name, mode_t mode)
|
||||
{
|
||||
#if HAVE_FCHMOD
|
||||
if (0 <= desc)
|
||||
return fchmod (desc, mode);
|
||||
#endif
|
||||
return lchmodat (dirfd, name, mode);
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
# define HAVE_STRUCT_STAT_ST_BLOCKS 0
|
||||
#endif
|
||||
@@ -1143,7 +1133,7 @@ infer_scantype (int fd, struct stat const *sb,
|
||||
suggests the file is sparse. */
|
||||
if (! (HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
&& S_ISREG (sb->st_mode)
|
||||
&& ST_NBLOCKS (*sb) < sb->st_size / ST_NBLOCKSIZE))
|
||||
&& STP_NBLOCKS (sb) < sb->st_size / ST_NBLOCKSIZE))
|
||||
return PLAIN_SCANTYPE;
|
||||
|
||||
#ifdef SEEK_HOLE
|
||||
@@ -1229,20 +1219,21 @@ handle_clone_fail (int dst_dirfd, char const *dst_relname,
|
||||
*NEW_DST is initially as in copy_internal.
|
||||
If successful, set *NEW_DST to true if the destination file was created and
|
||||
to false otherwise; if unsuccessful, perhaps set *NEW_DST to some value.
|
||||
SRC_SB is the result of calling follow_fstatat on SRC_NAME. */
|
||||
SRC_SB is the result of calling follow_fstatat on SRC_NAME;
|
||||
it might be updated by calling fstat again on the same file,
|
||||
to give it slightly more up-to-date contents. */
|
||||
|
||||
static bool
|
||||
copy_reg (char const *src_name, char const *dst_name,
|
||||
int dst_dirfd, char const *dst_relname,
|
||||
const struct cp_options *x,
|
||||
mode_t dst_mode, mode_t omitted_permissions, bool *new_dst,
|
||||
struct stat const *src_sb)
|
||||
struct stat *src_sb)
|
||||
{
|
||||
char *buf = nullptr;
|
||||
int dest_desc;
|
||||
int dest_errno;
|
||||
int source_desc;
|
||||
mode_t src_mode = src_sb->st_mode;
|
||||
mode_t extra_permissions;
|
||||
struct stat sb;
|
||||
struct stat src_open_sb;
|
||||
@@ -1273,7 +1264,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
/* Compare the source dev/ino from the open file to the incoming,
|
||||
saved ones obtained via a previous call to stat. */
|
||||
if (! SAME_INODE (*src_sb, src_open_sb))
|
||||
if (! psame_inode (src_sb, &src_open_sb))
|
||||
{
|
||||
error (0, 0,
|
||||
_("skipping file %s, as it was replaced while being copied"),
|
||||
@@ -1282,6 +1273,11 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
goto close_src_desc;
|
||||
}
|
||||
|
||||
/* Might as well tell the caller about the latest version of the
|
||||
source file status, since we have it already. */
|
||||
*src_sb = src_open_sb;
|
||||
mode_t src_mode = src_sb->st_mode;
|
||||
|
||||
/* The semantics of the following open calls are mandated
|
||||
by the specs for both cp and mv. */
|
||||
if (! *new_dst)
|
||||
@@ -1547,8 +1543,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
if (data_copy_required)
|
||||
{
|
||||
/* Choose a suitable buffer size; it may be adjusted later. */
|
||||
size_t buf_size = io_blksize (sb);
|
||||
size_t hole_size = ST_BLKSIZE (sb);
|
||||
size_t buf_size = io_blksize (&sb);
|
||||
size_t hole_size = STP_BLKSIZE (&sb);
|
||||
|
||||
/* Deal with sparse files. */
|
||||
enum scantype scantype = infer_scantype (source_desc, &src_open_sb,
|
||||
@@ -1576,7 +1572,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
Note we read in multiples of the reported block size
|
||||
to support (unusual) devices that have this constraint. */
|
||||
size_t blcm_max = MIN (SIZE_MAX, SSIZE_MAX);
|
||||
size_t blcm = buffer_lcm (io_blksize (src_open_sb), buf_size,
|
||||
size_t blcm = buffer_lcm (io_blksize (&src_open_sb), buf_size,
|
||||
blcm_max);
|
||||
|
||||
/* Do not bother with a buffer larger than the input file, plus one
|
||||
@@ -1746,7 +1742,7 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
|
||||
struct stat tmp_src_sb;
|
||||
|
||||
bool same_link;
|
||||
bool same = SAME_INODE (*src_sb, *dst_sb);
|
||||
bool same = psame_inode (src_sb, dst_sb);
|
||||
|
||||
*return_now = false;
|
||||
|
||||
@@ -1807,7 +1803,7 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
|
||||
src_sb_link = &tmp_src_sb;
|
||||
dst_sb_link = &tmp_dst_sb;
|
||||
|
||||
same_link = SAME_INODE (*src_sb_link, *dst_sb_link);
|
||||
same_link = psame_inode (src_sb_link, dst_sb_link);
|
||||
|
||||
/* If both are symlinks, then it's ok, but only if the destination
|
||||
will be unlinked before being opened. This is like the test
|
||||
@@ -1895,7 +1891,7 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
|
||||
hard links to the same file. */
|
||||
if (!S_ISLNK (src_sb_link->st_mode) && !S_ISLNK (dst_sb_link->st_mode))
|
||||
{
|
||||
if (!SAME_INODE (*src_sb_link, *dst_sb_link))
|
||||
if (!psame_inode (src_sb_link, dst_sb_link))
|
||||
return true;
|
||||
|
||||
/* If they are the same file, it's ok if we're making hard links. */
|
||||
@@ -1956,7 +1952,7 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
|
||||
else if (fstatat (dst_dirfd, dst_relname, &tmp_dst_sb, 0) != 0)
|
||||
return true;
|
||||
|
||||
if ( ! SAME_INODE (tmp_src_sb, tmp_dst_sb))
|
||||
if (!psame_inode (&tmp_src_sb, &tmp_dst_sb))
|
||||
return true;
|
||||
|
||||
if (x->hard_link)
|
||||
@@ -2079,9 +2075,10 @@ abandon_move (const struct cp_options *x,
|
||||
If BACKUP_DST_NAME is non-null, then also indicate that it is
|
||||
the name of a backup file. */
|
||||
static void
|
||||
emit_verbose (char const *src, char const *dst, char const *backup_dst_name)
|
||||
emit_verbose (char const *format, char const *src, char const *dst,
|
||||
char const *backup_dst_name)
|
||||
{
|
||||
printf ("%s -> %s", quoteaf_n (0, src), quoteaf_n (1, dst));
|
||||
printf (format, quoteaf_n (0, src), quoteaf_n (1, dst));
|
||||
if (backup_dst_name)
|
||||
printf (_(" (backup: %s)"), quoteaf (backup_dst_name));
|
||||
putchar ('\n');
|
||||
@@ -2175,7 +2172,7 @@ source_is_dst_backup (char const *srcbase, struct stat const *src_st,
|
||||
struct stat dst_back_sb;
|
||||
int dst_back_status = fstatat (dst_dirfd, dst_back, &dst_back_sb, 0);
|
||||
free (dst_back);
|
||||
return dst_back_status == 0 && SAME_INODE (*src_st, dst_back_sb);
|
||||
return dst_back_status == 0 && psame_inode (src_st, &dst_back_sb);
|
||||
}
|
||||
|
||||
/* Copy the file SRC_NAME to the file DST_NAME aka DST_DIRFD+DST_RELNAME.
|
||||
@@ -2220,22 +2217,16 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
bool dest_is_symlink = false;
|
||||
bool have_dst_lstat = false;
|
||||
|
||||
/* Whether the destination is (or was) known to be new, updated as
|
||||
more info comes in. This may become true if the destination is a
|
||||
dangling symlink, in contexts where dangling symlinks should be
|
||||
treated the same as nonexistent files. */
|
||||
bool new_dst = 0 < nonexistent_dst;
|
||||
|
||||
*copy_into_self = false;
|
||||
|
||||
int rename_errno = x->rename_errno;
|
||||
if (x->move_mode)
|
||||
if (x->move_mode && !x->exchange)
|
||||
{
|
||||
if (rename_errno < 0)
|
||||
rename_errno = (renameatu (AT_FDCWD, src_name, dst_dirfd, drelname,
|
||||
RENAME_NOREPLACE)
|
||||
? errno : 0);
|
||||
nonexistent_dst = *rename_succeeded = new_dst = rename_errno == 0;
|
||||
nonexistent_dst = *rename_succeeded = rename_errno == 0;
|
||||
}
|
||||
|
||||
if (rename_errno == 0
|
||||
@@ -2293,8 +2284,21 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
bool dereference = should_dereference (x, command_line_arg);
|
||||
|
||||
if (nonexistent_dst <= 0)
|
||||
/* Whether the destination is (or was) known to be new, updated as
|
||||
more info comes in. This may become true if the destination is a
|
||||
dangling symlink, in contexts where dangling symlinks should be
|
||||
treated the same as nonexistent files. */
|
||||
bool new_dst = 0 < nonexistent_dst;
|
||||
|
||||
if (! new_dst)
|
||||
{
|
||||
/* Normally, fill in DST_SB or set NEW_DST so that later code
|
||||
can use DST_SB if NEW_DST is false. However, don't bother
|
||||
doing this when rename_errno == EEXIST and X->interactive is
|
||||
I_ALWAYS_NO or I_ALWAYS_SKIP, something that can happen only
|
||||
with mv in which case x->update must be false which means
|
||||
that even if !NEW_DST the move will be abandoned without
|
||||
looking at DST_SB. */
|
||||
if (! (rename_errno == EEXIST
|
||||
&& (x->interactive == I_ALWAYS_NO
|
||||
|| x->interactive == I_ALWAYS_SKIP)))
|
||||
@@ -2308,30 +2312,31 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
bool use_lstat
|
||||
= ((! S_ISREG (src_mode)
|
||||
&& (! x->copy_as_regular
|
||||
|| S_ISDIR (src_mode) || S_ISLNK (src_mode)))
|
||||
|| (S_ISDIR (src_mode) && !x->keep_directory_symlink)
|
||||
|| S_ISLNK (src_mode)))
|
||||
|| x->move_mode || x->symbolic_link || x->hard_link
|
||||
|| x->backup_type != no_backups
|
||||
|| x->unlink_dest_before_opening);
|
||||
int fstatat_flags = use_lstat ? AT_SYMLINK_NOFOLLOW : 0;
|
||||
if (!use_lstat && nonexistent_dst < 0)
|
||||
new_dst = true;
|
||||
else if (follow_fstatat (dst_dirfd, drelname, &dst_sb, fstatat_flags)
|
||||
== 0)
|
||||
else if (0 <= follow_fstatat (dst_dirfd, drelname, &dst_sb,
|
||||
use_lstat ? AT_SYMLINK_NOFOLLOW : 0))
|
||||
{
|
||||
have_dst_lstat = use_lstat;
|
||||
rename_errno = EEXIST;
|
||||
}
|
||||
else if (errno == ENOENT)
|
||||
new_dst = true;
|
||||
else if (errno == ELOOP && !use_lstat
|
||||
&& x->unlink_dest_after_failed_open)
|
||||
{
|
||||
/* cp -f's destination might be a symlink loop.
|
||||
Leave new_dst=false so that we try to unlink later. */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errno == ELOOP && x->unlink_dest_after_failed_open)
|
||||
/* leave new_dst=false so we unlink later. */;
|
||||
else if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
new_dst = true;
|
||||
error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2445,72 +2450,36 @@ skip:
|
||||
if (return_now)
|
||||
return return_val;
|
||||
|
||||
if (!S_ISDIR (dst_sb.st_mode))
|
||||
/* Copying a directory onto a non-directory, or vice versa,
|
||||
is ok only with --backup or --exchange. */
|
||||
if (!S_ISDIR (src_mode) != !S_ISDIR (dst_sb.st_mode)
|
||||
&& x->backup_type == no_backups && !x->exchange)
|
||||
{
|
||||
if (S_ISDIR (src_mode))
|
||||
{
|
||||
if (x->move_mode && x->backup_type != no_backups)
|
||||
{
|
||||
/* Moving a directory onto an existing
|
||||
non-directory is ok only with --backup. */
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, 0,
|
||||
_("cannot overwrite non-directory %s with directory %s"),
|
||||
quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't let the user destroy their data, even if they try hard:
|
||||
This mv command must fail (likewise for cp):
|
||||
rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c
|
||||
Otherwise, the contents of b/f would be lost.
|
||||
In the case of 'cp', b/f would be lost if the user simulated
|
||||
a move using cp and rm.
|
||||
Note that it works fine if you use --backup=numbered. */
|
||||
if (command_line_arg
|
||||
&& x->backup_type != numbered_backups
|
||||
&& seen_file (x->dest_info, dst_relname, &dst_sb))
|
||||
{
|
||||
error (0, 0,
|
||||
_("will not overwrite just-created %s with %s"),
|
||||
quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
|
||||
return false;
|
||||
}
|
||||
error (0, 0,
|
||||
_(S_ISDIR (src_mode)
|
||||
? ("cannot overwrite non-directory %s "
|
||||
"with directory %s")
|
||||
: ("cannot overwrite directory %s "
|
||||
"with non-directory %s")),
|
||||
quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (src_mode))
|
||||
/* Don't let the user destroy their data, even if they try hard:
|
||||
This mv command must fail (likewise for cp):
|
||||
rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c
|
||||
Otherwise, the contents of b/f would be lost.
|
||||
In the case of 'cp', b/f would be lost if the user simulated
|
||||
a move using cp and rm.
|
||||
Nothing is lost if you use --backup=numbered or --exchange. */
|
||||
if (!S_ISDIR (dst_sb.st_mode) && command_line_arg
|
||||
&& x->backup_type != numbered_backups && !x->exchange
|
||||
&& seen_file (x->dest_info, dst_relname, &dst_sb))
|
||||
{
|
||||
if (S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
if (x->move_mode && x->backup_type != no_backups)
|
||||
{
|
||||
/* Moving a non-directory onto an existing
|
||||
directory is ok only with --backup. */
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, 0,
|
||||
_("cannot overwrite directory %s with non-directory"),
|
||||
quoteaf (dst_name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x->move_mode)
|
||||
{
|
||||
/* Don't allow user to move a directory onto a non-directory. */
|
||||
if (S_ISDIR (src_sb.st_mode) && !S_ISDIR (dst_sb.st_mode)
|
||||
&& x->backup_type == no_backups)
|
||||
{
|
||||
error (0, 0,
|
||||
_("cannot move directory onto non-directory: %s -> %s"),
|
||||
quotef_n (0, src_name), quotef_n (0, dst_name));
|
||||
return false;
|
||||
}
|
||||
error (0, 0,
|
||||
_("will not overwrite just-created %s with %s"),
|
||||
quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
char const *srcbase;
|
||||
@@ -2596,22 +2565,16 @@ skip:
|
||||
&& ! x->move_mode
|
||||
&& x->backup_type == no_backups)
|
||||
{
|
||||
bool lstat_ok = true;
|
||||
struct stat tmp_buf;
|
||||
struct stat *dst_lstat_sb;
|
||||
|
||||
/* If we did not follow symlinks above, good: use that data.
|
||||
Otherwise, use AT_SYMLINK_NOFOLLOW, in case dst_name is a symlink. */
|
||||
if (have_dst_lstat)
|
||||
dst_lstat_sb = &dst_sb;
|
||||
else if (fstatat (dst_dirfd, drelname, &tmp_buf, AT_SYMLINK_NOFOLLOW)
|
||||
== 0)
|
||||
dst_lstat_sb = &tmp_buf;
|
||||
else
|
||||
lstat_ok = false;
|
||||
struct stat tmp_buf;
|
||||
struct stat *dst_lstat_sb
|
||||
= (have_dst_lstat ? &dst_sb
|
||||
: fstatat (dst_dirfd, drelname, &tmp_buf, AT_SYMLINK_NOFOLLOW) < 0
|
||||
? nullptr : &tmp_buf);
|
||||
|
||||
/* Never copy through a symlink we've just created. */
|
||||
if (lstat_ok
|
||||
if (dst_lstat_sb
|
||||
&& S_ISLNK (dst_lstat_sb->st_mode)
|
||||
&& seen_file (x->dest_info, dst_relname, dst_lstat_sb))
|
||||
{
|
||||
@@ -2627,7 +2590,7 @@ skip:
|
||||
sure we'll create a directory. Also don't announce yet when moving
|
||||
so we can distinguish renames versus copies. */
|
||||
if (x->verbose && !x->move_mode && !S_ISDIR (src_mode))
|
||||
emit_verbose (src_name, dst_name, dst_backup);
|
||||
emit_verbose ("%s -> %s", src_name, dst_name, dst_backup);
|
||||
|
||||
/* Associate the destination file name with the source device and inode
|
||||
so that if we encounter a matching dev/ino pair in the source tree
|
||||
@@ -2659,7 +2622,7 @@ skip:
|
||||
Also, with --recursive, record dev/ino of each command-line directory.
|
||||
We'll use that info to detect this problem: cp -R dir dir. */
|
||||
|
||||
if (rename_errno == 0)
|
||||
if (rename_errno == 0 || x->exchange)
|
||||
earlier_file = nullptr;
|
||||
else if (x->recursive && S_ISDIR (src_mode))
|
||||
{
|
||||
@@ -2755,16 +2718,18 @@ skip:
|
||||
if (x->move_mode)
|
||||
{
|
||||
if (rename_errno == EEXIST)
|
||||
rename_errno = (renameat (AT_FDCWD, src_name, dst_dirfd, drelname) == 0
|
||||
rename_errno = ((renameatu (AT_FDCWD, src_name, dst_dirfd, drelname,
|
||||
x->exchange ? RENAME_EXCHANGE : 0)
|
||||
== 0)
|
||||
? 0 : errno);
|
||||
|
||||
if (rename_errno == 0)
|
||||
{
|
||||
if (x->verbose)
|
||||
{
|
||||
printf (_("renamed "));
|
||||
emit_verbose (src_name, dst_name, dst_backup);
|
||||
}
|
||||
emit_verbose (x->exchange
|
||||
? _("exchanged %s <-> %s")
|
||||
: _("renamed %s -> %s"),
|
||||
src_name, dst_name, dst_backup);
|
||||
|
||||
if (x->set_security_context)
|
||||
{
|
||||
@@ -2783,7 +2748,7 @@ skip:
|
||||
_destination_ dev/ino, since the rename above can't have
|
||||
changed those, and 'mv' always uses lstat.
|
||||
We could limit it further by operating
|
||||
only on non-directories. */
|
||||
only on non-directories when !x->exchange. */
|
||||
record_file (x->dest_info, dst_relname, &src_sb);
|
||||
}
|
||||
|
||||
@@ -2830,7 +2795,7 @@ skip:
|
||||
where you'd replace '18' with the integer in parentheses that
|
||||
was output from the perl one-liner above.
|
||||
If necessary, of course, change '/tmp' to some other directory. */
|
||||
if (rename_errno != EXDEV || x->no_copy)
|
||||
if (rename_errno != EXDEV || x->no_copy || x->exchange)
|
||||
{
|
||||
/* There are many ways this can happen due to a race condition.
|
||||
When something happens between the initial follow_fstatat and the
|
||||
@@ -2843,25 +2808,29 @@ skip:
|
||||
destination file are made too restrictive, the rename will
|
||||
fail. Etc. */
|
||||
char const *quoted_dst_name = quoteaf_n (1, dst_name);
|
||||
switch (rename_errno)
|
||||
{
|
||||
case EDQUOT: case EEXIST: case EISDIR: case EMLINK:
|
||||
case ENOSPC: case ETXTBSY:
|
||||
if (x->exchange)
|
||||
error (0, rename_errno, _("cannot exchange %s and %s"),
|
||||
quoteaf_n (0, src_name), quoted_dst_name);
|
||||
else
|
||||
switch (rename_errno)
|
||||
{
|
||||
case EDQUOT: case EEXIST: case EISDIR: case EMLINK:
|
||||
case ENOSPC: case ETXTBSY:
|
||||
#if ENOTEMPTY != EEXIST
|
||||
case ENOTEMPTY:
|
||||
case ENOTEMPTY:
|
||||
#endif
|
||||
/* The destination must be the problem. Don't mention
|
||||
the source as that is more likely to confuse the user
|
||||
than be helpful. */
|
||||
error (0, rename_errno, _("cannot overwrite %s"),
|
||||
quoted_dst_name);
|
||||
break;
|
||||
/* The destination must be the problem. Don't mention
|
||||
the source as that is more likely to confuse the user
|
||||
than be helpful. */
|
||||
error (0, rename_errno, _("cannot overwrite %s"),
|
||||
quoted_dst_name);
|
||||
break;
|
||||
|
||||
default:
|
||||
error (0, rename_errno, _("cannot move %s to %s"),
|
||||
quoteaf_n (0, src_name), quoted_dst_name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
error (0, rename_errno, _("cannot move %s to %s"),
|
||||
quoteaf_n (0, src_name), quoted_dst_name);
|
||||
break;
|
||||
}
|
||||
forget_created (src_sb.st_ino, src_sb.st_dev);
|
||||
return false;
|
||||
}
|
||||
@@ -2885,10 +2854,7 @@ skip:
|
||||
}
|
||||
|
||||
if (x->verbose && !S_ISDIR (src_mode))
|
||||
{
|
||||
printf (_("copied "));
|
||||
emit_verbose (src_name, dst_name, dst_backup);
|
||||
}
|
||||
emit_verbose (_("copied %s -> %s"), src_name, dst_name, dst_backup);
|
||||
new_dst = true;
|
||||
}
|
||||
|
||||
@@ -2988,7 +2954,7 @@ skip:
|
||||
if (x->move_mode)
|
||||
printf (_("created directory %s\n"), quoteaf (dst_name));
|
||||
else
|
||||
emit_verbose (src_name, dst_name, nullptr);
|
||||
emit_verbose ("%s -> %s", src_name, dst_name, nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3044,7 +3010,7 @@ skip:
|
||||
|| stat (".", &dot_sb) != 0
|
||||
|| (fstatat (dst_dirfd, dst_parent, &dst_parent_sb,
|
||||
0) != 0)
|
||||
|| SAME_INODE (dot_sb, dst_parent_sb));
|
||||
|| psame_inode (&dot_sb, &dst_parent_sb));
|
||||
free (dst_parent);
|
||||
|
||||
if (! in_current_dir)
|
||||
@@ -3302,6 +3268,9 @@ skip:
|
||||
{
|
||||
int default_permissions = S_ISDIR (src_mode) || S_ISSOCK (src_mode)
|
||||
? S_IRWXUGO : MODE_RW_UGO;
|
||||
dst_mode = dst_sb.st_mode;
|
||||
if (S_ISDIR (src_mode)) /* Keep set-group-ID for directories. */
|
||||
default_permissions |= (dst_mode & S_ISGID);
|
||||
if (set_acl (dst_name, -1, default_permissions & ~cached_umask ()) != 0)
|
||||
return false;
|
||||
}
|
||||
@@ -3458,9 +3427,16 @@ chown_failure_ok (struct cp_options const *x)
|
||||
{
|
||||
/* If non-root uses -p, it's ok if we can't preserve ownership.
|
||||
But root probably wants to know, e.g. if NFS disallows it,
|
||||
or if the target system doesn't support file ownership. */
|
||||
or if the target system doesn't support file ownership.
|
||||
|
||||
return ((errno == EPERM || errno == EINVAL) && !x->chown_privileges);
|
||||
Treat EACCES like EPERM and EINVAL to work around a bug in Linux
|
||||
CIFS <https://bugs.gnu.org/65599>. Although this means coreutils
|
||||
will ignore EACCES errors that it should report, problems should
|
||||
occur only when some other process is racing with coreutils and
|
||||
coreutils is not immune to races anyway. */
|
||||
|
||||
return ((errno == EPERM || errno == EINVAL || errno == EACCES)
|
||||
&& !x->chown_privileges);
|
||||
}
|
||||
|
||||
/* Similarly, return true if it's OK for chmod and similar operations
|
||||
@@ -3470,7 +3446,8 @@ chown_failure_ok (struct cp_options const *x)
|
||||
static bool
|
||||
owner_failure_ok (struct cp_options const *x)
|
||||
{
|
||||
return ((errno == EPERM || errno == EINVAL) && !x->owner_privileges);
|
||||
return ((errno == EPERM || errno == EINVAL || errno == EACCES)
|
||||
&& !x->owner_privileges);
|
||||
}
|
||||
|
||||
/* Return the user's umask, caching the result.
|
||||
|
||||
25
src/copy.h
25
src/copy.h
@@ -1,5 +1,5 @@
|
||||
/* core functions for copying files and directories
|
||||
Copyright (C) 1989-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -68,6 +68,9 @@ enum Update_type
|
||||
|
||||
/* Leave existing files. */
|
||||
UPDATE_NONE,
|
||||
|
||||
/* Leave existing files, but exit failure if existing files. */
|
||||
UPDATE_NONE_FAIL,
|
||||
};
|
||||
|
||||
/* This type is used to help mv (via copy.c) distinguish these cases. */
|
||||
@@ -129,8 +132,8 @@ struct cp_options
|
||||
if SET_MODE is nonzero. */
|
||||
mode_t mode;
|
||||
|
||||
/* If true, copy all files except (directories and, if not dereferencing
|
||||
them, symbolic links,) as if they were regular files. */
|
||||
/* If true, copy all files except directories (and, if not dereferencing
|
||||
them, symbolic links) as if they were regular files. */
|
||||
bool copy_as_regular;
|
||||
|
||||
/* If true, remove each existing destination nondirectory before
|
||||
@@ -152,6 +155,10 @@ struct cp_options
|
||||
If that fails and NO_COPY, fail instead of copying. */
|
||||
bool move_mode, no_copy;
|
||||
|
||||
/* Exchange instead of renaming. Valid only if MOVE_MODE and if
|
||||
BACKUP_TYPE == no_backups. */
|
||||
bool exchange;
|
||||
|
||||
/* If true, install(1) is the caller. */
|
||||
bool install_mode;
|
||||
|
||||
@@ -256,6 +263,9 @@ struct cp_options
|
||||
/* If true, display the names of the files before copying them. */
|
||||
bool verbose;
|
||||
|
||||
/* If true, follow existing symlinks to directories when copying. */
|
||||
bool keep_directory_symlink;
|
||||
|
||||
/* If true, display details of how files were copied. */
|
||||
bool debug;
|
||||
|
||||
@@ -294,15 +304,6 @@ struct cp_options
|
||||
Hash_table *src_info;
|
||||
};
|
||||
|
||||
/* Arrange to make rename calls go through the wrapper function
|
||||
on systems with a rename function that fails for a source file name
|
||||
specified with a trailing slash. */
|
||||
# if RENAME_TRAILING_SLASH_BUG
|
||||
int rpl_rename (char const *, char const *);
|
||||
# undef rename
|
||||
# define rename rpl_rename
|
||||
# endif
|
||||
|
||||
bool copy (char const *src_name, char const *dst_name,
|
||||
int dst_dirfd, char const *dst_relname,
|
||||
int nonexistent_dst, const struct cp_options *options,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user