Repository navigation
Expand file tree
/
Copy pathgcov.c
More file actions
66 lines (55 loc) · 1.67 KB
/
Copy pathgcov.c
File metadata and controls
66 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "fs.h"
#include "file.h"
int gcov_flush(cp_grant_id_t grantid, size_t size );
/*===========================================================================*
* do_gcov_flush *
*===========================================================================*/
int do_gcov_flush()
{
/* 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).
*/
struct fproc *rfp;
ssize_t size;
cp_grant_id_t grantid;
int r, n;
pid_t target;
message m;
vir_bytes buf;
size = job_m_in.m_lc_vfs_gcov.buff_sz;
target = job_m_in.m_lc_vfs_gcov.pid;
buf = job_m_in.m_lc_vfs_gcov.buff_p;
/* 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. */
if ((grantid = cpf_grant_magic(rfp->fp_endpoint, who_e, buf,
size, CPF_WRITE)) < 0) {
printf("VFS: gcov_flush: grant failed\n");
return(ENOMEM);
}
if (rfp->fp_endpoint == VFS_PROC_NR) {
/* Request is for VFS itself. */
r = gcov_flush(grantid, size);
} else {
/* Perform generic GCOV request. */
m.m_lc_vfs_gcov.grant = grantid;
m.m_lc_vfs_gcov.buff_sz = size;
r = _taskcall(rfp->fp_endpoint, COMMON_REQ_GCOV_DATA, &m);
}
cpf_revoke(grantid);
return(r);
}