Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --open-noatime option not working on files #726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ int do_open_nofollow(const char *pathname, int flags)
#endif
}

#ifdef O_NOATIME
if (open_noatime)
flags |= O_NOATIME;
#endif

#ifdef O_NOFOLLOW
fd = open(pathname, flags|O_NOFOLLOW);
#else
Expand Down
26 changes: 26 additions & 0 deletions testsuite/open-noatime.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# Test rsync --open-noatime option keeps source atimes intact

. "$suitedir/rsync.fns"

$RSYNC -VV | grep '"atimes": true' >/dev/null || test_skipped "Rsync is configured without atimes support"

mkdir "$fromdir"

# --open-noatime did not work properly on files with size > 0
echo content > "$fromdir/foo"
touch -a -t 200102031717.42 "$fromdir/foo"

TLS_ARGS=--atimes

"$TOOLDIR/tls" $TLS_ARGS "$fromdir/foo" > "$tmpdir/atime-from-before"

# Do not use checkit because it uses "diff" which breaks atimes
$RSYNC --open-noatime --archive --recursive --times --atimes -vvv "$fromdir/" "$todir/"

"$TOOLDIR/tls" $TLS_ARGS "$fromdir/foo" > "$tmpdir/atime-from-after"
diff "$tmpdir/atime-from-before" "$tmpdir/atime-from-after"

# The script would have aborted on error, so getting here means we've won.
exit 0