Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / other-fs-tmpdir
1 #! /bin/sh
2
3 # Use stat to find a writable directory on a file system different from that
4 # of the current directory.  If one is found, create a temporary directory
5 # inside it.
6
7 # Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23
24 test "${CANDIDATE_TMP_DIRS+set}" = set \
25   || CANDIDATE_TMP_DIRS="$TMPDIR /tmp /var/tmp /usr/tmp $HOME"
26
27 other_partition_tmpdir=
28
29 dot_mount_point=`stat -c %d .`
30 for d in $CANDIDATE_TMP_DIRS; do
31
32   # Skip nonexistent directories.
33   test -d $d || continue
34
35   d_mount_point=`stat -L -c %d $d`
36
37   # Same partition?  Skip it.
38   test x$d_mount_point = x$dot_mount_point && continue
39
40   # See if we can create a directory in it.
41   if mkdir "$d/tmp$$" > /dev/null 2>&1; then
42     other_partition_tmpdir="$d/tmp$$"
43     break
44   fi
45
46 done
47
48 if test -z "$other_partition_tmpdir"; then
49   cat <<EOF 1>&2
50 **************************************
51 This test requires a writable directory on a different
52 disk partition, and I couldn't find one.  I tried these:
53   $CANDIDATE_TMP_DIRS
54 Set your environment variable CANDIDATE_TMP_DIRS to make
55 this test use a different list.
56 **************************************
57 EOF
58     #'
59 fi
60
61 test "$VERBOSE" = yes && set -x