fsal_status_t XFSFSAL_GetClientContext(xfsfsal_op_context_t * p_thr_context, /* IN/OUT */ xfsfsal_export_context_t * p_export_context, /* IN */ fsal_uid_t uid, /* IN */ fsal_gid_t gid, /* IN */ fsal_gid_t * alt_groups, /* IN */ fsal_count_t nb_alt_groups /* IN */ ) { fsal_count_t ng = nb_alt_groups; unsigned int i; /* sanity check */ if(!p_thr_context || !p_export_context) Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext); /* set the export specific context */ p_thr_context->export_context = p_export_context; /* Extracted from /opt/hpss/src/nfs/nfsd/nfs_Dispatch.c */ p_thr_context->credential.user = uid; p_thr_context->credential.group = gid; if(ng > FSAL_NGROUPS_MAX) ng = FSAL_NGROUPS_MAX; if((ng > 0) && (alt_groups == NULL)) Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext); p_thr_context->credential.nbgroups = ng; for(i = 0; i < ng; i++) p_thr_context->credential.alt_groups[i] = alt_groups[i]; if(isFullDebug(COMPONENT_FSAL)) { /* traces: prints p_credential structure */ LogFullDebug(COMPONENT_FSAL, "credential modified:"); LogFullDebug(COMPONENT_FSAL, "\tuid = %d, gid = %d", p_thr_context->credential.user, p_thr_context->credential.group); if (isFullDebug(COMPONENT_FSAL)) { for(i = 0; i < p_thr_context->credential.nbgroups; i++) LogFullDebug(COMPONENT_FSAL, "\tAlt grp: %d", p_thr_context->credential.alt_groups[i]); } } Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetClientContext); }
/** * fsal_internal_proxy_create_fh : * * * @param pnfs4_handle [IN] the NFSv4 Handle * @param type [IN] the type of object for this entry * @param fileid [IN] the file id for this entry * @param pfsal_handle [OUT] the resulting FSAL Handle * * @return TRUE if OK, FALSE otherwise * */ int fsal_internal_proxy_create_fh(nfs_fh4 * pnfs4_handle, fsal_nodetype_t type, fsal_u64_t fileid, fsal_handle_t * fsal_handle) { proxyfsal_handle_t * pfsal_handle = (proxyfsal_handle_t *) fsal_handle; if(pnfs4_handle == NULL || pfsal_handle == NULL) return FALSE; if(isFullDebug(COMPONENT_FSAL)) { char outstr[1024]; nfs4_sprint_fhandle(pnfs4_handle, outstr); LogFullDebug(COMPONENT_FSAL, "fsal_internal_proxy_create_fh: input nfsv4 server handle=%s", outstr); } memset( (char *)pfsal_handle, 0, sizeof( proxyfsal_handle_t ) ) ; pfsal_handle->data.object_type_reminder = type; pfsal_handle->data.fileid4 = fileid; pfsal_handle->data.timestamp = /** @todo fh should be volatile ? ServerBootTime ; */ 0; pfsal_handle->data.srv_handle_len = pnfs4_handle->nfs_fh4_len; memset(pfsal_handle->data.srv_handle_val, 0, FSAL_PROXY_FILEHANDLE_MAX_LEN); memcpy(pfsal_handle->data.srv_handle_val, pnfs4_handle->nfs_fh4_val, pnfs4_handle->nfs_fh4_len); if(isFullDebug(COMPONENT_FSAL)) { char outstr[1024]; if(type == FSAL_TYPE_FILE) { nfs_fh4 tmpfh; tmpfh.nfs_fh4_len = pfsal_handle->data.srv_handle_len; tmpfh.nfs_fh4_val = pfsal_handle->data.srv_handle_val; nfs4_sprint_fhandle(&tmpfh, outstr); LogFullDebug(COMPONENT_FSAL, "fsal_internal_proxy_create_fh: output nfsv4 server handle= %s fileid=%llu", outstr, fileid); } if(memcmp (pfsal_handle->data.srv_handle_val, pnfs4_handle->nfs_fh4_val, pnfs4_handle->nfs_fh4_len)) LogFullDebug(COMPONENT_FSAL, "CRITICAL ERROR: ==========> Filehandle mismatch n ifsal_internal_proxy_create"); } return TRUE; } /* fsal_internal_proxy_create_fh */
int compare_9p_owner(state_owner_t *owner1, state_owner_t *owner2) { if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_9p_owner(owner1, str1); display_9p_owner(owner2, str2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (owner1 == NULL || owner2 == NULL) return 1; if (owner1 == owner2) return 0; if (owner1->so_owner.so_9p_owner.proc_id != owner2->so_owner.so_9p_owner.proc_id) return 1; #if 0 if (memcmp (&owner1->so_owner.so_9p_owner.client_addr, &owner2->so_owner.so_9p_owner.client_addr, sizeof(struct sockaddr_storage))) return 1; #endif if (owner1->so_owner_len != owner2->so_owner_len) return 1; return memcmp(owner1->so_owner_val, owner2->so_owner_val, owner1->so_owner_len); }
/** * @brief Update stateid and set current * * We increment the seqid, handling wraparound, and copy the id into * the response. * * @param[in,out] state State to update * @param[out] resp Stateid in response * @param[in,out] data Compound data to upddate with current stateid * (may be NULL) * @param[in] tag Arbitrary text for debug/log */ void update_stateid(state_t *state, stateid4 *resp, compound_data_t *data, const char *tag) { /* Increment state_seqid, handling wraparound */ state->state_seqid += 1; if (state->state_seqid == 0) state->state_seqid = 1; /* Copy stateid into current for later use */ if (data) { COPY_STATEID(&data->current_stateid, state); data->current_stateid_valid = true; } /* Copy stateid into response */ COPY_STATEID(resp, state); if (isFullDebug(COMPONENT_STATE)) { char str[OTHERSIZE * 2 + 1 + 6]; sprint_mem(str, (char *)state->stateid_other, OTHERSIZE); sprintf(str + OTHERSIZE * 2, ":%u", (unsigned int)state->state_seqid); LogDebug(COMPONENT_STATE, "Update %s stateid to %s for response", tag, str); } }
static void nlm4_unlock_message_resp(state_async_queue_t *arg) { state_nlm_async_data_t *nlm_arg = &arg->state_async_data.state_nlm_async_data; if (isFullDebug(COMPONENT_NLM)) { char buffer[1024] = "\0"; netobj_to_string(&nlm_arg->nlm_async_args.nlm_async_res. res_nlm4test.cookie, buffer, 1024); LogFullDebug(COMPONENT_NLM, "Calling nlm_send_async cookie=%s status=%s", buffer, lock_result_str(nlm_arg->nlm_async_args. nlm_async_res.res_nlm4.stat.stat)); } nlm_send_async(NLMPROC4_UNLOCK_RES, nlm_arg->nlm_async_host, &(nlm_arg->nlm_async_args.nlm_async_res), NULL); nlm4_Unlock_Free(&nlm_arg->nlm_async_args.nlm_async_res); dec_nsm_client_ref(nlm_arg->nlm_async_host->slc_nsm_client); dec_nlm_client_ref(nlm_arg->nlm_async_host); gsh_free(arg); }
/** * * nfs41_Session_Del * * This routine removes a session from the sessions's hashtable. * * @param sessionid [IN] sessionid, used as a hash key * * @return 1 if ok, 0 otherwise. * */ int nfs41_Session_Del(char sessionid[NFS4_SESSIONID_SIZE]) { hash_buffer_t buffkey, old_key, old_value; if(isFullDebug(COMPONENT_SESSIONS)) { char str[NFS4_SESSIONID_SIZE *2 + 1]; sprint_mem(str, (char *)sessionid, NFS4_SESSIONID_SIZE); LogFullDebug(COMPONENT_SESSIONS, " ----- DelSession : %s\n", str); } buffkey.pdata = (caddr_t) sessionid; buffkey.len = NFS4_SESSIONID_SIZE; if(HashTable_Del(ht_session_id, &buffkey, &old_key, &old_value) == HASHTABLE_SUCCESS) { /* free the key that was stored in hash table */ Mem_Free((void *)old_key.pdata); /* State is managed in stuff alloc, no fre is needed for old_value.pdata */ return 1; } else return 0; } /* nfs41_Session_Del */
/** * * nfs41_Session_Update * * This routine updates a session from the sessions's hashtable. * * @param psession [IN] pointer to the sessionid to be checked. * @param psession_data [IN] new session * * @return 1 if ok, 0 otherwise. * */ int nfs41_Session_Update(char sessionid[NFS4_SESSIONID_SIZE], nfs41_session_t * psession_data) { hash_buffer_t buffkey; hash_buffer_t buffval; if(isFullDebug(COMPONENT_SESSIONS)) { char str[NFS4_SESSIONID_SIZE *2 + 1]; sprint_mem(str, (char *)sessionid, NFS4_SESSIONID_SIZE); LogFullDebug(COMPONENT_SESSIONS, " ----- UpdateSession : %s\n", str); } buffkey.pdata = (caddr_t) sessionid; buffkey.len = NFS4_SESSIONID_SIZE; if(HashTable_Get(ht_session_id, &buffkey, &buffval) != HASHTABLE_SUCCESS) { LogFullDebug(COMPONENT_SESSIONS, "---> nfs41_Session_Update NOT FOUND !!!!!!\n"); return 0; } memcpy(buffval.pdata, psession_data, sizeof(nfs41_session_t)); LogFullDebug(COMPONENT_SESSIONS, "---> nfs41_Session_Update Found :-)\n"); return 1; } /* nfs41_Session_Update */
int compare_9p_owner(state_owner_t *owner1, state_owner_t *owner2) { if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_9p_owner(&dspbuf1, owner1); display_9p_owner(&dspbuf2, owner2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (owner1 == NULL || owner2 == NULL) return 1; if (owner1 == owner2) return 0; if (owner1->so_owner.so_9p_owner.proc_id != owner2->so_owner.so_9p_owner.proc_id) return 1; #if 0 if (memcmp (&owner1->so_owner.so_9p_owner.client_addr, &owner2->so_owner.so_9p_owner.client_addr, sizeof(struct sockaddr_storage))) return 1; #endif /* so_owner_len is always 0, don't compare so_owner_val */ return 0; }
/** * nlm_client_Set * * * This routine sets a NLM client into the related hashtable * * @return 1 if ok, 0 otherwise. * */ int nlm_client_Set(state_nlm_client_t * pkey, state_nlm_client_t * pclient) { hash_buffer_t buffkey; hash_buffer_t buffval; if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str[HASHTABLE_DISPLAY_STRLEN]; buffkey.pdata = (caddr_t) pkey; buffkey.len = sizeof(*pkey); display_nlm_client_key(&buffkey, str); LogFullDebug(COMPONENT_STATE, "KEY {%s}", str); } buffkey.pdata = (caddr_t) pkey; buffkey.len = sizeof(*pkey); buffval.pdata = (caddr_t) pclient; buffval.len = sizeof(*pclient); if(HashTable_Test_And_Set (ht_nlm_client, &buffkey, &buffval, HASHTABLE_SET_HOW_SET_NO_OVERWRITE) != HASHTABLE_SUCCESS) return 0; return 1; } /* nlm_client_Set */
int compare_nfs4_owner_key(hash_buffer_t * buff1, hash_buffer_t * buff2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nfs4_owner_key(buff1, str1); display_nfs4_owner_key(buff2, str2); if(isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } state_nfs4_owner_name_t *pname1 = (state_nfs4_owner_name_t *) buff1->pdata; state_nfs4_owner_name_t *pname2 = (state_nfs4_owner_name_t *) buff2->pdata; if(pname1 == NULL || pname2 == NULL) return 1; if(pname1->son_islock != pname2->son_islock) return 1; if(pname1->son_clientid != pname2->son_clientid) return 1; if(pname1->son_owner_len != pname2->son_owner_len) return 1; return memcmp(pname1->son_owner_val, pname2->son_owner_val, pname1->son_owner_len); } /* compare_nfs4_owner */
static int Hash_del_nlm_owner_ref(hash_buffer_t *buffval) { int rc; state_owner_t *powner = (state_owner_t *)(buffval->pdata); P(powner->so_mutex); powner->so_refcount--; if(isFullDebug(COMPONENT_STATE)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_nlm_owner(powner, str); LogFullDebug(COMPONENT_STATE, "Decrement refcount for NLM Owner powner=%p {%s}, refcount = %d", powner, str, powner->so_refcount); } rc = powner->so_refcount; V(powner->so_mutex); return rc; }
/** * @brief Check the consistency between two fsal_posixdb_fileinfo_t * * @param p_info1 * @param p_info2 * * @return 0 if the two fsal_posixdb_fileinfo_t are consistent * another value else (or on error) */ int fsal_posixdb_consistency_check(fsal_posixdb_fileinfo_t * p_info1, /* IN */ fsal_posixdb_fileinfo_t * p_info2 /* IN */ ) { int out = 0; if(!p_info1 || !p_info2) return -1; if(isFullDebug(COMPONENT_FSAL)) { if(p_info1->inode != p_info2->inode) LogFullDebug(COMPONENT_FSAL, "inode 1 <> inode 2 : %llu != %llu\n", p_info1->inode, p_info2->inode); if(p_info1->devid != p_info2->devid) LogFullDebug(COMPONENT_FSAL, "devid 1 <> devid 2 : %llu != %llu\n", p_info1->devid, p_info2->devid); if(p_info1->ftype != p_info2->ftype) LogFullDebug(COMPONENT_FSAL, "ftype 1 <> ftype 2 : %u != %u\n", p_info1->ftype, p_info2->ftype); } out |= (p_info1->inode && p_info2->inode) && (p_info1->inode != p_info2->inode); out |= (p_info1->devid && p_info2->devid) && (p_info1->devid != p_info2->devid); out |= (p_info1->ftype && p_info2->ftype) && (p_info1->ftype != p_info2->ftype); return out; }
unsigned long session_id_rbt_hash_func(hash_parameter_t * p_hparam, hash_buffer_t * buffclef) { u_int32_t i1 = 0; u_int32_t i2 = 0; u_int32_t i3 = 0; u_int32_t i4 = 0; if(isFullDebug(COMPONENT_SESSIONS)) { char str[NFS4_SESSIONID_SIZE *2 + 1]; sprint_mem(str, (char *)buffclef->pdata, NFS4_SESSIONID_SIZE); LogFullDebug(COMPONENT_SESSIONS, " ----- session_id_rbt_hash_func : %s\n", str); } memcpy(&i1, &(buffclef->pdata[0]), sizeof(u_int32_t)); memcpy(&i2, &(buffclef->pdata[4]), sizeof(u_int32_t)); memcpy(&i3, &(buffclef->pdata[8]), sizeof(u_int32_t)); memcpy(&i4, &(buffclef->pdata[12]), sizeof(u_int32_t)); LogFullDebug(COMPONENT_SESSIONS, "---> session_id_rbt_hash_func=%lu\n", (unsigned long)(i1 ^ i2 ^ i3)); return (unsigned long)(i1 ^ i2 ^ i3 | i4); } /* session_id_rbt_hash_func */
/** * @brief Compare two NFSv4 owners in the hash table * * @param[in] buff1 One key * @param[in] buff2 Another owner * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nfs4_owner_key(struct gsh_buffdesc *buff1, struct gsh_buffdesc *buff2) { state_owner_t *pkey1 = buff1->addr; state_owner_t *pkey2 = buff2->addr; if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_owner(&dspbuf1, pkey1); display_owner(&dspbuf2, pkey2); if (isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (pkey1 == NULL || pkey2 == NULL) return 1; if (pkey1->so_type != pkey2->so_type) return 1; return compare_nfs4_owner(pkey1, pkey2); }
/** * @brief Returns the mount list * * @return The mount list */ mountlist nfs_Get_MountList(void) { if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); return MNT_List_head; }
/** * @brief Compare two NFSv4 owners * * @param[in] owner1 One owner * @param[in] owner2 Another owner * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nfs4_owner(state_owner_t *owner1, state_owner_t *owner2) { if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_nfs4_owner(&dspbuf1, owner1); display_nfs4_owner(&dspbuf2, owner2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (owner1 == NULL || owner2 == NULL) return 1; if (owner1 == owner2) return 0; if (owner1->so_type != owner2->so_type) return 1; if (owner1->so_owner.so_nfs4_owner.so_clientid != owner2->so_owner.so_nfs4_owner.so_clientid) return 1; if (owner1->so_owner_len != owner2->so_owner_len) return 1; return memcmp(owner1->so_owner_val, owner2->so_owner_val, owner1->so_owner_len); }
/** * @brief Compare NSM clients * * @param[in] client1 A client * @param[in] client2 Another client * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nsm_client(state_nsm_client_t *client1, state_nsm_client_t *client2) { if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_nsm_client(&dspbuf1, client1); display_nsm_client(&dspbuf2, client2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (client1 == NULL || client2 == NULL) return 1; if (client1 == client2) return 0; if (!nfs_param.core_param.nsm_use_caller_name) { if (client1->ssc_client != client2->ssc_client) return 1; return 0; } if (client1->ssc_nlm_caller_name_len != client2->ssc_nlm_caller_name_len) return 1; return memcmp(client1->ssc_nlm_caller_name, client2->ssc_nlm_caller_name, client1->ssc_nlm_caller_name_len); }
/** * * nsm_client_Get_Pointer * * This routine gets a pointer to an NSM client from the nsm_client's hashtable. * * @param pstate [IN] pointer to the stateid to be checked. * @param ppstate_data [OUT] pointer's state found * * @return 1 if ok, 0 otherwise. * */ int nsm_client_Get_Pointer(state_nsm_client_t * pkey, state_nsm_client_t * *pclient) { hash_buffer_t buffkey; hash_buffer_t buffval; buffkey.pdata = (caddr_t) pkey; buffkey.len = sizeof(*pkey); if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_nsm_client_key(&buffkey, str); LogFullDebug(COMPONENT_STATE, "KEY {%s}", str); } if(HashTable_GetRef(ht_nsm_client, &buffkey, &buffval, Hash_inc_nsm_client_ref) != HASHTABLE_SUCCESS) { LogFullDebug(COMPONENT_STATE, "NOTFOUND"); *pclient = NULL; return 0; } *pclient = (state_nsm_client_t *) buffval.pdata; LogFullDebug(COMPONENT_STATE, "FOUND"); return 1; } /* nsm_client_Get_Pointer */
int compare_nsm_client(state_nsm_client_t *pclient1, state_nsm_client_t *pclient2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nsm_client(pclient1, str1); display_nsm_client(pclient2, str2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if(pclient1 == NULL || pclient2 == NULL) return 1; if(pclient1 == pclient2) return 0; if(!nfs_param.core_param.nsm_use_caller_name) { if(cmp_sockaddr(&pclient1->ssc_client_addr, &pclient2->ssc_client_addr, IGNORE_PORT) == 0) return 1; return 0; } if(pclient1->ssc_nlm_caller_name_len != pclient2->ssc_nlm_caller_name_len) return 1; return memcmp(pclient1->ssc_nlm_caller_name, pclient2->ssc_nlm_caller_name, pclient1->ssc_nlm_caller_name_len); }
static void fsal_print_access_by_acl(int naces, int ace_number, fsal_ace_t *pace, fsal_aceperm_t perm, enum fsal_errors_t access_result, bool is_dir, struct user_cred *creds) { char str[LOG_BUFF_LEN]; struct display_buffer dspbuf = { sizeof(str), str, str }; int b_left; if (!isFullDebug(COMPONENT_NFS_V4_ACL)) return; if (access_result == ERR_FSAL_NO_ERROR) b_left = display_cat(&dspbuf, "access granted"); else if (access_result == ERR_FSAL_PERM) b_left = display_cat(&dspbuf, "access denied (EPERM)"); else b_left = display_cat(&dspbuf, "access denied (EACCESS)"); if (b_left > 0) b_left = display_printf(&dspbuf, " uid %u gid %u Access req:", creds->caller_uid, creds->caller_gid); if (b_left > 0) b_left = display_fsal_v4mask(&dspbuf, perm, is_dir); if (b_left > 0 && (naces != ace_number)) b_left = display_fsal_ace(&dspbuf, ace_number, pace, is_dir); LogFullDebug(COMPONENT_NFS_V4_ACL, "%s", str); }
int compare_nlm_client(state_nlm_client_t *pclient1, state_nlm_client_t *pclient2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nlm_client(pclient1, str1); display_nlm_client(pclient2, str2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if(pclient1 == NULL || pclient2 == NULL) return 1; if(pclient1 == pclient2) return 0; if(compare_nsm_client(pclient1->slc_nsm_client, pclient2->slc_nsm_client) != 0) return 1; if(pclient1->slc_client_type != pclient2->slc_client_type) return 1; if(pclient1->slc_nlm_caller_name_len != pclient2->slc_nlm_caller_name_len) return 1; return memcmp(pclient1->slc_nlm_caller_name, pclient2->slc_nlm_caller_name, pclient1->slc_nlm_caller_name_len); }
static int Hash_dec_nlm_client_ref(hash_buffer_t *buffval) { int rc; state_nlm_client_t *pclient = (state_nlm_client_t *)(buffval->pdata); P(pclient->slc_mutex); pclient->slc_refcount--; if(isFullDebug(COMPONENT_STATE)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_nlm_client(pclient, str); LogFullDebug(COMPONENT_STATE, "Decrement refcount NLM Client {%s}", str); } rc = pclient->slc_refcount; V(pclient->slc_mutex); return rc; }
/** * * nfs41_Session_Set * * This routine sets a session into the sessions's hashtable. * * @param psession [IN] pointer to the sessionid to be checked. * * @return 1 if ok, 0 otherwise. * */ int nfs41_Session_Set(char sessionid[NFS4_SESSIONID_SIZE], nfs41_session_t * psession_data) { hash_buffer_t buffkey; hash_buffer_t buffval; if(isFullDebug(COMPONENT_SESSIONS)) { char str[NFS4_SESSIONID_SIZE *2 + 1]; sprint_mem(str, (char *)sessionid, NFS4_SESSIONID_SIZE); LogFullDebug(COMPONENT_SESSIONS, " ----- SetSSession : %s\n", str); } if((buffkey.pdata = (caddr_t) Mem_Alloc(NFS4_SESSIONID_SIZE)) == NULL) return 0; memcpy(buffkey.pdata, sessionid, NFS4_SESSIONID_SIZE); buffkey.len = NFS4_SESSIONID_SIZE; buffval.pdata = (caddr_t) psession_data; buffval.len = sizeof(nfs41_session_t); if(HashTable_Test_And_Set (ht_session_id, &buffkey, &buffval, HASHTABLE_SET_HOW_SET_NO_OVERWRITE) != HASHTABLE_SUCCESS) return 0; return 1; } /* nfs41_Session_Set */
/** * @brief Purges the whole mount list * * @return true if successful, false otherwise */ bool nfs_Purge_MountList(void) { mountlist piter_mnt_list_entry __attribute__((unused)), piter_mnt_list_entry_next __attribute__((unused)); piter_mnt_list_entry = MNT_List_head; piter_mnt_list_entry_next = MNT_List_head; #ifndef _NO_MOUNT_LIST while(piter_mnt_list_entry_next != NULL) { piter_mnt_list_entry_next = piter_mnt_list_entry->ml_next; gsh_free(piter_mnt_list_entry->ml_hostname); gsh_free(piter_mnt_list_entry->ml_directory); gsh_free(piter_mnt_list_entry); piter_mnt_list_entry = piter_mnt_list_entry_next; } MNT_List_head = NULL; MNT_List_tail = NULL; if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); #endif return 1; } /* nfs_Purge_MountList */
/** * @brief Compare two NFSv4 owners in the hash table * * @param[in] buff1 One key * @param[in] buff2 Another owner * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nfs4_owner_key(struct gsh_buffdesc *buff1, struct gsh_buffdesc *buff2) { state_owner_t *pkey1 = buff1->addr; state_owner_t *pkey2 = buff2->addr; if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; DisplayOwner(pkey1, str1); DisplayOwner(pkey2, str2); if (isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (pkey1 == NULL || pkey2 == NULL) return 1; if (pkey1->so_type != pkey2->so_type) return 1; return compare_nfs4_owner(pkey1, pkey2); }
/** * * nfs_Add_MountList_Entry: Adds a client to the mount list. * * Adds a client to the mount list. * * @param hostname [IN] the hostname for the client * @param dirpath [IN] the mounted path * * @return 1 if successful, 0 otherwise * */ int nfs_Add_MountList_Entry(char *hostname, char *dirpath) { #ifndef _NO_MOUNT_LIST mountlist pnew_mnt_list_entry; #endif /* Sanity check */ if(hostname == NULL || dirpath == NULL) return 0; #ifndef _NO_MOUNT_LIST /* Allocate the new entry */ if((pnew_mnt_list_entry = gsh_calloc(1, sizeof(struct mountbody))) == NULL) return 0; if((pnew_mnt_list_entry->ml_hostname = gsh_calloc(1, MAXHOSTNAMELEN)) == NULL) { gsh_free(pnew_mnt_list_entry); return 0; } if((pnew_mnt_list_entry->ml_directory = gsh_calloc(1, MAXPATHLEN)) == NULL) { gsh_free(pnew_mnt_list_entry->ml_hostname); gsh_free(pnew_mnt_list_entry); return 0; } /* Copy the data */ strncpy(pnew_mnt_list_entry->ml_hostname, hostname, MAXHOSTNAMELEN); strncpy(pnew_mnt_list_entry->ml_directory, dirpath, MAXPATHLEN); /* initialize next pointer */ pnew_mnt_list_entry->ml_next = NULL; /* This should occur only for the first mount */ if(MNT_List_head == NULL) { MNT_List_head = pnew_mnt_list_entry; } /* Append to the tail of the list */ if(MNT_List_tail == NULL) MNT_List_tail = pnew_mnt_list_entry; else { MNT_List_tail->ml_next = pnew_mnt_list_entry; MNT_List_tail = pnew_mnt_list_entry; } if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); #endif return 1; } /* nfs_Add_MountList_Entry */
int nfs4_op_savefh(struct nfs_argop4 *op, compound_data_t * data, struct nfs_resop4 *resp) { int error; /* First of all, set the reply to zero to make sure it contains no parasite information */ memset(resp, 0, sizeof(struct nfs_resop4)); resp->resop = NFS4_OP_SAVEFH; resp->nfs_resop4_u.opsavefh.status = NFS4_OK; /* If there is no currentFH, teh return an error */ if(nfs4_Is_Fh_Empty(&(data->currentFH))) { /* There is no current FH, return NFS4ERR_NOFILEHANDLE */ resp->nfs_resop4_u.opsavefh.status = NFS4ERR_NOFILEHANDLE; return NFS4ERR_NOFILEHANDLE; } /* If the filehandle is invalid */ if(nfs4_Is_Fh_Invalid(&(data->currentFH))) { resp->nfs_resop4_u.opgetfh.status = NFS4ERR_BADHANDLE; return NFS4ERR_BADHANDLE; } /* Tests if teh Filehandle is expired (for volatile filehandle) */ if(nfs4_Is_Fh_Expired(&(data->currentFH))) { resp->nfs_resop4_u.opgetfh.status = NFS4ERR_FHEXPIRED; return NFS4ERR_FHEXPIRED; } /* If the savefh is not allocated, do it now */ if(data->savedFH.nfs_fh4_len == 0) { if((error = nfs4_AllocateFH(&(data->savedFH))) != NFS4_OK) { resp->nfs_resop4_u.opsavefh.status = error; return error; } } /* Copy the data from current FH to saved FH */ memcpy((char *)(data->savedFH.nfs_fh4_val), (char *)(data->currentFH.nfs_fh4_val), data->currentFH.nfs_fh4_len); /* Keep the vnodep in mind */ data->saved_entry = data->current_entry; data->saved_filetype = data->current_filetype; if(isFullDebug(COMPONENT_NFS_V4)) { char str[LEN_FH_STR]; sprint_fhandle4(str, &data->savedFH); LogFullDebug(COMPONENT_NFS_V4, "SAVE FH: Saved FH %s", str); } return NFS4_OK; } /* nfs4_op_savefh */
void free_nsm_client(state_nsm_client_t *pclient) { if(pclient->ssc_nlm_caller_name != NULL) Mem_Free(pclient->ssc_nlm_caller_name); if(isFullDebug(COMPONENT_MEMLEAKS)) memset(pclient, 0, sizeof(*pclient)); Mem_Free(pclient); }
/** * * print_buff * * This routine prints the content of a buffer. * * @param buff [IN] buffer to print. * @param len [IN] length of the buffer. * * @return nothing (void function). * */ void print_buff(log_components_t component, char *buff, int len) { if(isFullDebug(component)) { char str[1024]; sprint_buff(str, buff, len); LogFullDebug(component, "%s", str); } } /* print_buff */
/** * @brief Initializes the mount list * * @return 1 if successful, 0 otherwise * */ int nfs_Init_MountList(void) { MNT_List_head = NULL; MNT_List_tail = NULL; if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); return 1; } /* nfs_Init_MountList */