/** Initiate removal of a specific file system object. */ PVFS_error PVFS_imgmt_remove_object( PVFS_object_ref object_ref, PVFS_credentials *credentials, PVFS_sys_op_id *op_id, PVFS_hint hints, void *user_ptr) { PVFS_error ret = -PVFS_EINVAL; PINT_smcb *smcb = NULL; PINT_client_sm *sm_p = NULL; gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_imgmt_remove_object entered\n"); if ((object_ref.handle == PVFS_HANDLE_NULL) || (object_ref.fs_id == PVFS_FS_ID_NULL)) { return ret; } PINT_smcb_alloc(&smcb, PVFS_MGMT_REMOVE_OBJECT, sizeof(struct PINT_client_sm), client_op_state_get_machine, client_state_machine_terminate, pint_client_sm_context); if (smcb == NULL) { return -PVFS_ENOMEM; } sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PINT_init_msgarray_params(sm_p, object_ref.fs_id); PINT_init_sysint_credentials(sm_p->cred_p, credentials); sm_p->object_ref = object_ref; PVFS_hint_copy(hints, &sm_p->hints); gossip_debug( GOSSIP_CLIENT_DEBUG, "Trying to remove handle %llu,%d\n", llu(object_ref.handle), object_ref.fs_id); gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_imgmt_remove_object calling " "PINT_client_state_machine_post()\n"); return PINT_client_state_machine_post( smcb, op_id, user_ptr); }
/* given mount information, retrieve the server's configuration by issuing a getconfig operation. on successful response, we parse the configuration and fill in the config object specified. returns 0 on success, -errno on error */ int PVFS_mgmt_get_config( const PVFS_fs_id * fsid, PVFS_BMI_addr_t * addr, char *fs_buf, int fs_buf_size) { int ret = -PVFS_EINVAL; PINT_smcb *smcb = NULL; PINT_client_sm *sm_p = NULL; PVFS_error error = 0; PVFS_credentials creds; struct filesystem_configuration_s *cur_fs = NULL; PVFS_sys_op_id op_id; struct server_configuration_s *config = NULL; struct PVFS_sys_mntent mntent; int server_type = 0; gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_config entered\n"); PVFS_util_gen_credentials(&creds); PINT_smcb_alloc(&smcb, PVFS_SERVER_GET_CONFIG, sizeof(struct PINT_client_sm), client_op_state_get_machine, client_state_machine_terminate, pint_client_sm_context); if(smcb == NULL) { return -PVFS_ENOMEM; } sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); sm_p->u.get_config.persist_config_buffers = 1; PINT_init_msgarray_params(sm_p, *fsid); PINT_init_sysint_credentials(sm_p->cred_p, &creds); config = PINT_get_server_config_struct(*fsid); mntent.the_pvfs_config_server = (char*)PINT_cached_config_map_addr(*fsid, *addr, &server_type); PINT_put_server_config_struct(config); cur_fs = PINT_config_find_fs_id(config, *fsid); mntent.encoding = cur_fs->encoding; mntent.flowproto = cur_fs->flowproto; mntent.fs_id = *fsid; mntent.pvfs_fs_name = cur_fs->file_system_name; sm_p->u.get_config.config = config; sm_p->msgarray_op.msgpair.enc_type = cur_fs->encoding; sm_p->u.get_config.mntent = &mntent; PINT_msgpair_init(&sm_p->msgarray_op); ret = PINT_client_state_machine_post( smcb, &op_id, NULL); if (ret) { PVFS_perror_gossip("PINT_client_state_machine_post call", ret); error = ret; } else { ret = PVFS_mgmt_wait(op_id, "X-get_config", &error); if (ret) { PVFS_perror_gossip("PVFS_mgmt_wait call", ret); error = ret; } } if (error) { goto exit_path; } gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_get_config completed\n"); /* make sure strings will be null terminated after strncpy */ fs_buf[fs_buf_size-1] = '\0'; /* The following copies the retrieved configuration buffers into the return buffers */ strncpy(fs_buf, sm_p->u.get_config.fs_config_buf, (fs_buf_size - 1)); exit_path: if (sm_p && sm_p->u.get_config.persist_config_buffers) { free(sm_p->u.get_config.fs_config_buf); sm_p->u.get_config.fs_config_buf = NULL; } PINT_mgmt_release(op_id); return error; }
/** Initiate modification of attributes of a single object. */ PVFS_error PVFS_isys_setattr( PVFS_object_ref ref, PVFS_sys_attr attr, const PVFS_credentials *credentials, PVFS_sys_op_id *op_id, PVFS_hint hints, void *user_ptr) { PVFS_error ret = -PVFS_EINVAL; PINT_smcb *smcb = NULL; PINT_client_sm *sm_p = NULL; gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_isys_setattr entered\n"); if ((ref.handle == PVFS_HANDLE_NULL) || (ref.fs_id == PVFS_FS_ID_NULL)) { gossip_err("invalid (NULL) required argument\n"); return ret; } /* * make sure the caller didn't set invalid mask bits. * only common attributes can be set. */ if ((attr.mask & ~PVFS_ATTR_SYS_ALL_TIMES) != 0) { gossip_lerr("PVFS_isys_setattr() failure: invalid attributes " "specified\n"); return ret; } /* make sure that the permission bits are acceptable */ if ((attr.mask & PVFS_ATTR_SYS_PERM) && (attr.perms & ~PVFS_PERM_VALID) != 0) { gossip_lerr("PVFS_isys_setattr() failure: invalid or unsupported" "permission bits\n"); return(-PVFS_EINVAL); } PINT_smcb_alloc(&smcb, PVFS_SYS_SETATTR, sizeof(struct PINT_client_sm), client_op_state_get_machine, client_state_machine_terminate, pint_client_sm_context); if (smcb == NULL) { return -PVFS_ENOMEM; } sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PINT_init_msgarray_params(sm_p, ref.fs_id); PINT_init_sysint_credentials(sm_p->cred_p, credentials); sm_p->object_ref = ref; PVFS_hint_copy(hints, &sm_p->hints); PVFS_hint_add(&sm_p->hints, PVFS_HINT_HANDLE_NAME, sizeof(PVFS_handle), &ref.handle); ret = PVFS_util_copy_sys_attr(&sm_p->u.setattr.sys_attr, &attr); if(ret < 0) { gossip_lerr("PVFS_isys_setattr() failure: %s\n", strerror(PVFS_get_errno_mapping(-ret))); return ret; } gossip_debug(GOSSIP_CLIENT_DEBUG, "Doing setattr on handle %llu " "on fs %d\n", llu(ref.handle), ref.fs_id); return PINT_client_state_machine_post( smcb, op_id, user_ptr); }
/** Initiate reading of entries from a directory. * * \param token opaque value used to track position in directory * when more than one read is required. * \param pvfs_dirent_incount maximum number of entries to read, if * available, starting from token. */ PVFS_error PVFS_isys_readdir( PVFS_object_ref ref, PVFS_ds_position token, int32_t pvfs_dirent_incount, const PVFS_credentials *credentials, PVFS_sysresp_readdir *resp, PVFS_sys_op_id *op_id, PVFS_hint hints, void *user_ptr) { PVFS_error ret = -PVFS_EINVAL; PINT_smcb *smcb = NULL; PINT_client_sm *sm_p = NULL; gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_isys_readdir entered\n"); if ((ref.handle == PVFS_HANDLE_NULL) || (ref.fs_id == PVFS_FS_ID_NULL) || (resp == NULL)) { gossip_err("invalid (NULL) required argument\n"); return ret; } if (pvfs_dirent_incount > PVFS_REQ_LIMIT_DIRENT_COUNT) { gossip_lerr("PVFS_isys_readdir unable to handle request " "for %d entries.\n", pvfs_dirent_incount); return ret; } PINT_smcb_alloc(&smcb, PVFS_SYS_READDIR, sizeof(struct PINT_client_sm), client_op_state_get_machine, client_state_machine_terminate, pint_client_sm_context); if (smcb == NULL) { return -PVFS_ENOMEM; } sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PINT_init_msgarray_params(sm_p, ref.fs_id); PINT_init_sysint_credentials(sm_p->cred_p, credentials); sm_p->u.readdir.readdir_resp = resp; sm_p->object_ref = ref; PVFS_hint_copy(hints, &sm_p->hints); PVFS_hint_add(&sm_p->hints, PVFS_HINT_HANDLE_NAME, sizeof(PVFS_handle), &ref.handle); /* point the sm dirent array and outcount to the readdir response field */ sm_p->readdir.dirent_array = &resp->dirent_array; sm_p->readdir.dirent_outcount = &resp->pvfs_dirent_outcount; sm_p->readdir.token = &resp->token; sm_p->readdir.directory_version = &resp->directory_version; sm_p->readdir.pos_token = sm_p->u.readdir.pos_token = token; sm_p->readdir.dirent_limit = sm_p->u.readdir.dirent_limit = pvfs_dirent_incount; gossip_debug(GOSSIP_READDIR_DEBUG, "Doing readdir on handle " "%llu on fs %d\n", llu(ref.handle), ref.fs_id); return PINT_client_state_machine_post( smcb, op_id, user_ptr); }