2010-08-25 15:06:43 +02:00
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include "file.h"
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
int gcov_flush(cp_grant_id_t grantid, size_t size );
|
2010-08-25 15:06:43 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_gcov_flush *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_gcov_flush()
|
2010-08-25 15:06:43 +02:00
|
|
|
{
|
|
|
|
/* A userland tool has requested the gcov data from another
|
|
|
|
* process (possibly vfs itself). Grant the target process
|
|
|
|
* access to the supplied buffer, and perform the call that
|
|
|
|
* makes the target copy its buffer to the caller (incl vfs
|
|
|
|
* itself).
|
|
|
|
*/
|
2012-02-13 16:28:04 +01:00
|
|
|
struct fproc *rfp;
|
|
|
|
ssize_t size;
|
|
|
|
cp_grant_id_t grantid;
|
|
|
|
int r, n;
|
|
|
|
pid_t target;
|
|
|
|
message m;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes buf;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
size = job_m_in.GCOV_BUFF_SZ;
|
|
|
|
target = job_m_in.GCOV_PID;
|
|
|
|
buf = (vir_bytes) job_m_in.GCOV_BUFF_P;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
/* If the wrong process is sent to, the system hangs; so make this root-only.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!super_user) return(EPERM);
|
|
|
|
|
|
|
|
/* Find target gcov process. */
|
|
|
|
for(n = 0; n < NR_PROCS; n++) {
|
|
|
|
if(fproc[n].fp_endpoint != NONE && fproc[n].fp_pid == target)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(n >= NR_PROCS) {
|
|
|
|
printf("VFS: gcov process %d not found\n", target);
|
|
|
|
return(ESRCH);
|
|
|
|
}
|
|
|
|
rfp = &fproc[n];
|
|
|
|
|
|
|
|
/* Grant target process to requestor's buffer. */
|
2012-04-13 14:50:38 +02:00
|
|
|
if ((grantid = cpf_grant_magic(rfp->fp_endpoint, who_e, buf,
|
|
|
|
size, CPF_WRITE)) < 0) {
|
2012-02-13 16:28:04 +01:00
|
|
|
printf("VFS: gcov_flush: grant failed\n");
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (rfp->fp_endpoint == VFS_PROC_NR) {
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Request is for VFS itself. */
|
|
|
|
r = gcov_flush(grantid, size);
|
|
|
|
} else {
|
|
|
|
/* Perform generic GCOV request. */
|
|
|
|
m.GCOV_GRANT = grantid;
|
|
|
|
m.GCOV_BUFF_SZ = size;
|
|
|
|
r = _taskcall(rfp->fp_endpoint, COMMON_REQ_GCOV_DATA, &m);
|
|
|
|
}
|
|
|
|
|
|
|
|
cpf_revoke(grantid);
|
|
|
|
|
|
|
|
return(r);
|
2010-08-25 15:06:43 +02:00
|
|
|
}
|