in formats that don't change (or is upwards compatible).
-#define NCALLS 97 /* number of system calls allowed */
+#define NCALLS 98 /* number of system calls allowed */
#define EXIT 1
#define FORK 2
#define FTRUNCATE 94 /* to FS */
#define FCHMOD 95 /* to FS */
#define FCHOWN 96 /* to FS */
+#define GETSYSINFO_UP 97 /* to PM or FS */
/* Calls provided by PM and FS that are not part of the API */
#define EXEC_NEWMEM 100 /* from FS or RS to PM: new memory map for
#define SEL_ERRORFDS m8_p3
#define SEL_TIMEOUT m8_p4
+/* Field names for GETSYSINFO_UP (PM). */
+#define SIU_WHAT m2_i1
+#define SIU_LEN m2_i2
+#define SIU_WHERE m2_p1
+
/* Message for SYS_READBIOS */
#define RDB_SIZE m2_i1
#define RDB_ADDR m2_l1
--- /dev/null
+
+#ifndef _MINIX_SYSINFO_H
+#define _MINIX_SYSINFO_H
+
+#include <minix/endpoint.h>
+#include <minix/type.h>
+
+_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
+_PROTOTYPE( ssize_t getsysinfo_up, (endpoint_t who, int what, size_t size,
+ void *where));
+
+#define SIU_LOADINFO 1 /* retrieve load info data */
+
+/* Exported system parameters. */
+
+#endif
+
};
/* Load data accounted every this no. of seconds. */
-#define _LOAD_UNIT_SECS 6
+#define _LOAD_UNIT_SECS 6 /* Changing this breaks ABI. */
/* Load data history is kept for this long. */
-#define _LOAD_HISTORY_MINUTES 15
+#define _LOAD_HISTORY_MINUTES 15 /* Changing this breaks ABI. */
#define _LOAD_HISTORY_SECONDS (60*_LOAD_HISTORY_MINUTES)
/* We need this many slots to store the load history. */
#include <lib.h>
+#include <minix/endpoint.h>
#define getsysinfo _getsysinfo
-#include <unistd.h>
+#define getsysinfo_up _getsysinfo_up
+#include <minix/sysinfo.h>
PUBLIC int getsysinfo(who, what, where)
-int who; /* from whom to request info */
+endpoint_t who; /* from whom to request info */
int what; /* what information is requested */
void *where; /* where to put it */
{
return(0);
}
+/* Unprivileged variant of getsysinfo. */
+PUBLIC ssize_t getsysinfo_up(who, what, size, where)
+endpoint_t who; /* from whom to request info */
+int what; /* what information is requested */
+size_t size; /* input and output size */
+void *where; /* where to put it */
+{
+ message m;
+ m.SIU_WHAT = what;
+ m.SIU_WHERE = where;
+ m.SIU_LEN = size;
+ return _syscall(who, GETSYSINFO_UP, &m);
+}
+
#include <sys/types.h>
+#include <minix/sysinfo.h>
#include <stdlib.h>
#include <unistd.h>
#include <lib.h>
int h, p, unfilled_ticks;
#define PERIODS 3
int minutes[3] = { 1, 5, 15 };
+ size_t loadsize;
+ ssize_t l;
if(nelem < 1) {
errno = ENOSPC;
return -1;
}
- if(getsysinfo(PM_PROC_NR, SI_LOADINFO, &loadinfo) < 0)
+ loadsize = sizeof(loadinfo);
+ if((l=getsysinfo_up(PM_PROC_NR, SIU_LOADINFO, loadsize, &loadinfo)) < 0)
+ return -1;
+ if(l != sizeof(loadinfo))
return -1;
if(nelem > PERIODS)
nelem = PERIODS;
.sect .text
.extern __getsysinfo
.define _getsysinfo
+.extern __getsysinfo_up
+.define _getsysinfo_up
.align 2
_getsysinfo:
jmp __getsysinfo
+_getsysinfo_up:
+ jmp __getsysinfo_up
do_ftruncate, /* 94 = truncate */
do_chmod, /* 95 = fchmod */
do_chown, /* 96 = fchown */
+ no_sys, /* 97 = (getsysinfo_up) */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
#include <sys/utsname.h>
#include <minix/com.h>
#include <minix/config.h>
+#include <minix/sysinfo.h>
#include <minix/type.h>
#include <string.h>
#include <lib.h>
return(OK);
}
+/*===========================================================================*
+ * do_getsysinfo_up *
+ *===========================================================================*/
+PUBLIC int do_getsysinfo_up()
+{
+ vir_bytes src_addr, dst_addr;
+ struct loadinfo loadinfo;
+ size_t len, real_len;
+ int s, r;
+
+ switch(m_in.SIU_WHAT) {
+ case SIU_LOADINFO: /* loadinfo is obtained via PM */
+ sys_getloadinfo(&loadinfo);
+ src_addr = (vir_bytes) &loadinfo;
+ real_len = sizeof(struct loadinfo);
+ break;
+ default:
+ return(EINVAL);
+ }
+
+ /* Let application know what the length was. */
+ len = real_len;
+ if(len > m_in.SIU_LEN)
+ len = m_in.SIU_LEN;
+
+ dst_addr = (vir_bytes) m_in.SIU_WHERE;
+ if (OK != (s=sys_datacopy(SELF, src_addr, who_e, dst_addr, len)))
+ return(s);
+ return(real_len);
+}
+
/*===========================================================================*
* do_getprocnr *
*===========================================================================*/
_PROTOTYPE( int do_procstat, (void) );
_PROTOTYPE( int do_sysuname, (void) );
_PROTOTYPE( int do_getsysinfo, (void) );
+_PROTOTYPE( int do_getsysinfo_up, (void) );
_PROTOTYPE( int do_getprocnr, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_allocmem, (void) );
no_sys, /* 94 = (ftruncate) */
no_sys, /* 95 = (fchmod) */
no_sys, /* 96 = (fchown) */
+ do_getsysinfo_up,/* 97 = getsysinfo_up */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];