2
# Probe Ext2, Ext3 and Ext4 file systems
4
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
20
require_512_byte_sector_size_
25
for type in ext2 ext3 ext4 nilfs2; do
27
( mkfs.$type -V ) >/dev/null 2>&1 \
28
|| { warn_ "$ME: no $type support"; continue; }
30
case $type in ext*) n_sectors=8000 force=-F;;
31
*) n_sectors=$((257*1024)) force=;; esac
33
# create an $type file system
34
dd if=/dev/zero of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
35
mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; }
37
# probe the $type file system
38
parted -m -s $dev u s print >out 2>&1 || fail=1
39
grep '^1:.*:'$type'::;$' out || { cat out; fail=1; }
43
# Some features should indicate ext4 by themselves.
44
for feature in uninit_bg flex_bg; do
45
# create an ext3 file system
46
dd if=/dev/zero of=$dev bs=1024 count=4096 >/dev/null || fail=1
47
mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
50
tune2fs -O $feature $dev || skip_ "tune2fs failed"
52
# probe the file system, which should now be ext4
53
parted -m -s $dev u s print >out 2>&1 || fail=1
54
grep '^1:.*:ext4::;$' out || fail=1