15dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes#!/bin/sh
25dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
35dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes# Check how ftruncate, lseek and stat family syscalls are traced.
45dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
55dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes. "${srcdir=.}/init.sh"
65dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
75dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughescheck_prog dd
85dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughescheck_prog find
95dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughescheck_prog grep
105dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughescheck_prog rm
115dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
125dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughesumask 022
135dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughestruncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
145dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes$truncate_cmd > $LOG 2>&1 ||
155dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes	{ cat $LOG; framework_skip_ 'failed to create a large sparse file'; }
165dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughesrm -f sample
175dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
185dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes$STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> $LOG &&
195dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott HughesLC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' $LOG > /dev/null ||
205dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes	{ cat $LOG; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
215dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
225dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott HughesLC_ALL=C grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' $LOG > /dev/null ||
235dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes	{ cat $LOG; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
245dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
255dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes$STRACE -efile find -L sample > /dev/null 2> $LOG &&
265dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott HughesLC_ALL=C grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' $LOG > /dev/null ||
275dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes	{ cat $LOG; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
285dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
295dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes$STRACE -efile find sample > /dev/null 2> $LOG &&
305dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott HughesLC_ALL=C grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' $LOG > /dev/null ||
315dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes	{ cat $LOG; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
325dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
335dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughesrm -f sample
345dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughes
355dec78d0c2663930cd1bbcecbbcee47f68bc52f3Elliott Hughesexit 0
36