libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / bin / compress / usermem.sh
blobba63b8b42332fad63e527bbe10c23ef4a5d01a18
1 #! /bin/sh
3 # @(#)usermem.sh 1.1 86/09/25 SMI; from UCB 5.4 85/09/17
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 $*
19 if test -n "$UNIX"
20 then
21 : User must have specified it already.
22 elif test -r /vmunix
23 then
24 UNIX=/vmunix
25 if [ -r /bin/sun2 ] && /bin/sun2
26 then
27 CLICKSIZE=2048 # Sun-2
28 elif [ -r /bin/sun3 ] && /bin/sun3
29 then
30 CLICKSIZE=8192 # Sun-3
31 else
32 CLICKSIZE=512 # Probably VAX
34 elif test -r /edition7
35 then
36 UNIX=/edition7
37 CLICKSIZE=2048 # Perkin-Elmer: change to 4096 on a 3205
38 elif test -r /unix
39 then
40 UNIX=/unix # Could be anything
43 SIZE=0
44 # messages: probably the most transportable
45 if test -r /usr/adm/messages -a -s /usr/adm/messages
46 then
47 SIZE=`grep avail /usr/adm/messages | sed -n '$s/.*[ ]//p'`
50 if test 0$SIZE -le 0 # no SIZE in /usr/adm/messages
51 then
52 if test -r $KMEM # Readable KMEM
53 then
54 if test -n "$UNIX"
55 then
56 SIZE=`echo maxmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
57 if test 0$SIZE -le 0
58 then
59 SIZE=`echo physmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
61 SIZE=`expr 0$SIZE '*' $CLICKSIZE`
66 case $UNIX in
67 /vmunix) # Assume 4.2bsd: check for resource limits
68 MAXSIZE=`csh -c limit | awk 'BEGIN { MAXSIZE = 1000000 }
69 /datasize|memoryuse/ && NF == 3 { if ($2 < MAXSIZE) MAXSIZE = $2 }
70 END { print MAXSIZE * 1000 }'`
71 if test $MAXSIZE -lt $SIZE
72 then
73 SIZE=$MAXSIZE
76 esac
78 if test 0$SIZE -le 0
79 then
80 echo 0;exit 1
81 else
82 echo $SIZE