1#!/bin/sh - 2# 3# @(#)usermem.sh 5.4 (Berkeley) 09/17/85 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 9KMEM=/dev/kmem # User needs read access to KMEM 10UNIX= 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 16CLICKSIZE=512 17eval $* 18 19if test -n "$UNIX" 20then 21 : User must have specified it already. 22elif test -r /vmunix 23then 24 UNIX=/vmunix 25 CLICKSIZE=512 # Probably VAX 26elif test -r /edition7 27then 28 UNIX=/edition7 29 CLICKSIZE=2048 # Perkin-Elmer: change to 4096 on a 3205 30elif test -r /unix 31then 32 UNIX=/unix # Could be anything 33fi 34 35SIZE=0 36# messages: probably the most transportable 37if test -r /usr/adm/messages -a -s /usr/adm/messages 38then 39 SIZE=`grep avail /usr/adm/messages | sed -n '$s/.*[ ]//p'` 40fi 41 42if test 0$SIZE -le 0 # no SIZE in /usr/adm/messages 43then 44 if test -r $KMEM # Readable KMEM 45 then 46 if test -n "$UNIX" 47 then 48 SIZE=`echo maxmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'` 49 if test 0$SIZE -le 0 50 then 51 SIZE=`echo physmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'` 52 fi 53 SIZE=`expr 0$SIZE '*' $CLICKSIZE` 54 fi 55 fi 56fi 57 58case $UNIX in 59 /vmunix) # Assume 4.2bsd: check for resource limits 60 MAXSIZE=`csh -c limit | awk 'BEGIN { MAXSIZE = 1000000 } 61/datasize|memoryuse/ && NF == 3 { if ($2 < MAXSIZE) MAXSIZE = $2 } 62END { print MAXSIZE * 1000 }'` 63 if test $MAXSIZE -lt $SIZE 64 then 65 SIZE=$MAXSIZE 66 fi 67 ;; 68esac 69 70if test 0$SIZE -le 0 71then 72 echo 0;exit 1 73else 74 echo $SIZE 75fi 76