tools/llvm: Do not build with symbols
[minix3.git] / minix / servers / vfs / gcov.c
blob7d1c1e7ab07437a0f29197706378d6f0300679e5
2 #include "fs.h"
3 #include "file.h"
5 int gcov_flush(cp_grant_id_t grantid, size_t size );
7 /*===========================================================================*
8 * do_gcov_flush *
9 *===========================================================================*/
10 int do_gcov_flush()
12 /* A userland tool has requested the gcov data from another
13 * process (possibly vfs itself). Grant the target process
14 * access to the supplied buffer, and perform the call that
15 * makes the target copy its buffer to the caller (incl vfs
16 * itself).
18 struct fproc *rfp;
19 ssize_t size;
20 cp_grant_id_t grantid;
21 int r, n;
22 pid_t target;
23 message m;
24 vir_bytes buf;
26 size = job_m_in.m_lc_vfs_gcov.buff_sz;
27 target = job_m_in.m_lc_vfs_gcov.pid;
28 buf = job_m_in.m_lc_vfs_gcov.buff_p;
30 /* If the wrong process is sent to, the system hangs; so make this root-only.
33 if (!super_user) return(EPERM);
35 /* Find target gcov process. */
36 for(n = 0; n < NR_PROCS; n++) {
37 if(fproc[n].fp_endpoint != NONE && fproc[n].fp_pid == target)
38 break;
40 if(n >= NR_PROCS) {
41 printf("VFS: gcov process %d not found\n", target);
42 return(ESRCH);
44 rfp = &fproc[n];
46 /* Grant target process to requestor's buffer. */
47 if ((grantid = cpf_grant_magic(rfp->fp_endpoint, who_e, buf,
48 size, CPF_WRITE)) < 0) {
49 printf("VFS: gcov_flush: grant failed\n");
50 return(ENOMEM);
53 if (rfp->fp_endpoint == VFS_PROC_NR) {
54 /* Request is for VFS itself. */
55 r = gcov_flush(grantid, size);
56 } else {
57 /* Perform generic GCOV request. */
58 m.m_lc_vfs_gcov.grant = grantid;
59 m.m_lc_vfs_gcov.buff_sz = size;
60 r = _taskcall(rfp->fp_endpoint, COMMON_REQ_GCOV_DATA, &m);
63 cpf_revoke(grantid);
65 return(r);