Last change
on this file was 30, checked in by bcornec, 20 years ago |
Id property added on files to allow for better conf. management
|
-
Property svn:keywords
set to
Id
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 |
|
---|
3 | # patched by Doug Nordwall, June 28th 2000, to fix a SCSI disk size
|
---|
4 | # calculation bug; nice one, Doug! :-) - HR
|
---|
5 |
|
---|
6 | CalcDiskSize() {
|
---|
7 | local res cylinders sectorsize disksize i curr stub out
|
---|
8 | res=`fdisk -l $1 2> /dev/null | grep -i "cylinders of"`
|
---|
9 | cylinders=`echo "$res" | cut -d' ' -f5`
|
---|
10 | sectorsize=`echo "$res" | cut -d' ' -f7`
|
---|
11 | cylindermod=`fdisk -l $1 2> /dev/null | grep -i $1:`; # note colon at end to make sure it's not the /dev/sda# partition info
|
---|
12 | cylnum=`echo "$cylindermod" | cut -d' ' -f7`
|
---|
13 | predisksize=$(($cylinders*$sectorsize/1024))
|
---|
14 | disksize=$(($predisksize*$cylnum/1024)); # this works on larger drives; I imagine it'll work on smaller drives with fewer cylinders...
|
---|
15 |
|
---|
16 | #echo "cylinders = $cylinders; sectorsize = $sectorsize"
|
---|
17 | #echo "cylnum = $cylnum"
|
---|
18 | #echo "predisksize = $predisksize; disksize = $disksize"
|
---|
19 |
|
---|
20 | if [ "$disksize" = "" ] ; then
|
---|
21 | return 1
|
---|
22 | else
|
---|
23 | echo "$disksize"
|
---|
24 | return 0
|
---|
25 | fi
|
---|
26 | }
|
---|
27 |
|
---|
28 | # ---------------- main ---------------
|
---|
29 |
|
---|
30 | if [ "$#" -ne "1" ] || [ "`echo "$1" |grep -x "/dev/[a-z]*"`" = "" ]; then
|
---|
31 | LogIt "calc-disk-size <device>" 1
|
---|
32 | exit 1
|
---|
33 | fi
|
---|
34 |
|
---|
35 | LogIt "calc-disk-size --- starting"
|
---|
36 | out=`CalcDiskSize $1`
|
---|
37 | if [ "$out" = "" ] ; then
|
---|
38 | echo "-1"
|
---|
39 | else
|
---|
40 | echo "$out"
|
---|
41 | fi
|
---|
42 |
|
---|
43 | LogIt "calc-disk-size --- leaving"
|
---|
44 |
|
---|
45 | exit
|
---|
46 |
|
---|
47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.