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