#include <klibc/string.h>
#include <lunaix/clock.h>
#include <lunaix/common.h>
+#include <lunaix/mm/pmm.h>
#include <lunaix/mm/region.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/spike.h>
+#include <lunaix/status.h>
#include <lunaix/syscall.h>
#include <lunaix/syslog.h>
__dup_pagetable(pid_t pid, uintptr_t mount_point)
{
void* ptd_pp = pmm_alloc_page(pid, PP_FGPERSIST);
- x86_page_table* ptd = vmm_fmap_page(pid, PG_MOUNT_1, ptd_pp, PG_PREM_RW);
+ vmm_set_mapping(PD_REFERENCED, PG_MOUNT_1, ptd_pp, PG_PREM_RW, VMAP_NULL);
+
+ x86_page_table* ptd = PG_MOUNT_1;
x86_page_table* pptd = (x86_page_table*)(mount_point | (0x3FF << 12));
for (size_t i = 0; i < PG_MAX_ENTRIES - 1; i++) {
continue;
}
- x86_page_table* ppt = (x86_page_table*)(mount_point | (i << 12));
void* pt_pp = pmm_alloc_page(pid, PP_FGPERSIST);
- x86_page_table* pt = vmm_fmap_page(pid, PG_MOUNT_2, pt_pp, PG_PREM_RW);
+ vmm_set_mapping(
+ PD_REFERENCED, PG_MOUNT_2, pt_pp, PG_PREM_RW, VMAP_NULL);
+
+ x86_page_table* ppt = (x86_page_table*)(mount_point | (i << 12));
+ x86_page_table* pt = PG_MOUNT_2;
for (size_t j = 0; j < PG_MAX_ENTRIES; j++) {
x86_pte_t pte = ppt->entry[j];
return __current->parent->pid;
}
+__DEFINE_LXSYSCALL(pid_t, getpgid)
+{
+ return __current->pgid;
+}
+
+__DEFINE_LXSYSCALL2(int, setpgid, pid_t, pid, pid_t, pgid)
+{
+ struct proc_info* proc = pid ? get_process(pid) : __current;
+
+ if (!proc) {
+ __current->k_status = LXINVL;
+ return -1;
+ }
+
+ pgid = pgid ? pgid : proc->pid;
+
+ struct proc_info* gruppenfuhrer = get_process(pgid);
+
+ if (!gruppenfuhrer || proc->pgid == proc->pid) {
+ __current->k_status = LXINVL;
+ return -1;
+ }
+
+ llist_delete(&proc->grp_member);
+ llist_append(&gruppenfuhrer->grp_member, &proc->grp_member);
+
+ proc->pgid = pgid;
+ return 0;
+}
+
void
init_proc(struct proc_info* pcb)
{
pcb->pid = alloc_pid();
pcb->created = clock_systime();
pcb->state = PROC_CREATED;
+ pcb->pgid = pcb->pid;
}
pid_t