#!/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 "$@" setvar myname = $(basename $0) setvar USAGE = ""usage: $myname [ -M mount-point ] [ newfs-options ] raw-special-device"" if test ! $UFS_MKFS { setvar UFS_MKFS = ""/usr/lib/fs/ufs/mkfs"" } setvar verbose = """" setvar mkfs_opts = ""-G"" setvar mkfs_subopts = """" setvar size = """" setvar newsize = '0' setvar mount_pt = '' setvar UFS_MKFS_NOTENOUGHSPACE = '33' proc add_opt { setvar mkfs_opts = ""$mkfs_opts $1"" } proc add_subopt { if test ! $mkfs_subopts { setvar mkfs_subopts = ""-o $1"" } else { setvar mkfs_subopts = ""$mkfs_subopts,$1"" } } while getopts "GM:Nva:b:c:d:f:i:m:n:o:r:s:t:C:" c { setvar save = "$OPTIND" match $c { with G with M add_opt "-M $OPTARG"; setvar mount_pt = "$OPTARG" with N add_subopt "N" with v setvar verbose = ""1"" with a add_subopt "apc=$OPTARG" with b add_subopt "bsize=$OPTARG" with c add_subopt "cgsize=$OPTARG" with d add_subopt "gap=$OPTARG" with f add_subopt "fragsize=$OPTARG" with i add_subopt "nbpi=$OPTARG" with m add_subopt "free=$OPTARG" with n add_subopt "nrpos=$OPTARG" with o add_subopt "opt=$OPTARG" with r add_subopt "rps=$(expr $OPTARG / 60)" with s setvar size = "$OPTARG" with t add_subopt "ntrack=$OPTARG" with C add_subopt "maxcontig=$OPTARG" with \? echo $USAGE; exit 1 } setvar OPTIND = "$save" } shift $(expr $OPTIND - 1) if test $Argc -ne 1 { echo $USAGE exit 1 } setvar raw_special = "$1" if test ! $size { setvar size = $(devinfo -p $raw_special | awk '{ print $5 }) if test $Status -ne 0 -o ! $size { echo "$myname: cannot get partition size" exit 2 } } setvar cmd = ""$UFS_MKFS $mkfs_opts $mkfs_subopts $raw_special $size"" if test -n $verbose { echo $cmd } $cmd; setvar retv = "$Status" if test $retv -eq $UFS_MKFS_NOTENOUGHSPACE { echo "Growing filesystem in increments due to limited available space." while test $newsize -lt $size { setvar cmd = ""$UFS_MKFS $mkfs_opts $mkfs_subopts -P $raw_special $size"" if test -n $verbose { echo $cmd } setvar newsize = $($cmd); setvar retv = "$Status" if test 0 -ne $retv -o -z $newsize { echo "$myname: cannot probe the possible file system size" exit 2 } if test 0 -eq $newsize { echo "$myname: the file system is full and cannot be grown, please delete some files" exit 2 } setvar cmd = ""$UFS_MKFS $mkfs_opts $mkfs_subopts $raw_special $newsize""; setvar retv = "$Status" if test -n $verbose { echo $cmd } $cmd; setvar retv = "$Status" if test 0 -ne $retv { echo "$myname: cannot grow file system to $newsize sectors" exit $retv } } echo \ "\nThe incremental grow has successfully completed, but since the first growth \ attempt failed (see output from first mkfs(1M) run), the filesystem is still \ locked and needs to be checked with fsck(1M).\n\ Please run \`fsck -F ufs $raw_special' and then unlock the filesystem \ with \`lockfs -u $mount_pt'." | fmt; } exit $retv