Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / mkdir / writable-under-readonly
1 #!/bin/sh
2 # This is just for the record.
3 # This test is not run.
4
5 # Copyright (C) 2005 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 # Test for the 2005-10-13 patch to lib/mkdir-p.c that fixed this sort
23 # of bug in mkdir:
24 #
25 #   "mkdir -p /a/b/c" no longer fails merely because a leading prefix
26 #   directory (e.g., /a or /a/b) exists on a read-only file system.
27 #
28 # Demonstrate the problem, as root:
29
30 mount='sudo mount'
31
32 cd /tmp                                    \
33   && dd if=/dev/zero of=1 bs=8192 count=50 \
34   && dd if=/dev/zero of=2 bs=8192 count=50 \
35   && mkdir -p mnt-ro && mkfs -t ext2 1 && mkfs -t ext2 2 \
36   && $mount -o loop=/dev/loop3 1 mnt-ro    \
37   && mkdir -p mnt-ro/rw                    \
38   && $mount -o remount,ro mnt-ro           \
39   && $mount -o loop=/dev/loop4 2 mnt-ro/rw
40
41 mkdir -p mnt-ro/rw/sub || fail=1
42
43 # To clean up
44 umount /tmp/2
45 umount /tmp/1
46 rm -rf /tmp/[12]