Merge branch 'master' of git://github.com/illumos/illumos-gate
[unleashed.git] / usr / src / grub / grub-0.97 / stage2 / size_test
blobf2b8c945ca540e3ceda5c2b35c94bc649c5df237
1 #!/bin/sh
3 # Check the sizes of Stage 2 and Stage 1.5's.
4 # Copyright (C) 1999,2004 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Written by OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
23 # This function checks if the size of the first argument (filename) is
24 # greater than the second argument (limit). If so, then exit with the
25 # status 1, otherwise do nothing.
26 check ()
28 file=$1
29 limit=$2
30 set dummy `ls -l $file`
31 size=$6
32 if test $size -gt $limit; then
33 echo "$file is too big ($size > $limit)."
34 exit 1
38 # The bootloader area of a FFS partition is 14 sectors.
39 check ffs_stage1_5 7168
41 check ufs2_stage1_5 7168
43 # Stage 1.5 can be installed in the sectors immediately after MBR in the
44 # first cylinder, so the size is (63 - 1) sectors.
45 check fat_stage1_5 31744
47 # Likewise.
48 check e2fs_stage1_5 31744
50 # Likewise.
51 check minix_stage1_5 31744
53 # Success.
54 exit 0