mirror of
https://github.com/drasko/codezero.git
synced 2026-04-18 01:39:05 +02:00
Added ipc to notify vfs about a forked child.
TODO: Need to ensure child shmat()s its own utcb after a fork (possibly in libposix/fork.c)
This commit is contained in:
@@ -8,6 +8,14 @@ struct id_pool {
|
||||
u32 bitmap[];
|
||||
};
|
||||
|
||||
/* Copy one id pool to another by calculating its size */
|
||||
static inline void id_pool_copy(struct idpool *to, struct idpool *from, int totalbits)
|
||||
{
|
||||
int nwords = BITWISE_GETWORD(totalbits);
|
||||
|
||||
memcpy(to, from, nwords * SZ_WORD + sizeof(struct id_pool));
|
||||
}
|
||||
|
||||
struct id_pool *id_pool_new_init(int mapsize);
|
||||
int id_new(struct id_pool *pool);
|
||||
int id_del(struct id_pool *pool, int id);
|
||||
|
||||
@@ -24,6 +24,17 @@ struct tcb {
|
||||
struct vnode *rootdir;
|
||||
};
|
||||
|
||||
/* Structures used when receiving new task info from pager */
|
||||
struct task_data {
|
||||
unsigned long tid;
|
||||
unsigned long utcb_address;
|
||||
};
|
||||
|
||||
struct task_data_head {
|
||||
unsigned long total;
|
||||
struct task_data tdata[];
|
||||
};
|
||||
|
||||
static inline int task_is_utcb_mapped(struct tcb *t)
|
||||
{
|
||||
return t->utcb_mapped;
|
||||
|
||||
@@ -99,6 +99,10 @@ void handle_fs_requests(void)
|
||||
pager_update_stats(sender, (unsigned long)mr[0],
|
||||
(unsigned long)mr[1]);
|
||||
break;
|
||||
case L4_IPC_TAG_NOTIFY_FORK:
|
||||
pager_notify_fork(sender, (l4id_t)mr[0], (l4id_t)mr[1],
|
||||
(unsigned long)mr[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s: Unrecognised ipc tag (%d) "
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
#include INC_GLUE(memory.h)
|
||||
#include <stdio.h>
|
||||
|
||||
static inline void id_pool_copy(struct idpool *to, struct idpool *from, int totalbits)
|
||||
{
|
||||
int nwords = BITWISE_GETWORD(totalbits);
|
||||
|
||||
memcpy(to, from, nwords * SZ_WORD + sizeof(struct id_pool));
|
||||
}
|
||||
struct id_pool *id_pool_new_init(int totalbits)
|
||||
{
|
||||
int nwords = BITWISE_GETWORD(totalbits);
|
||||
|
||||
@@ -72,15 +72,44 @@ int receive_pager_taskdata_orig(l4id_t *tdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct task_data {
|
||||
unsigned long tid;
|
||||
unsigned long utcb_address;
|
||||
};
|
||||
/*
|
||||
* Receives ipc from pager about a new fork event and
|
||||
* the information on the resulting child task.
|
||||
*/
|
||||
int pager_notify_fork(l4id_t sender, l4id_t parid,
|
||||
l4id_t chid, unsigned long utcb_address)
|
||||
{
|
||||
struct tcb *child, *parent;
|
||||
int err;
|
||||
|
||||
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
BUG_ON(!(parent = find_task(parid)));
|
||||
|
||||
if (IS_ERR(child = create_tcb())) {
|
||||
l4_ipc_return((int)child);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialise fields sent by pager */
|
||||
child->tid = chid;
|
||||
child->utcb_address = utcb_address;
|
||||
|
||||
/*
|
||||
* Initialise vfs specific fields.
|
||||
* FIXME: Or copy from parent???
|
||||
*/
|
||||
child->rootdir = vfs_root.pivot;
|
||||
child->curdir = vfs_root.pivot;
|
||||
|
||||
/* Copy file descriptors from parent */
|
||||
id_pool_copy(child->fdpool, parent->fdpool, TASK_FILES_MAX);
|
||||
memcpy(child->fd, parent->fd, TASK_FILES_MAX * sizeof(int));
|
||||
|
||||
l4_ipc_return(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct task_data_head {
|
||||
unsigned long total;
|
||||
struct task_data tdata[];
|
||||
};
|
||||
|
||||
/* Read task information into the utcb page, since it won't fit into mrs. */
|
||||
struct task_data_head *receive_pager_taskdata(void)
|
||||
|
||||
Reference in New Issue
Block a user