du01: create the temp file outside of the working directory

I noticed that with older kernels and with XFS the 'du -B 512'
scenario of this test case may fail:

[root@kholmanskikh du01]# uname -r
3.8.13-98.2.2.el6uek.x86_64
[root@kholmanskikh du01]# ls -l
total 10240
drwxr-xr-x 2 root root       24 Jul 25 14:48 testdir
-rw-r--r-- 1 root root 10485760 Jul 25 14:48 testfile
[root@kholmanskikh du01]# du -B 512
0		   ./testdir
20480		   .
[root@kholmanskikh du01]# du -B 512 > temp; cat temp
0		   ./testdir
20608		   .
[root@kholmanskikh du01]#

This happens because we create 'temp' file in the working directory,
i.e. 'temp' may already contain some data at the moment 'du' tries
to 'fstat' it.

So let's keep the working directory clean and create any extra
files outside of it.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
1 file changed