blob: fa9855cadac48309bd39609204b035e97ad7dbe2 (
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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#exec newfs -G "$@"
myname=`basename $0`
USAGE="usage: $myname [ -M mount-point ] [ newfs-options ] raw-special-device"
if [ ! "$UFS_MKFS" ]; then
UFS_MKFS="/usr/lib/fs/ufs/mkfs"
fi
verbose=""
mkfs_opts="-G"
mkfs_subopts=""
size=""
newsize=0
mount_pt=
UFS_MKFS_NOTENOUGHSPACE=33
add_opt() {
mkfs_opts="$mkfs_opts $1"
}
add_subopt() {
if [ ! "$mkfs_subopts" ]; then
mkfs_subopts="-o $1"
else
mkfs_subopts="$mkfs_subopts,$1"
fi
}
while getopts "GM:Nva:b:c:d:f:i:m:n:o:r:s:t:C:" c ; do
save=$OPTIND
case $c in
G) ;;
M) add_opt "-M $OPTARG"; mount_pt="$OPTARG" ;;
N) add_subopt "N" ;;
v) verbose="1" ;;
a) add_subopt "apc=$OPTARG" ;;
b) add_subopt "bsize=$OPTARG" ;;
c) add_subopt "cgsize=$OPTARG" ;;
d) add_subopt "gap=$OPTARG" ;;
f) add_subopt "fragsize=$OPTARG" ;;
i) add_subopt "nbpi=$OPTARG" ;;
m) add_subopt "free=$OPTARG" ;;
n) add_subopt "nrpos=$OPTARG" ;;
o) add_subopt "opt=$OPTARG" ;;
r) add_subopt "rps=`expr $OPTARG / 60`" ;;
s) size=$OPTARG ;;
t) add_subopt "ntrack=$OPTARG" ;;
C) add_subopt "maxcontig=$OPTARG" ;;
\?) echo $USAGE; exit 1 ;;
esac
OPTIND=$save
done
shift `expr $OPTIND - 1`
if [ $# -ne 1 ]; then
echo $USAGE
exit 1
fi
raw_special=$1
if [ ! "$size" ]; then
size=`devinfo -p $raw_special | awk '{ print $5 }'`
if [ $? -ne 0 -o ! "$size" ]; then
echo "$myname: cannot get partition size"
exit 2
fi
fi
cmd="$UFS_MKFS $mkfs_opts $mkfs_subopts $raw_special $size"
if [ -n "$verbose" ]; then
echo $cmd
fi
$cmd; retv=$?
if [ $retv -eq $UFS_MKFS_NOTENOUGHSPACE ]; then
echo "Growing filesystem in increments due to limited available space."
while [ "$newsize" -lt "$size" ]; do
cmd="$UFS_MKFS $mkfs_opts $mkfs_subopts -P $raw_special $size"
if [ -n "$verbose" ]; then
echo $cmd
fi
newsize=`$cmd`; retv=$?
if [ 0 -ne $retv -o -z "$newsize" ]; then
echo "$myname: cannot probe the possible file system size"
exit 2
fi
if [ 0 -eq "$newsize" ]; then
echo "$myname: the file system is full and cannot be grown, please delete some files"
exit 2
fi
cmd="$UFS_MKFS $mkfs_opts $mkfs_subopts $raw_special $newsize"; retv=$?
if [ -n "$verbose" ]; then
echo $cmd
fi
$cmd; retv=$?
if [ 0 -ne $retv ]; then
echo "$myname: cannot grow file system to $newsize sectors"
exit $retv
fi
done
echo \
"\nThe incremental grow has successfully completed, but since the first growth \
attempt failed (see output from first mkfs(8) run), the filesystem is still \
locked and needs to be checked with fsck(8).\n\
Please run \`fsck -F ufs $raw_special' and then unlock the filesystem \
with \`lockfs -u $mount_pt'." | fmt;
fi
exit $retv
|