-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1648 from EliahKagan/run-ci/touch-next
Make `touch` logic in `file_metadata.sh` more portable
- Loading branch information
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
# Attempt to create files with the latest and earliest possible dates for ext4. Nanoseconds are | ||
# special there, but not usually on other filesystems. In some touch implementations, the format | ||
# may be rejected. So if a command fails, we try again with a more extreme date that is out of | ||
# range, because some implementations will clip it to the edge of the range (but they may fail). | ||
touch -d '2446-05-10 22:38:55.111111111' future || touch -d '2446-05-11 22:38:56' future | ||
touch -d '1901-12-13 20:45:52.222222222' past || touch -d '1901-12-13 20:45:52' past | ||
# Attempt to create files with the latest and earliest possible 64-bit dates/times for ext4. | ||
# Although nanoseconds are stored in ext4, specifying fractions of a second does not seem to make | ||
# this work better, and omitting them allows the commands that attempt to set these dates to | ||
# succeed on more systems. While we use a portable format, if the system rejects a future date as | ||
# out of range with an error (and touch does not automatically retry with an allowed date) then it | ||
# can fail. In this case, we try again with a much more moderate date: the greatest value that can | ||
# in practice always parse to fit within a 32-bit signed time_t. This is subject to change to | ||
# support changed or new tests. It will also become less useful in the near future (after 2038). | ||
TZ=UTC touch -d '2446-05-10 22:38:55' future || TZ=UTC touch -d '2038-01-19 03:14:07' future | ||
TZ=UTC touch -d '1901-12-13 20:45:52' past |