#include "auth.h"
#include "messages.h"
#include "../librpc/gen_ndr/open_files.h"
+#include "lib/util/tevent_ntstatus.h"
/****************************************************************************
Run a file if it is a magic script.
remove_oplock(fsp);
}
- if (fsp->write_time_forced) {
+ if (fsp->fsp_flags.write_time_forced) {
struct timespec ts;
DEBUG(10,("close_remove_share_mode: write time forced "
fsp_str_dbg(fsp)));
ts = nt_time_to_full_timespec(lck->data->changed_write_time);
set_close_write_time(fsp, ts);
- } else if (fsp->update_write_time_on_close) {
+ } else if (fsp->fsp_flags.update_write_time_on_close) {
/* Someone had a pending write. */
if (is_omit_timespec(&fsp->close_write_time)) {
DEBUG(10,("close_remove_share_mode: update to current time "
}
}
- if (fsp->initial_delete_on_close &&
+ if (fsp->fsp_flags.initial_delete_on_close &&
!is_delete_on_close_set(lck, fsp->name_hash)) {
bool became_user = False;
become_user_without_service(conn, fsp->vuid);
became_user = True;
}
- fsp->delete_on_close = true;
+ fsp->fsp_flags.delete_on_close = true;
set_delete_on_close_lck(fsp, lck,
get_current_nttok(conn),
get_current_utok(conn));
/*
* Don't try to update the write time when we delete the file
*/
- fsp->update_write_time_on_close = false;
+ fsp->fsp_flags.update_write_time_on_close = false;
got_tokens = get_delete_on_close_token(lck, fsp->name_hash,
&del_nt_token, &del_token);
}
}
- if (fsp->kernel_share_modes_taken) {
+ if (fsp->fsp_flags.kernel_share_modes_taken) {
int ret_flock;
/*
fsp_str_dbg(fsp), strerror(errno));
}
- fsp->kernel_share_modes_taken = false;
+ fsp->fsp_flags.kernel_share_modes_taken = false;
}
* the delete on close flag. JRA.
*/
- fsp->delete_on_close = false;
+ fsp->fsp_flags.delete_on_close = false;
reset_delete_on_close_lck(fsp, lck);
done:
pop_sec_ctx();
}
- if (fsp->kernel_share_modes_taken) {
+ if (fsp->fsp_flags.kernel_share_modes_taken) {
int ret_flock;
/* remove filesystem sharemodes */
if (is_omit_timespec(&ts)) {
return;
}
- fsp->write_time_forced = false;
- fsp->update_write_time_on_close = true;
+ fsp->fsp_flags.write_time_forced = false;
+ fsp->fsp_flags.update_write_time_on_close = true;
fsp->close_write_time = ts;
}
init_smb_file_time(&ft);
- if (!fsp->update_write_time_on_close) {
+ if (!(fsp->fsp_flags.update_write_time_on_close)) {
return NT_STATUS_OK;
}
return s2;
}
+static void assert_no_pending_aio(struct files_struct *fsp,
+ enum file_close_type close_type)
+{
+ unsigned num_requests = fsp->num_aio_requests;
+
+ if (num_requests == 0) {
+ return;
+ }
+
+ DBG_ERR("fsp->num_aio_requests=%u\n", num_requests);
+ smb_panic("can not close with outstanding aio requests");
+ return;
+}
+
/****************************************************************************
Close a file.
connection_struct *conn = fsp->conn;
bool is_durable = false;
- if (fsp->num_aio_requests != 0) {
-
- if (close_type != SHUTDOWN_CLOSE) {
- /*
- * reply_close and the smb2 close must have
- * taken care of this. No other callers of
- * close_file should ever have created async
- * I/O.
- *
- * We need to panic here because if we close()
- * the fd while we have outstanding async I/O
- * requests, in the worst case we could end up
- * writing to the wrong file.
- */
- DEBUG(0, ("fsp->num_aio_requests=%u\n",
- fsp->num_aio_requests));
- smb_panic("can not close with outstanding aio "
- "requests");
- }
-
- /*
- * For shutdown close, just drop the async requests
- * including a potential close request pending for
- * this fsp. Drop the close request first, the
- * destructor for the aio_requests would execute it.
- */
- TALLOC_FREE(fsp->deferred_close);
-
- while (fsp->num_aio_requests != 0) {
- /*
- * The destructor of the req will remove
- * itself from the fsp.
- * Don't use TALLOC_FREE here, this will overwrite
- * what the destructor just wrote into
- * aio_requests[0].
- */
- talloc_free(fsp->aio_requests[0]);
- }
- }
+ assert_no_pending_aio(fsp, close_type);
while (talloc_array_length(fsp->blocked_smb1_lock_reqs) != 0) {
smbd_smb1_brl_finish_by_req(
continue;
}
- if (!is_visible_file(conn, smb_dname->base_name, dname, &st,
- false)) {
+ if (!is_visible_file(conn,
+ smb_dname,
+ dname,
+ &st,
+ false)) {
TALLOC_FREE(talloced);
continue;
}
TALLOC_FREE(talloced);
continue;
}
- if (!is_visible_file(conn, smb_dname->base_name, dname,
- &st, false)) {
+ if (!is_visible_file(conn,
+ smb_dname,
+ dname,
+ &st,
+ false)) {
TALLOC_FREE(talloced);
continue;
}
TALLOC_FREE(talloced);
continue;
}
- if (!is_visible_file(conn, smb_dname->base_name, dname,
- &st, false)) {
+ if (!is_visible_file(conn,
+ smb_dname,
+ dname,
+ &st,
+ false)) {
TALLOC_FREE(talloced);
continue;
}
notify_status = NT_STATUS_OK;
}
- if (fsp->num_aio_requests != 0) {
- if (close_type != SHUTDOWN_CLOSE) {
- /*
- * We panic here because if we close() the fd while we
- * have outstanding async I/O requests, an async IO
- * request might use the fd. For directories the fd is
- * read-only, so this is not as bad as with files, but
- * still, better safe then sorry.
- */
- DBG_ERR("fsp->num_aio_requests=%u\n",
- fsp->num_aio_requests);
- smb_panic("close with outstanding aio requests");
- return NT_STATUS_INTERNAL_ERROR;
- }
-
- while (fsp->num_aio_requests != 0) {
- /*
- * The destructor of the req will remove itself from the
- * fsp. Don't use TALLOC_FREE here, this will overwrite
- * what the destructor just wrote into aio_requests[0].
- */
- talloc_free(fsp->aio_requests[0]);
- }
- }
+ assert_no_pending_aio(fsp, close_type);
/*
* NT can set delete_on_close of the last open
return NT_STATUS_INVALID_PARAMETER;
}
- if (fsp->initial_delete_on_close) {
+ if (fsp->fsp_flags.initial_delete_on_close) {
bool became_user = False;
/* Initial delete on close was set - for
set_delete_on_close_lck(fsp, lck,
get_current_nttok(fsp->conn),
get_current_utok(fsp->conn));
- fsp->delete_on_close = true;
+ fsp->fsp_flags.delete_on_close = true;
if (became_user) {
unbecome_user_without_service();
}
NTSTATUS status;
struct files_struct *base_fsp = fsp->base_fsp;
- if(fsp->is_directory) {
+ if (fsp->fsp_flags.is_directory) {
status = close_directory(req, fsp, close_type);
} else if (fsp->fake_file_handle != NULL) {
status = close_fake_file(req, fsp);