struct file *rcv_faf_file_desc(struct rpc_desc *desc) { int r, first_import; void *fdesc; int fdesc_size; long fobjid; struct dvfs_file_struct *dvfs_file = NULL; struct file *file = NULL; r = rpc_unpack_type(desc, fobjid); if (r) goto error; r = rpc_unpack_type(desc, fdesc_size); if (r) goto error; fdesc = kmalloc(GFP_KERNEL, fdesc_size); if (!fdesc) { r = -ENOMEM; goto error; } r = rpc_unpack(desc, 0, fdesc, fdesc_size); if (r) goto err_free_desc; /* Check if the file struct is already present */ first_import = 0; file = begin_import_dvfs_file(fobjid, &dvfs_file); if (!file) { file = create_faf_file_from_krg_desc(current, fdesc); first_import = 1; } r = end_import_dvfs_file(fobjid, dvfs_file, file, first_import); if (r) goto err_free_desc; err_free_desc: kfree(fdesc); error: if (r) file = ERR_PTR(r); return file; }
static int __cr_link_to_file(struct epm_action *action, ghost_t *ghost, struct task_struct *task, struct cr_file_link *file_link, struct file **returned_file) { int r = 0; if (!file_link) { BUG(); r = -E_CR_BADDATA; goto exit; } BUG_ON(file_link->desc_type == CR_FILE_NONE); if (file_link->desc_type != CR_FILE_POINTER && file_link->desc_type != CR_FILE_REGULAR_DESC && file_link->desc_type != CR_FILE_FAF_DESC) { BUG(); r = -E_CR_BADDATA; goto exit; } if (file_link->desc_type == CR_FILE_POINTER) { *returned_file = file_link->desc; get_file(*returned_file); } else { struct file *file; struct dvfs_file_struct *dvfs_file; int first_import = 0; file_link->desc = &file_link[1]; /* Check if the file struct is already present */ file = begin_import_dvfs_file(file_link->dvfs_objid, &dvfs_file); /* the file is not yet opened on this node */ if (!file) { #ifdef CONFIG_KRG_FAF if (file_link->desc_type == CR_FILE_FAF_DESC) file = create_faf_file_from_krg_desc( task, file_link->desc); else #endif file = import_regular_file_from_krg_desc( action, task, file_link->desc); first_import = 1; } r = end_import_dvfs_file(file_link->dvfs_objid, dvfs_file, file, first_import); if (r) goto exit; BUG_ON(file->f_objid != file_link->dvfs_objid); *returned_file = file; } exit: return r; }