1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
# Probe Ext2, Ext3 and Ext4 file systems
# Copyright (C) 2008-2014, 2019-2022 Free Software Foundation, Inc.
# 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 3 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, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_512_byte_sector_size_
dev=loop-file
ss=$sector_size_
n_sectors=$((512*1024))
for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus udf f2fs; do
( mkfs.$type 2>&1 | grep -i '^usage' ) > /dev/null \
|| { warn_ "$ME: no $type support"; continue; }
fsname=$type
force=
case $type in
ext*) force=-F;;
xfs) force=-f;;
nilfs2) force=-f;;
ntfs) force=-F;;
vfat) fsname=fat16;;
hfsplus) fsname=hfs+;;
esac
# create an $type file system, creation failures are not parted bugs,
# skip the filesystem instead of failing the test.
if [ "$type" = "xfs" ]; then
# XFS requires at least 300M which is > 1024 sectors with 8192b sector size
mkfs.xfs -ssize=$ss -dfile,name=$dev,size=300m || { warn_ "$ME: mkfs.$type failed, skipping"; continue; }
else
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || { warn_ "$ME: dd failed, skipping $type"; continue; }
mkfs.$type $force $dev || { warn_ "$ME: mkfs.$type failed skipping"; continue; }
fi
# probe the $type file system
parted -m -s $dev u s print >out 2>&1 || fail=1
grep '^1:.*:'$fsname'::;$' out || { cat out; fail=1; }
rm $dev
done
# Some features should indicate ext4 by themselves.
for feature in uninit_bg flex_bg; do
# create an ext3 file system
dd if=/dev/null of=$dev bs=1024 seek=8192 >/dev/null || skip_ "dd failed"
mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
# set the feature
tune2fs -O $feature $dev || skip_ "tune2fs failed"
# probe the file system, which should now be ext4
parted -m -s $dev u s print >out 2>&1 || fail=1
grep '^1:.*:ext4::;$' out || fail=1
rm $dev
done
Exit $fail
|