7 /*===========================================================================*
9 *===========================================================================*/
10 int do_gcov_flush(void)
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
18 char label
[LABEL_MAX
];
19 vir_bytes labeladdr
, buf
;
20 size_t labellen
, size
;
22 cp_grant_id_t grantid
;
27 * Something as sensitive as system service coverage information must be
28 * call to the target service, and so it is not impossible to deadlock the
29 * system with this call.
31 if (!super_user
) return(EPERM
);
33 labeladdr
= job_m_in
.m_lc_vfs_gcov
.label
;
34 labellen
= job_m_in
.m_lc_vfs_gcov
.labellen
;
35 buf
= job_m_in
.m_lc_vfs_gcov
.buf
;
36 size
= job_m_in
.m_lc_vfs_gcov
.buflen
;
38 /* Retrieve and look up the target label. */
39 if (labellen
>= sizeof(label
))
41 if ((r
= sys_datacopy_wrapper(who_e
, labeladdr
, SELF
, (vir_bytes
)label
,
44 label
[labellen
- 1] = '\0';
46 if ((r
= ds_retrieve_label_endpt(label
, &endpt
)) != OK
)
49 /* Hack: init is the only non-system process with a valid label. */
50 if (endpt
== INIT_PROC_NR
)
53 /* Grant target process to requestor's buffer. */
54 if ((grantid
= cpf_grant_magic(endpt
, who_e
, buf
, size
, CPF_WRITE
)) < 0) {
55 printf("VFS: gcov_flush: grant failed\n");
59 if (endpt
== VFS_PROC_NR
) {
60 /* Request is for VFS itself. */
61 r
= gcov_flush(VFS_PROC_NR
, grantid
, size
);
63 /* Perform generic GCOV request. */
64 memset(&m
, 0, sizeof(m
));
65 m
.m_vfs_lsys_gcov
.grant
= grantid
;
66 m
.m_vfs_lsys_gcov
.size
= size
;
67 r
= _taskcall(endpt
, COMMON_REQ_GCOV_DATA
, &m
);