1#!/bin/sh
2
3# Check the sizes of Stage 2 and Stage 1.5's.
4# Copyright (C) 1999,2004  Free Software Foundation, Inc.
5
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.
10
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.
15
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.
19
20# Written by OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
21
22
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.
26check ()
27{
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
35    fi
36}
37
38# The bootloader area of a FFS partition is 14 sectors.
39check ffs_stage1_5 7168
40
41check ufs2_stage1_5 7168
42
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.
45check fat_stage1_5 31744
46
47# Likewise.
48check e2fs_stage1_5 31744
49
50# Likewise.
51check minix_stage1_5 31744
52
53# Success.
54exit 0
55