/*===========================================================================* * do_gcov_flush * *===========================================================================*/ PUBLIC 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; size = m_in.GCOV_BUFF_SZ; target = m_in.GCOV_PID; /* 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, (vir_bytes) m_in.GCOV_BUFF_P, 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.GCOV_GRANT = grantid; m.GCOV_BUFF_SZ = size; r = _taskcall(rfp->fp_endpoint, COMMON_REQ_GCOV_DATA, &m); } cpf_revoke(grantid); return(r); }
/*===========================================================================* * req_getdents * *===========================================================================*/ PUBLIC int req_getdents( endpoint_t fs_e, ino_t inode_nr, u64_t pos, char *buf, size_t size, u64_t *new_pos, int direct ) { int r; message m; cp_grant_id_t grant_id; if (direct) { grant_id = cpf_grant_direct(fs_e, (vir_bytes) buf, size, CPF_WRITE); } else { grant_id = cpf_grant_magic(fs_e, who_e, (vir_bytes) buf, size, CPF_WRITE); } if (grant_id < 0) panic("req_getdents: cpf_grant_direct/cpf_grant_magic failed: %d", grant_id); m.m_type = REQ_GETDENTS; m.REQ_INODE_NR = inode_nr; m.REQ_GRANT = grant_id; m.REQ_MEM_SIZE = size; m.REQ_SEEK_POS_LO = ex64lo(pos); m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ r = fs_sendrec(fs_e, &m); cpf_revoke(grant_id); if (r == OK) { *new_pos = cvul64(m.RES_SEEK_POS_LO); r = m.RES_NBYTES; } return(r); }
/*===========================================================================* * req_statvfs * *===========================================================================*/ PUBLIC int req_statvfs(int fs_e, int who_e, char *buf) { int r; cp_grant_id_t grant_id; message m; grant_id = cpf_grant_magic(fs_e, who_e, (vir_bytes) buf, sizeof(struct statvfs), CPF_WRITE); if(grant_id == -1) panic("req_statvfs: cpf_grant_magic failed"); /* Fill in request message */ m.m_type = REQ_STATVFS; m.REQ_GRANT = grant_id; /* Send/rec request */ r = fs_sendrec(fs_e, &m); cpf_revoke(grant_id); return(r); }
/*===========================================================================* * req_statvfs * *===========================================================================*/ int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) { int r; cp_grant_id_t grant_id; message m; grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct statvfs), CPF_WRITE); if(grant_id == GRANT_INVALID) panic("req_statvfs: cpf_grant_magic failed"); /* Fill in request message */ m.m_type = REQ_STATVFS; m.REQ_GRANT = grant_id; /* Send/rec request */ r = fs_sendrec(fs_e, &m); cpf_revoke(grant_id); return(r); }
/*===========================================================================* * req_breadwrite * *===========================================================================*/ PUBLIC int req_breadwrite( endpoint_t fs_e, endpoint_t user_e, dev_t dev, u64_t pos, unsigned int num_of_bytes, char *user_addr, int rw_flag, u64_t *new_posp, unsigned int *cum_iop ) { int r; cp_grant_id_t grant_id; message m; grant_id = cpf_grant_magic(fs_e, user_e, (vir_bytes) user_addr, num_of_bytes, (rw_flag == READING ? CPF_WRITE : CPF_READ)); if(grant_id == -1) panic("req_breadwrite: cpf_grant_magic failed"); /* Fill in request message */ m.m_type = rw_flag == READING ? REQ_BREAD : REQ_BWRITE; m.REQ_DEV2 = dev; m.REQ_GRANT = grant_id; m.REQ_SEEK_POS_LO = ex64lo(pos); m.REQ_SEEK_POS_HI = ex64hi(pos); m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ r = fs_sendrec(fs_e, &m); cpf_revoke(grant_id); if (r != OK) return(r); /* Fill in response structure */ *new_posp = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); *cum_iop = m.RES_NBYTES; return(OK); }