I have done a new system-call named spawn.
Kernel and glibc are correctly updated and both know "spawn".
spawn(char *filename, char **argv, char **envp, unsigned int args)
This system call first do a fork and then an execve in the created child.
My problem is when i call spawn: spawn("/bin/ls", argv, envp, FLAGS);
execve succeeds (return value is 0) but in fact nothing appends !!! ?
i have tried to make this in two different ways.
*********************
* FIRST WAY *
*********************
1.) sys_spawn call do_spawn
---------------------------
2.) do_spawn call my_fork
-------------------------
3.) my_fork (/usr/src/linux/kernel/fork.c)
-------------------------------------------
my_fork is exactly the same as do_fork but call mycopy_thread in place of
copy_thread
i have
=> retval = mycopy_thread(nr, clone_flags, usp, p, regs);
in place of
=> retval = copy_thread(nr, clone_flags, usp, p, regs);
3.) mycopy_thread (/usr/src/linux/arch/i386/kernel/process.c)
-------------------------------------------------------------
mycopy_thread is exactly the same as copy_thread except two lines
i have
=> memcpy(&my_regs, childregs, sizeof(struct pt_regs));
=> p->tss.eip = (unsigned long) my_last_function;
in place of
=> p->tss.eip = (unsigned long) ret_from_fork
where my_regs is "actually" an "ugly" global variable.
4.) my_last_function
--------------------
void my_last_function(void)
{
char *filename;
int error;
filename = getname((char*)my_regs.ebx);
error = do_execve(filename, (char**) my_regs.ecx, (char**) my_regs.edx,
&my_regs);
ret_from_fork();
So error is zero .. but do_execve does nothing at all.Quote:}
*********************
* SECOND WAY *
*********************
1.) sys_spawn call do_spawn
---------------------------
2.) do_spawn
-------------
do_spawn uses kernel_thread
waitpid = kernel_thread(my_execve, spawnstr, CLONE_FS | CLONE_FILES |
CLONE_SIGHAND | CLONE_VFORK);
3.) my_execve (/usr/src/linux/fs/exec.c)
-----------------------------------------
my_execve is exactly the same as do_execve but the function prototype is
my_execve(struct s_spawn *spawnstr)
and the structure s_spawn is
struct s_spawn
{
char *filename;
char **argv;
char **envp;
struct pt_regs *regs;
}
of course i have changed in my_execve
filename to spawnstr->filename
argv to spawnstr->argv
envp to spawnstr->envp
regs to spawnstr->regs
Finally the result is the same .. execve returns zero but doesn't execute
anything.
NOTES
--------
I tried to check the different parms do_execve takes, and all of
them where correct: like the filename, argv and envp.
I also tried to check if the flag current->flags was alright.
(like cheking if PF_FORKNOEXEC was set)
I need help :)
Thanx