previous | start | next

Copying Data from the Process Manager to a User

This seems as though it should be the same as copying from kernel space to a user address space. However, the process manager does not have the privilege to call virtual_copy or phys_copy directly. It must send a "ask" the system task. The system library function sys_vircopy is provided in Minix 3 for that purpose.

PUBLIC int sys_vircopy(src_proc, src_seg, src_vir,
        dst_proc, dst_seg, dst_vir, bytes)
int src_proc;                   /* source process */
int src_seg;                    /* source memory segment */
vir_bytes src_vir;              /* source virtual address */
int dst_proc;                   /* destination process */
int dst_seg;                    /* destination memory segment */
vir_bytes dst_vir;              /* destination virtual address */
phys_bytes bytes;               /* how many bytes */

Note: src_proc and dst_proc should be endpoint values

There are no struct parameters here, but they are comparable to the values we needed in using virtual_copy in the system task.

We can use this as a sort of check on the task call for a user's mem_maps. Both the process tables mproc and proc have an array of mem_map for the 3 local segments of each process. These should have the same information. As a check a user process could declare two such arrays and get one from the process manager's mproc and the other from the kernel's proc table and print the results. They should be the same. All that is needed is to pass the pid of the user whose mem_maps we want (not necessarily the calling user) and pointers to the two user arrays.

The endpoint of the calling user is available in several ways:

    mp->mp_endpopint
    m_in.m_source
    who_e

How do you get the endpoint for a different user given only that user's pid?



previous | start | next