NTSTATUS file_name_hash(connection_struct *conn, const char *name, uint32_t *p_name_hash) { char tmpbuf[PATH_MAX]; char *fullpath, *to_free; ssize_t len; TDB_DATA key; /* Set the hash of the full pathname. */ len = full_path_tos(conn->connectpath, name, tmpbuf, sizeof(tmpbuf), &fullpath, &to_free); if (len == -1) { return NT_STATUS_NO_MEMORY; } key = (TDB_DATA) { .dptr = (uint8_t *)fullpath, .dsize = len+1 }; *p_name_hash = tdb_jenkins_hash(&key); DEBUG(10,("file_name_hash: %s hash 0x%x\n", fullpath, (unsigned int)*p_name_hash )); TALLOC_FREE(to_free); return NT_STATUS_OK; } /** * The only way that the fsp->fsp_name field should ever be set. */ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp, const struct smb_filename *smb_fname_in) { struct smb_filename *smb_fname_new; smb_fname_new = cp_smb_filename(fsp, smb_fname_in); if (smb_fname_new == NULL) { return NT_STATUS_NO_MEMORY; } TALLOC_FREE(fsp->fsp_name); fsp->fsp_name = smb_fname_new; return file_name_hash(fsp->conn, smb_fname_str_dbg(fsp->fsp_name), &fsp->name_hash); } const struct GUID *fsp_client_guid(const files_struct *fsp) { return &fsp->conn->sconn->client->connections->smb2.client.guid; } uint32_t fsp_lease_type(struct files_struct *fsp) { if (fsp->oplock_type == LEASE_OPLOCK) { return fsp->lease->lease.lease_state; } return map_oplock_to_lease_type(fsp->oplock_type); }
NTSTATUS file_name_hash(connection_struct *conn, const char *name, uint32_t *p_name_hash) { char tmpbuf[PATH_MAX]; char *fullpath, *to_free; size_t len; /* Set the hash of the full pathname. */ len = full_path_tos(conn->connectpath, name, tmpbuf, sizeof(tmpbuf), &fullpath, &to_free); if (len == -1) { return NT_STATUS_NO_MEMORY; } *p_name_hash = hash(fullpath, len+1, 0); DEBUG(10,("file_name_hash: %s hash 0x%x\n", fullpath, (unsigned int)*p_name_hash )); TALLOC_FREE(to_free); return NT_STATUS_OK; }