aboutsummaryrefslogtreecommitdiff
blob: 731c7d1ac0c0e5c82ec56f62219ffc76f19650d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# make sure we don't accidentally trip atime updates on files
# through symlinks #415475
[ "${at_xfail}" = "yes" ] && exit 77 # see script-0

# We assume $PWD supports atimes, and the granularity is more than 1 second.
# If it doesn't, this test will still pass, but not really because the code
# was proven to be correct.

# XXX: Maybe we need to add our own stat shim to avoid portability issues ?
get_atime() {
	# This shows the full atime field (secs, msecs, nsecs).
	stat -c %x "$1"
}

# Create a symlink.
sym="sym"
ln -s atime "${sym}"

# Get the state before we test it.
before=$(get_atime "${sym}")

# A quick sleep of a few msecs.
sleep 0.1

# See if the atime changes -- it should not.
utimensat-0 -1,EINVAL AT_FDCWD "${sym}" -1,-1 AT_SYMLINK_NOFOLLOW || exit 1
after=$(get_atime "${sym}")

[ "${after}" = "${before}" ]