OSDN Git Service

maint: remove now-unused fat-related functions
[android-x86/external-parted.git] / tests / t2310-dos-extended-2-sector-min-offset.sh
1 #!/bin/sh
2 # Ensure that parted leaves at least 2 sectors between the beginning
3 # of an extended partition and the first logical partition.
4 # Before parted-2.3, it could be made to leave just one, and that
5 # would cause trouble with the Linux kernel.
6
7 # Copyright (C) 2010-2012 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 3 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, see <http://www.gnu.org/licenses/>.
21
22 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
23
24 require_root_
25 require_scsi_debug_module_
26
27 # create memory-backed device
28 scsi_debug_setup_ dev_size_mb=1 > dev-name ||
29   skip_ 'failed to create scsi_debug device'
30 scsi_dev=$(cat dev-name)
31 p1=${scsi_dev}1
32 p5=${scsi_dev}5
33
34 cat <<EOF > exp || framework_failure
35 BYT;
36 $scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
37 1:64s:128s:65s:::lba;
38 5:66s:128s:63s:::;
39 EOF
40
41 cat <<EOF > err.exp || framework_failure
42 Error: Error informing the kernel about modifications to partition $p5 -- Device or resource busy.  This means Linux won't know about any changes you made to $p5 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
43 Error: Failed to add partition 5 (Device or resource busy)
44 EOF
45
46 # Create a DOS label with an extended partition starting at sector 64.
47 parted -s $scsi_dev mklabel msdos || fail=1
48 parted --align=min -s $scsi_dev mkpart extended 64s 128s> out 2>&1 || fail=1
49 parted -m -s $scsi_dev u s print
50 compare /dev/null out || fail=1
51
52 # Provoke a failure by trying to create a partition that starts just
53 # one sector after the start of the extended partition.
54 parted --align=min -s $scsi_dev mkpart logical 65s 128s > err 2>&1 && fail=1
55 compare err.exp err || fail=1
56
57 # The above failed, but created the partition nonetheless.  Remove it.
58 parted -s $scsi_dev rm 5 || fail=1
59
60 parted --align=min -s $scsi_dev mkpart logical 66s 128s > out 2>&1 || fail=1
61 compare /dev/null out || fail=1
62
63 parted -m -s $scsi_dev u s print > out 2>&1
64 compare exp out || fail=1
65
66 Exit $fail