* as this is not a client visible handle so
* can'tbe part of an SMB1 chain.
*/
- close_file(NULL, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_file_free(NULL, &fsp, NORMAL_CLOSE);
reply_nterror(req, nt_status);
goto out;
}
if (numentries == 0) {
dptr_num = -1;
if (fsp != NULL) {
- close_file(NULL, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_file_free(NULL, &fsp, NORMAL_CLOSE);
}
} else if(expect_close && status_len == 0) {
/* Close the dptr - we know it's gone */
dptr_num = -1;
if (fsp != NULL) {
- close_file(NULL, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_file_free(NULL, &fsp, NORMAL_CLOSE);
}
}
dptr_num = -1;
/* fsp may have been closed above. */
if (fsp != NULL) {
- close_file(NULL, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_file_free(NULL, &fsp, NORMAL_CLOSE);
}
}
fsp = dptr_fetch_fsp(sconn, status+12,&dptr_num);
if(fsp != NULL) {
/* Close the file - we know it's gone */
- close_file(NULL, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_file_free(NULL, &fsp, NORMAL_CLOSE);
dptr_num = -1;
}
if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("attempt to open a directory %s\n",
fsp_str_dbg(fsp)));
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_botherror(req, NT_STATUS_ACCESS_DENIED,
ERRDOS, ERRnoaccess);
goto out;
if (((smb_action == FILE_WAS_CREATED) || (smb_action == FILE_WAS_OVERWRITTEN)) && allocation_size) {
fsp->initial_allocation_size = smb_roundup(fsp->conn, allocation_size);
if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
goto out;
}
retval = vfs_set_filelen(fsp, (off_t)allocation_size);
if (retval < 0) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
goto out;
}
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, status);
goto out;
}
fattr = fdos_mode(fsp);
if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
}
"(%s)\n",
smb_fname_str_dbg(smb_fname),
nt_errstr(status));
- close_file(req, fsp, NORMAL_CLOSE);
+ close_file_free(req, &fsp, NORMAL_CLOSE);
return status;
}
if (!set_delete_on_close(fsp, True,
conn->session_info->security_token,
conn->session_info->unix_token)) {
- close_file(req, fsp, NORMAL_CLOSE);
+ close_file_free(req, &fsp, NORMAL_CLOSE);
return NT_STATUS_ACCESS_DENIED;
}
- return close_file(req, fsp, NORMAL_CLOSE);
+ return close_file_free(req, &fsp, NORMAL_CLOSE);
}
/****************************************************************************
* reply_readbraw has already checked the length.
*/
- if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
- lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
+ if ( !req_is_in_chain(req) &&
+ (nread > 0) &&
+ !fsp_is_alternate_stream(fsp) &&
+ lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
ssize_t sendfile_read = -1;
char header[4];
DATA_BLOB header_blob;
if (!req_is_in_chain(req) &&
!req->encrypted &&
- (fsp->base_fsp == NULL) &&
+ !fsp_is_alternate_stream(fsp) &&
lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
uint8_t headerbuf[smb_size + 12 * 2 + 1 /* padding byte */];
DATA_BLOB header;
DEBUG(10,("is_valid_writeX_buffer: printing tid\n"));
return false;
}
- if (fsp->base_fsp != NULL) {
+ if (fsp_is_alternate_stream(fsp)) {
DEBUG(10,("is_valid_writeX_buffer: stream fsp\n"));
return false;
}
smb_request_done(smb1req);
END_PROFILE(SMBexit);
}
- close_file(NULL, fsp, SHUTDOWN_CLOSE);
+ close_file_free(NULL, &fsp, SHUTDOWN_CLOSE);
}
reply_outbuf(smb1req, 0, 0);
}
/*
- * close_file() returns the unix errno if an error was detected on
+ * close_file_free() returns the unix errno if an error was detected on
* close - normally this is due to a disk full error. If not then it
* was probably an I/O error.
*/
- status = close_file(smb1req, fsp, NORMAL_CLOSE);
+ status = close_file_free(smb1req, &fsp, NORMAL_CLOSE);
done:
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(smb1req, status);
return;
}
- status = close_file(smb1req, state->fsp, NORMAL_CLOSE);
+ status = close_file_free(smb1req, &state->fsp, NORMAL_CLOSE);
if (NT_STATUS_IS_OK(status)) {
reply_outbuf(smb1req, 0, 0);
} else {
if (numtowrite) {
DEBUG(3,("reply_writeclose: zero length write doesn't close "
"file %s\n", fsp_str_dbg(fsp)));
- close_status = close_file(req, fsp, NORMAL_CLOSE);
- fsp = NULL;
+ close_status = close_file_free(req, &fsp, NORMAL_CLOSE);
}
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
DEBUG(3,("printclose fd=%d %s\n",
fsp_get_io_fd(fsp), fsp_fnum_dbg(fsp)));
- status = close_file(req, fsp, NORMAL_CLOSE);
+ status = close_file_free(req, &fsp, NORMAL_CLOSE);
if(!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
status = can_set_delete_on_close(fsp, FILE_ATTRIBUTE_DIRECTORY);
if (!NT_STATUS_IS_OK(status)) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, status);
goto out;
}
if (!set_delete_on_close(fsp, true,
conn->session_info->security_token,
conn->session_info->unix_token)) {
- close_file(req, fsp, ERROR_CLOSE);
+ close_file_free(req, &fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
}
- status = close_file(req, fsp, NORMAL_CLOSE);
+ status = close_file_free(req, &fsp, NORMAL_CLOSE);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
} else {
goto out;
}
- dst_exists = SMB_VFS_STAT(conn, smb_fname_dst) == 0;
+ dst_exists = vfs_stat(conn, smb_fname_dst) == 0;
if(!replace_if_exists && dst_exists) {
DEBUG(3, ("rename_internals_fsp: dest exists doing rename "
attrs,
replace_if_exists);
- close_file(req, fsp, NORMAL_CLOSE);
+ close_file_free(req, &fsp, NORMAL_CLOSE);
DBG_NOTICE("Error %s rename %s -> %s\n",
nt_errstr(status), smb_fname_str_dbg(smb_fname_src),
NULL, NULL); /* create context */
if (!NT_STATUS_IS_OK(status)) {
- close_file(NULL, fsp1, ERROR_CLOSE);
+ close_file_free(NULL, &fsp1, ERROR_CLOSE);
goto out;
}
DEBUG(0, ("error - vfs lseek returned error %s\n",
strerror(errno)));
status = map_nt_error_from_unix(errno);
- close_file(NULL, fsp1, ERROR_CLOSE);
- close_file(NULL, fsp2, ERROR_CLOSE);
+ close_file_free(NULL, &fsp1, ERROR_CLOSE);
+ close_file_free(NULL, &fsp2, ERROR_CLOSE);
goto out;
}
}
ret = 0;
}
- close_file(NULL, fsp1, NORMAL_CLOSE);
+ close_file_free(NULL, &fsp1, NORMAL_CLOSE);
/* Ensure the modtime is set correctly on the destination file. */
set_close_write_time(fsp2, smb_fname_src->st.st_ex_mtime);
* Thus we don't look at the error return from the
* close of fsp1.
*/
- status = close_file(NULL, fsp2, NORMAL_CLOSE);
+ status = close_file_free(NULL, &fsp2, NORMAL_CLOSE);
if (!NT_STATUS_IS_OK(status)) {
goto out;