GetTimeOfDay(&fsp->open_time);
- if (sconn->conn) {
+ if (req) {
struct smbXsrv_open *op = NULL;
NTTIME now = timeval_to_nttime(&fsp->open_time);
op->compat = fsp;
fsp->fnum = op->local_id;
fsp->fh->gen_id = smbXsrv_open_hash(op);
+ } else {
+ DEBUG(10, ("%s: req==NULL, INTERNAL_OPEN_ONLY, smbXsrv_open "
+ "allocated\n", __func__));
}
/*
* few NULL checks, so make sure it's initialized with something. to
* be safe until an audit can be done.
*/
- status = create_synthetic_smb_fname(fsp, "", NULL, NULL,
- &fsp->fsp_name);
- if (!NT_STATUS_IS_OK(status)) {
+ fsp->fsp_name = synthetic_smb_fname(fsp, "", NULL, NULL);
+ if (fsp->fsp_name == NULL) {
file_free(NULL, fsp);
- return status;
+ return NT_STATUS_NO_MEMORY;
}
DEBUG(5,("allocated file structure %s (%u used)\n",
}
/* Paranoia check. */
if ((fsp->fh->fd == -1) &&
- (fsp->oplock_type != NO_OPLOCK) &&
- (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK)) {
+ (fsp->oplock_type != NO_OPLOCK)) {
DEBUG(0,("file_find_dif: file %s file_id = "
"%s, gen = %u oplock_type = %u is a "
"stat open with oplock type !\n",
return fsp;
}
-struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
- uint64_t persistent_id,
- uint64_t volatile_id)
+struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
+ uint64_t persistent_id,
+ uint64_t volatile_id)
{
struct smbXsrv_open *op;
NTSTATUS status;
NTTIME now = 0;
struct files_struct *fsp;
- if (smb2req->compat_chain_fsp != NULL) {
- if (smb2req->compat_chain_fsp->deferred_close) {
- return NULL;
- }
- return smb2req->compat_chain_fsp;
- }
-
now = timeval_to_nttime(&smb2req->request_time);
status = smb2srv_open_lookup(smb2req->sconn->conn,
return NULL;
}
+ return fsp;
+}
+
+struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
+ uint64_t persistent_id,
+ uint64_t volatile_id)
+{
+ struct files_struct *fsp;
+
+ if (smb2req->compat_chain_fsp != NULL) {
+ if (smb2req->compat_chain_fsp->deferred_close) {
+ return NULL;
+ }
+ return smb2req->compat_chain_fsp;
+ }
+
+ fsp = file_fsp_get(smb2req, persistent_id, volatile_id);
+ if (fsp == NULL) {
+ return NULL;
+ }
+
smb2req->compat_chain_fsp = fsp;
return fsp;
}
NTSTATUS file_name_hash(connection_struct *conn,
const char *name, uint32_t *p_name_hash)
{
- char *fullpath = NULL;
+ char tmpbuf[PATH_MAX];
+ char *fullpath, *to_free;
+ size_t len;
/* Set the hash of the full pathname. */
- fullpath = talloc_asprintf(talloc_tos(),
- "%s/%s",
- conn->connectpath,
- name);
- if (!fullpath) {
+
+ 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, talloc_get_size(fullpath), 0);
+ *p_name_hash = hash(fullpath, len+1, 0);
DEBUG(10,("file_name_hash: %s hash 0x%x\n",
- fullpath,
+ fullpath,
(unsigned int)*p_name_hash ));
- TALLOC_FREE(fullpath);
+ TALLOC_FREE(to_free);
return NT_STATUS_OK;
}
NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
const struct smb_filename *smb_fname_in)
{
- NTSTATUS status;
struct smb_filename *smb_fname_new;
- status = copy_smb_filename(fsp, smb_fname_in, &smb_fname_new);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ 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);