diff --git a/sys/include/sys/sysproto_posix.h b/sys/include/sys/sysproto_posix.h index 5f3cf78..e14e374 100644 --- a/sys/include/sys/sysproto_posix.h +++ b/sys/include/sys/sysproto_posix.h @@ -785,6 +785,28 @@ int sys_setlogin(struct thread *, struct sys_setlogin_args *); +struct sys_getrlimit_args { + char which_l_[PADL_(u_int)]; + u_int which; + char which_r_[PADR_(u_int)]; + char rlp_l_[PADL_(struct rlimit *)]; + struct rlimit * rlp; + char rlp_r_[PADR_(struct rlimit *)]; +}; + +int sys_getrlimit(struct thread *, struct sys_getrlimit_args *); + +struct sys_setrlimit_args { + char which_l_[PADL_(u_int)]; + u_int which; + char which_r_[PADR_(u_int)]; + char rlp_l_[PADL_(struct rlimit *)]; + struct rlimit * rlp; + char rlp_r_[PADR_(struct rlimit *)]; +}; + +int sys_setrlimit(struct thread *, struct sys_setrlimit_args *); + //Func Defs int sys_invalid(struct thread *, void *); int sys_exit(struct thread *, struct sys_exit_args *); diff --git a/sys/kernel/gen_calls.c b/sys/kernel/gen_calls.c index f3d950c..537409a 100644 --- a/sys/kernel/gen_calls.c +++ b/sys/kernel/gen_calls.c @@ -203,14 +203,14 @@ tmpDesc->granularity = ((dData + dWrite + dBig + dBiglim + dDpl3) & 0xFF) >> 4; tmpDesc->baseHigh = base_addr >> 24; - asm( - "push %eax\n" + asm( + "push %eax\n" "mov $0x18,%ax\n" "lldt %ax\n" /* "lgdtl (loadGDT)\n" */ - "mov $0xF,%eax\n" - "mov %eax,%gs\n" - "pop %eax\n" - ); + "mov $0xF,%eax\n" + "mov %eax,%gs\n" + "pop %eax\n" + ); td->td_retval[0] = 0; } @@ -373,17 +373,206 @@ return (error); } -int sys_getrlimit(struct thread *thr, struct sys_getrlimit *args) { +int sys_getrlimit(struct thread *thr, struct sys_getrlimit_args *args) { int error = 0; - switch(args->resource) { + switch (args->which) { + case 0: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 1: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 2: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 3: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 4: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 5: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 6: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 7: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 8: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 9: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 10: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 11: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 12: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 13: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + case 14: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + args->rlp->rlim_cur = thr->rlim[args->which]->rlim_cur; + args->rlp->rlim_max = thr->rlim[args->which]->rlim_max; + break; + default: + error = -1; + kprintf("[getrlimit: %i]", args->which); } - return(error); + return (error); } -int sys_setrlimit(struct thread *thr, struct sys_setrlimit *args) { +int sys_setrlimit(struct thread *thr, struct sys_setrlimit_args *args) { int error = 0; - return(error); + switch (args->which) { + case 0: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 1: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 2: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 3: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 4: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 5: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 6: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 7: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 8: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 9: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 10: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 11: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 12: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 13: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + case 14: + if (thr->rlim[args->which] == 0) + thr->rlim[args->which] = (struct rlimit *) kmalloc(sizeof(struct rlimit)); + thr->rlim[args->which]->rlim_cur = args->rlp->rlim_cur; + thr->rlim[args->which]->rlim_max = args->rlp->rlim_max; + break; + default: + error = -1; + kprintf("[setrlimit: %i]", args->which); + } + + return (error); } diff --git a/sys/kernel/syscalls_posix.c b/sys/kernel/syscalls_posix.c index 90a5a84..b48b452 100644 --- a/sys/kernel/syscalls_posix.c +++ b/sys/kernel/syscalls_posix.c @@ -1002,15 +1002,15 @@ sys_invalid, SYSCALL_NOTIMP }, /* 193 - Invalid */ { - 0, + ARG_COUNT(sys_getrlimit_args), "getrlimit", - sys_invalid, - SYSCALL_NOTIMP }, /* 194 - Invalid */ + sys_getrlimit, + SYSCALL_VALID }, /* 194 - Invalid */ { - 0, + ARG_COUNT(sys_setrlimit_args), "setrlimit", - sys_invalid, - SYSCALL_NOTIMP }, /* 195 - Invalid */ + sys_setrlimit, + SYSCALL_VALID }, /* 195 - Invalid */ { ARG_COUNT(sys_getdirentries_args), "getdirentries",