2000-11-07 05:52:12 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# make sure mkdir's -p options works properly
|
|
|
|
|
2006-10-23 01:37:31 +08:00
|
|
|
# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc.
|
2006-08-18 03:58:17 +08:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
# 02110-1301, USA.
|
|
|
|
|
2000-11-07 05:52:12 +08:00
|
|
|
if test "$VERBOSE" = yes; then
|
|
|
|
set -x
|
|
|
|
mkdir --version
|
|
|
|
fi
|
|
|
|
|
|
|
|
pwd=`pwd`
|
|
|
|
tmp=parents-$$
|
2006-10-23 01:37:31 +08:00
|
|
|
trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
|
2000-11-07 05:52:12 +08:00
|
|
|
trap '(exit $?); exit' 1 2 13 15
|
|
|
|
|
|
|
|
framework_failure=0
|
|
|
|
|
|
|
|
# Record absolute path of srcdir.
|
|
|
|
cd $srcdir || framework_failure=1
|
|
|
|
abs_srcdir=`pwd`
|
|
|
|
|
2006-10-23 01:37:31 +08:00
|
|
|
cd "$pwd" || framework_failure=1
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir $tmp || framework_failure=1
|
|
|
|
cd $tmp || framework_failure=1
|
2000-11-10 06:22:41 +08:00
|
|
|
mkdir -m 700 e-dir || framework_failure=1
|
2000-11-07 05:52:12 +08:00
|
|
|
|
|
|
|
if test $framework_failure = 1; then
|
|
|
|
echo 'failure in testing framework'
|
2004-06-23 23:07:00 +08:00
|
|
|
(exit 1); exit 1
|
2000-11-07 05:52:12 +08:00
|
|
|
fi
|
|
|
|
|
2006-10-23 04:12:13 +08:00
|
|
|
. "$abs_srcdir"/../setgid-check
|
2000-11-07 05:52:12 +08:00
|
|
|
|
2000-11-23 22:59:05 +08:00
|
|
|
fail=0
|
2000-11-10 06:22:41 +08:00
|
|
|
|
2000-11-07 05:52:12 +08:00
|
|
|
# Make sure `mkdir -p existing-dir' succeeds
|
|
|
|
# and that `mkdir existing-dir' fails.
|
|
|
|
mkdir -p e-dir || fail=1
|
|
|
|
mkdir e-dir > /dev/null 2>&1 && fail=1
|
|
|
|
|
2000-11-07 05:53:08 +08:00
|
|
|
# Create an existing directory.
|
2000-11-07 05:52:12 +08:00
|
|
|
umask 077
|
|
|
|
mode_str=drwxr-x-wx
|
2006-10-23 04:12:13 +08:00
|
|
|
mode_arg=`"$abs_srcdir"/../rwx-to-mode $mode_str`
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir -m $mode_arg a || fail=1
|
|
|
|
|
2000-11-07 05:53:08 +08:00
|
|
|
# this `mkdir -p ...' shouldn't change perms of existing dir `a'.
|
2000-11-07 05:52:12 +08:00
|
|
|
d_mode_str=drwx-w--wx
|
2006-10-23 04:12:13 +08:00
|
|
|
d_mode_arg=`"$abs_srcdir"/../rwx-to-mode $d_mode_str`
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir -p -m $d_mode_arg a/b/c/d
|
|
|
|
|
|
|
|
# Make sure the permissions of `a' haven't been changed.
|
|
|
|
p=`ls -ld a|sed 's/ .*//'`; case $p in $mode_str);; *) fail=1;; esac
|
|
|
|
# `b's and `c's should reflect the umask
|
|
|
|
p=`ls -ld a/b|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
|
|
|
|
p=`ls -ld a/b/c|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
|
|
|
|
|
|
|
|
# `d's perms are determined by the -m argument.
|
|
|
|
p=`ls -ld a/b/c/d|sed 's/ .*//'`; case $p in $d_mode_str);; *) fail=1;; esac
|
|
|
|
|
2004-06-23 23:07:00 +08:00
|
|
|
(exit $fail); exit $fail
|