summaryrefslogtreecommitdiff
path: root/tests/t1700-probe-fs.sh
blob: 2ba2f95c8ebb20cad64e236547be1760d3f39bb4 (plain)
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
#!/bin/sh
# Probe Ext2, Ext3 and Ext4 file systems

# Copyright (C) 2008-2013 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=$((257*1024))

for type in ext2 ext3 ext4 btrfs xfs nilfs2; do

  ( mkfs.$type -V ) >/dev/null 2>&1 \
      || { warn_ "$ME: no $type support"; continue; }

  case $type in ext*) force=-F;;
      xfs) force=-f;;
      *) force=;; esac

  # create an $type file system
  dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || fail=1
  mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; }

  # probe the $type file system
  parted -m -s $dev u s print >out 2>&1 || fail=1
  grep '^1:.*:'$type'::;$' 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=4096 >/dev/null || fail=1
  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
done

Exit $fail