[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH 3/3] lib/posix-process: Implement getpriority() and setpriority()
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@xxxxxxxxx> On Mon, Nov 25, 2019 at 12:58 PM Costin Lupu <costin.lupu@xxxxxxxxx> wrote: > > We allow getting and setting priority only for the calling process (or its > process group or its real user ID), meaning that 0 is the only accepted value > for the 'who' parameter. This patch also introduces the default value for the > Unikraft "process" priority. This is also the only value that can be set using > setpriority() (i.e. basically it doesn't change anything). > > Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> > --- > lib/posix-process/include/uk/process.h | 1 + > lib/posix-process/process.c | 54 ++++++++++++++++++++++++-- > 2 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/lib/posix-process/include/uk/process.h > b/lib/posix-process/include/uk/process.h > index 67208e3d..b5eeb90a 100644 > --- a/lib/posix-process/include/uk/process.h > +++ b/lib/posix-process/include/uk/process.h > @@ -39,5 +39,6 @@ > #define UNIKRAFT_PPID 0 > #define UNIKRAFT_SID 0 > #define UNIKRAFT_PGID 0 > +#define UNIKRAFT_PROCESS_PRIO 0 > > #endif /* __UK_PROCESS_H__ */ > diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c > index 74961db8..b2ace4c6 100644 > --- a/lib/posix-process/process.c > +++ b/lib/posix-process/process.c > @@ -298,10 +298,58 @@ int nice(int inc __unused) > return -1; > } > > -int setpriority(int which __unused, id_t who __unused, int prio __unused) > +int getpriority(int which, id_t who) > { > - WARN_STUBBED(); > - return 0; > + int rc = 0; > + > + switch (which) { > + case PRIO_PROCESS: > + case PRIO_PGRP: > + case PRIO_USER: > + if (who == 0) > + /* Allow only for the calling "process" */ > + rc = UNIKRAFT_PROCESS_PRIO; > + else { > + errno = ESRCH; > + rc = -1; > + } > + break; > + default: > + errno = EINVAL; > + rc = -1; > + break; > + } > + > + return rc; > +} > + > +int setpriority(int which, id_t who, int prio) > +{ > + int rc = 0; > + > + switch (which) { > + case PRIO_PROCESS: > + case PRIO_PGRP: > + case PRIO_USER: > + if (who == 0) { > + /* Allow only for the calling "process" */ > + if (prio != UNIKRAFT_PROCESS_PRIO) { > + /* Allow setting only the default prio */ > + errno = EACCES; > + rc = -1; > + } > + } else { > + errno = ESRCH; > + rc = -1; > + } > + break; > + default: > + errno = EINVAL; > + rc = -1; > + break; > + } > + > + return rc; > } > > int prctl(int option __unused, ...) > -- > 2.20.1 > _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |