static struct izo_upcall_hdr *upc_pack(__u32 opcode, int pathlen, char *path, char *fsetname, int reclen, char *rec, int *size) { struct izo_upcall_hdr *hdr; char *ptr; ENTRY; *size = sizeof(struct izo_upcall_hdr); if ( fsetname ) { *size += round_strlen(fsetname); } if ( path ) { *size += round_strlen(path); } if ( rec ) { *size += size_round(reclen); } PRESTO_ALLOC(hdr, *size); if (!hdr) { CERROR("intermezzo upcall: out of memory (opc %d)\n", opcode); EXIT; return NULL; } memset(hdr, 0, *size); ptr = (char *)hdr + sizeof(*hdr); /* XXX do we need fsuid ? */ hdr->u_len = *size; hdr->u_version = IZO_UPC_VERSION; hdr->u_opc = opcode; hdr->u_pid = current->pid; hdr->u_uid = current->fsuid; if (path) { /*XXX Robert: please review what len to pass in for NUL terminated strings */ hdr->u_pathlen = strlen(path); LOGL0(path, hdr->u_pathlen, ptr); } if (fsetname) { hdr->u_fsetlen = strlen(fsetname); LOGL0(fsetname, strlen(fsetname), ptr); } if (rec) { hdr->u_reclen = reclen; LOGL(rec, reclen, ptr); } EXIT; return hdr; }
void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_link *rec; char *tmp; CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_link)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); LASSERT (rec != NULL); rec->lk_opcode = REINT_LINK; rec->lk_fsuid = op_data->op_fsuid;//current->fsuid; rec->lk_fsgid = op_data->op_fsgid;//current->fsgid; rec->lk_cap = op_data->op_cap;//current->cap_effective; rec->lk_suppgid1 = op_data->op_suppgids[0]; rec->lk_suppgid2 = op_data->op_suppgids[1]; rec->lk_fid1 = op_data->op_fid1; rec->lk_fid2 = op_data->op_fid2; rec->lk_time = op_data->op_mod_time; rec->lk_bias = op_data->op_bias; mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); mdc_pack_capa(req, &RMF_CAPA2, op_data->op_capa2); tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LOGL0(op_data->op_name, op_data->op_namelen, tmp); }
void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_unlink *rec; char *tmp; CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_unlink)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); LASSERT(rec != NULL); rec->ul_opcode = op_data->op_cli_flags & CLI_RM_ENTRY ? REINT_RMENTRY : REINT_UNLINK; rec->ul_fsuid = op_data->op_fsuid; rec->ul_fsgid = op_data->op_fsgid; rec->ul_cap = op_data->op_cap; rec->ul_mode = op_data->op_mode; rec->ul_suppgid1= op_data->op_suppgids[0]; rec->ul_suppgid2= -1; rec->ul_fid1 = op_data->op_fid1; rec->ul_fid2 = op_data->op_fid2; rec->ul_time = op_data->op_mod_time; rec->ul_bias = op_data->op_bias; mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LASSERT(tmp != NULL); LOGL0(op_data->op_name, op_data->op_namelen, tmp); }
/* packing of MDS records */ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, __u32 mode, __u64 rdev, __u64 flags, const void *lmm, int lmmlen) { struct mdt_rec_create *rec; char *tmp; __u64 cr_flags; CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); /* XXX do something about time, uid, gid */ rec->cr_opcode = REINT_OPEN; rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid()); rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->cr_cap = cfs_curproc_cap_pack(); if (op_data != NULL) { rec->cr_fid1 = op_data->op_fid1; rec->cr_fid2 = op_data->op_fid2; } rec->cr_mode = mode; cr_flags = mds_pack_open_flags(flags, mode); rec->cr_rdev = rdev; rec->cr_time = op_data->op_mod_time; rec->cr_suppgid1 = op_data->op_suppgids[0]; rec->cr_suppgid2 = op_data->op_suppgids[1]; rec->cr_bias = op_data->op_bias; rec->cr_umask = current_umask(); rec->cr_old_handle = op_data->op_handle; mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); /* the next buffer is child capa, which is used for replay, * will be packed from the data in reply message. */ if (op_data->op_name) { tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LOGL0(op_data->op_name, op_data->op_namelen, tmp); if (op_data->op_bias & MDS_CREATE_VOLATILE) cr_flags |= MDS_OPEN_VOLATILE; } if (lmm) { cr_flags |= MDS_OPEN_HAS_EA; tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA); memcpy(tmp, lmm, lmmlen); } set_mrc_cr_flags(rec, cr_flags); }
/* packing of MDS records */ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, const void *data, int datalen, __u32 mode, __u32 uid, __u32 gid, cfs_cap_t cap_effective, __u64 rdev) { struct mdt_rec_create *rec; char *tmp; __u64 flags; CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->cr_opcode = REINT_CREATE; rec->cr_fsuid = uid; rec->cr_fsgid = gid; rec->cr_cap = cap_effective; rec->cr_fid1 = op_data->op_fid1; rec->cr_fid2 = op_data->op_fid2; rec->cr_mode = mode; rec->cr_rdev = rdev; rec->cr_time = op_data->op_mod_time; rec->cr_suppgid1 = op_data->op_suppgids[0]; rec->cr_suppgid2 = op_data->op_suppgids[1]; flags = op_data->op_flags & MF_SOM_LOCAL_FLAGS; if (op_data->op_bias & MDS_CREATE_VOLATILE) flags |= MDS_OPEN_VOLATILE; set_mrc_cr_flags(rec, flags); rec->cr_bias = op_data->op_bias; rec->cr_umask = current_umask(); mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LOGL0(op_data->op_name, op_data->op_namelen, tmp); if (data) { tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA); memcpy(tmp, data, datalen); } }