--- machine/m_svr42.c.orig	Sat Sep  4 07:25:37 1993
+++ machine/m_svr42.c	Mon Mar 13 17:00:15 2000
@@ -69,6 +69,8 @@
 #define X_ANONINFO	4
 #define X_TOTAL		5
 #define X_SYSINFO	6
+#define X_MAXMEM	7
+#define X_FREEMEM	8
 
 static struct nlist nlst[] =
 {
@@ -79,6 +81,8 @@
   {"anoninfo"},			/* 4 */
   {"total"},			/* 5 */
   {"sysinfo"},			/* 6 */
+  {"maxmem"},			/* 7 */
+  {"mem_freemem"},		/* 8 */
   {NULL}
 };
 
@@ -88,6 +92,8 @@
 static unsigned long anoninfo_offset;
 static unsigned long total_offset;
 static unsigned long sysinfo_offset;
+static unsigned long maxmem_offset;
+static unsigned long freemem_offset;
 
 /* get_process_info passes back a handle.  This is what it looks like: */
 
@@ -188,6 +194,8 @@
     anoninfo_offset = nlst[X_ANONINFO].n_value;
     total_offset = nlst[X_TOTAL].n_value;
     sysinfo_offset = nlst[X_SYSINFO].n_value;
+    maxmem_offset = nlst[X_MAXMEM].n_value;
+    freemem_offset = nlst[X_FREEMEM].n_value;
 
     /* allocate space for proc structure array and array of pointers */
     bytes = nproc * sizeof (struct prpsinfo);
@@ -235,6 +243,8 @@
   long avenrun[3];
   struct sysinfo sysinfo;
   struct vmtotal total;
+  static int maxmem;
+  static int freemem;
   struct anoninfo anoninfo;
   static time_t cp_old[CPUSTATES];
   static time_t cp_diff[CPUSTATES];	/* for cpu state percentages */
@@ -258,10 +268,16 @@
 
   /* get total -- systemwide main memory usage structure */
   (void) getkval (total_offset, (int *) (&total), sizeof (total), "total");
+  (void) getkval (maxmem_offset, (int *) (&maxmem), sizeof (maxmem), "maxmem");
+  (void) getkval (freemem_offset, (int *) (&freemem), sizeof (freemem), "freemem");
   /* convert memory stats to Kbytes */
+/*
   memory_stats[0] = pagetok (total.t_rm);
   memory_stats[1] = pagetok (total.t_arm);
   memory_stats[2] = pagetok (total.t_free);
+*/
+  memory_stats[0] = pagetok (maxmem);
+  memory_stats[2] = pagetok (freemem);
   (void) getkval (anoninfo_offset, (int *) (&anoninfo), sizeof (anoninfo),
 		  "anoninfo");
   memory_stats[3] = pagetok (anoninfo.ani_max - anoninfo.ani_free);
@@ -591,8 +607,16 @@
   tsparms->ts_uprilim = tsparms->ts_upri = -(scale * prio) / 20;
   pcparms.pc_cid = pcinfo.pc_cid;
 
-  if (priocntl (P_PID, who, PC_SETPARMS, (caddr_t) & pcparms) == -1)
+  { long prio_ret;
+    int tmp_errno;
+  seteuid(getuid());
+  prio_ret = priocntl (P_PID, who, PC_SETPARMS, (caddr_t) & pcparms);
+  tmp_errno = errno;
+  seteuid(0); /* ignore error */
+  errno = tmp_errno;
+  if (prio_ret == -1)
     return (-1);
+  }
 
   return (0);
 }
