/
repit-fs-vfat.sh
101 lines (78 loc) · 2.46 KB
/
repit-fs-vfat.sh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#####################################################
# Lanchon REPIT - File System Handler #
# Copyright 2016, Lanchon #
#####################################################
#####################################################
# Lanchon REPIT is free software licensed under #
# the GNU General Public License (GPL) version 3 #
# and any later version. #
#####################################################
### vfat
checkTools_fs_vfat() {
# only require tools if actually needed
#mkfs_vfat=$(chooseTool mkdosfs mkfs.fat)
#fsck_vfat=$(chooseTool dosfsck fsck.fat)
:
}
processPar_vfat_wipe_dry() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
info "will format the partition in vfat"
mkfs_vfat=$(chooseTool mkdosfs mkfs.fat)
}
processPar_vfat_wipe_wet() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
processParRecreate $n $oldStart $oldSize $newStart $newSize
info "formatting the partition in vfat"
$mkfs_vfat -I $dev
}
checkFs_vfat() {
local n=$1
local dev=$2
info "checking the file system"
# the -w flag is used here to bound memory use
if ! $fsck_vfat -pw $dev; then
info "errors detected, retrying the file system check"
if ! $fsck_vfat -pw $dev; then
fatal "file system errors in $(parName $n) could not be fixed"
fi
fi
}
processPar_vfat_keep_dry() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then
info "will move/resize the vfat partition"
fi
fsck_vfat=$(chooseTool dosfsck fsck.fat)
checkFs_vfat $@
}
processPar_vfat_keep_wet() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
if [ $(( newStart != oldStart || newSize != oldSize )) -ne 0 ]; then
info "moving/resizing the vfat partition"
info "note that the error 'unable to satisfy all constraints on the partition' usually means "\
"that the new desired partition size would be too small to hold the files already stored in the partition."
runParted resize $n $newStart $(( newStart + newSize - 1 ))
rereadParTable
checkFs_vfat $@
fi
}