* do_dup: perform the DUP system call
* do_fcntl: perform the FCNTL system call
* do_sync: perform the SYNC system call
+ * do_fsync: perform the FSYNC system call
* do_reboot: sync disks and prepare for shutdown
* do_fork: adjust the tables after MM has performed a FORK system call
* do_exec: handle files with FD_CLOEXEC on after MM has done an EXEC
return(OK); /* sync() can't fail */
}
+/*===========================================================================*
+ * do_fsync *
+ *===========================================================================*/
+PUBLIC int do_fsync()
+{
+/* Perform the fsync() system call. For now, don't be unnecessarily smart. */
+
+ do_sync();
+
+ return(OK);
+}
+
+
/*===========================================================================*
* do_reboot *
_PROTOTYPE( int do_revive, (void) );
_PROTOTYPE( int do_set, (void) );
_PROTOTYPE( int do_sync, (void) );
+_PROTOTYPE( int do_fsync, (void) );
_PROTOTYPE( int do_reboot, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_getsysinfo, (void) );
no_sys, /* 84 = memfree */
do_select, /* 85 = select */
do_fchdir, /* 86 = fchdir */
+ do_fsync, /* 87 = fsync */
+ no_sys, /* 88 = getpriority */
+ no_sys, /* 89 = setpriority */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
* handling behaviour for PM, since PM cannot call sigaction() as others.
*/
mproc[INIT_PROC_NR].mp_pid = INIT_PID;
+ mproc[INIT_PROC_NR].mp_nice = 0;
mproc[INIT_PROC_NR].mp_parent = PM_PROC_NR;
sigemptyset(&mproc[INIT_PROC_NR].mp_ignore);
sigemptyset(&mproc[INIT_PROC_NR].mp_sigmask);
* do_getprocnr: lookup process slot number (Jorrit N. Herder)
* do_memalloc: allocate a chunk of memory (Jorrit N. Herder)
* do_memfree: deallocate a chunk of memory (Jorrit N. Herder)
+ * do_getsetpriority: get/set process priority
*/
#include "pm.h"
#include <minix/callnr.h>
#include <signal.h>
#include <sys/svrctl.h>
+#include <sys/resource.h>
#include <minix/com.h>
#include <minix/utils.h>
#include <string.h>
return(SUSPEND); /* don't reply to killed process */
}
+/*=====================================================================*
+ * do_getsetpriority *
+ *=====================================================================*/
+PUBLIC int do_getsetpriority()
+{
+ int arg_which, arg_who, arg_pri;
+ int rmp_nr;
+ struct mproc *rmp;
+
+ arg_which = m_in.m1_i1;
+ arg_who = m_in.m1_i2;
+ arg_pri = m_in.m1_i3; /* for SETPRIORITY */
+
+ /* Code common to GETPRIORITY and SETPRIORITY. */
+
+ /* Only support PRIO_PROCESS for now. */
+ if(arg_which != PRIO_PROCESS)
+ return EINVAL;
+
+ if(arg_who == 0)
+ rmp_nr = who;
+ else
+ if((rmp_nr = proc_from_pid(arg_who)) < 0)
+ return ESRCH;
+
+ rmp = &mproc[rmp_nr];
+
+ if(mp->mp_effuid != SUPER_USER &&
+ mp->mp_effuid != rmp->mp_effuid && mp->mp_effuid != rmp->mp_realuid)
+ return EPERM;
+
+ /* If GET, that's it. */
+
+ if(call_nr == GETPRIORITY) {
+ return rmp->mp_nice - PRIO_MIN;
+ }
+
+ /* Only root is allowed to reduce the nice level. */
+ if(rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
+ return EACCES;
+
+ /* We're SET, and it's allowed. Do it and tell kernel. */
+ rmp->mp_nice = arg_pri;
+ return sys_setpriority(rmp_nr, arg_pri);
+}
+
/*=====================================================================*
* do_svrctl *
*=====================================================================*/
struct mproc *mp_swapq; /* queue of procs waiting to be swapped in */
message mp_reply; /* reply message to be sent to one */
+ /* Scheduling priority. */
+ signed int mp_nice; /* nice is PRIO_MIN..PRIO_MAX, standard 0. */
+
char mp_name[PROC_NAME_LEN]; /* process name */
} mproc[NR_PROCS];
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_allocmem, (void) );
_PROTOTYPE( int do_freemem, (void) );
-_PROTOTYPE( int do_mstats, (void) );
+_PROTOTYPE( int do_getsetpriority, (void) );
#if (MACHINE == MACINTOSH)
_PROTOTYPE( phys_clicks start_click, (void) );
_PROTOTYPE( int get_stack_ptr, (int proc_nr, vir_bytes *sp) );
_PROTOTYPE( int get_mem_map, (int proc_nr, struct mem_map *mem_map) );
_PROTOTYPE( char *find_param, (const char *key));
+_PROTOTYPE( int proc_from_pid, (pid_t p));
do_freemem, /* 84 = memfree */
no_sys, /* 85 = select */
no_sys, /* 86 = fchdir */
+ no_sys, /* 87 = fsync */
+ do_getsetpriority, /* 88 = getpriority */
+ do_getsetpriority, /* 89 = setpriority */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
* tell_fs: interface to FS
* get_mem_map: get memory map of given process
* get_stack_ptr: get stack pointer of given process
+ * proc_from_pid: return process pointer from pid number
*/
#include "pm.h"
return(OK);
}
+/*===========================================================================*
+ * proc_from_pid *
+ *===========================================================================*/
+PUBLIC int proc_from_pid(mp_pid)
+pid_t mp_pid;
+{
+ int rmp;
+
+ for (rmp = 0; rmp < NR_PROCS; rmp++)
+ if (mproc[rmp].mp_pid == mp_pid)
+ return rmp;
+
+ return -1;
+}
+