]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/miscellany/compress-4.0/usermem
Merge branch 'tmpfiles'
[nmh] / docs / historical / mh-6.8.5 / miscellany / compress-4.0 / usermem
1 : This shell script snoops around to find the maximum amount of available
2 : user memory. These variables need to be set only if there is no
3 : /usr/adm/messages. KMEM, UNIX, and CLICKSIZE can be set on the command
4 : line, if desired, e.g. UNIX=/unix
5 KMEM=/dev/kmem # User needs read access to KMEM
6 UNIX=
7 # VAX CLICKSIZE=512, UNIX=/vmunix
8 # PDP-11 CLICKSIZE=64, UNIX=/unix
9 # CADLINC 68000 CLICKSIZE=4096, UNIX=/unix
10 # Perkin-Elmer 3205 CLICKSIZE=4096, UNIX=/edition7
11 # Perkin-Elmer all others, CLICKSIZE=2048, UNIX=/edition7
12 CLICKSIZE=512
13 eval $*
14
15 SIZE=0
16 if test -r /usr/adm/messages # probably the most transportable
17 then
18 SIZE=`grep avail /usr/adm/messages | sed -n '$s/.*[ ]//p'`
19 fi
20
21 if test 0$SIZE -le 0 # no SIZE in /usr/adm/messages
22 then
23 if test -r $KMEM # Readable KMEM
24 then
25 if test -n "$UNIX"
26 then
27 : User must have specified it already.
28 elif test -r /vmunix
29 then
30 UNIX=/vmunix
31 CLICKSIZE=512 # Probably VAX
32 elif test -r /edition7
33 then
34 UNIX=/edition7
35 CLICKSIZE=2048 # Perkin-Elmer: change to 4096 on a 3205
36 elif test -r /unix
37 then
38 UNIX=/unix # Could be anything
39 fi
40 if test -n "$UNIX"
41 then
42 SIZE=`echo maxmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
43 if test 0$SIZE -le 0
44 then
45 SIZE=`echo physmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
46 fi
47 SIZE=`expr 0$SIZE '*' $CLICKSIZE`
48 fi
49 fi
50 fi
51
52 case $UNIX in
53 /vmunix) # Assume 4.2bsd: check for resource limits
54 MAXSIZE=`csh -c limit | awk 'BEGIN { MAXSIZE = 1000000 }
55 /datasize|memoryuse/ && NF == 3 { if ($2 < MAXSIZE) MAXSIZE = $2 }
56 END { print MAXSIZE * 1000 }'`
57 if test $MAXSIZE -lt $SIZE
58 then
59 SIZE=$MAXSIZE
60 fi
61 ;;
62 esac
63
64 if test 0$SIZE -le 0
65 then
66 echo 0;exit 1
67 else
68 echo $SIZE
69 fi