1

I have to edit the exec syscall inside the Minix OS, in a way that every process created by it should print the program file path + program name:

for example, if I type ls inside the terminal, the next line should show me path/to/ls/ls always in this format: filepath/programName.

I already managed to print the program name, but I am having problems with the file path. Can somebody show me how can I print it?

here is the code for sys_exec.c:

#include "syslib.h"
#include "stdio.h" //I included this library

int sys_exec(endpoint_t proc_ep, vir_bytes stack_ptr, vir_bytes progname,
        vir_bytes pc, vir_bytes ps_str)
{
/* A process has exec'd.  Tell the kernel. */

        message m;

        m.m_lsys_krn_sys_exec.endpt = proc_ep;
        m.m_lsys_krn_sys_exec.stack = stack_ptr;
        m.m_lsys_krn_sys_exec.name = progname;
        m.m_lsys_krn_sys_exec.ip = pc;
        m.m_lsys_krn_sys_exec.ps_str = ps_str;

        //edited by me
        puts((char*)progname);//this prints the program name

        return _kernel_call(SYS_EXEC, &m);
}

and some image as reference:

this is what happens when I type ls

Gabomfim
  • 29
  • 6

1 Answers1

1

I was on the wrong path, the file I needed to edit was \usr\src\minix\minix\servers\vfs\exec.c, I was trying to edit \usr\src\minix\minix\lib\libsys\sys_exec.c.

Inside the right file I had access to a variable called fullpath inside the get_read_vp function. I imported stdio.h and then typed printf("executing: %s\n", fullpath); inside the function.

Gabomfim
  • 29
  • 6