Deal with SMB_SET_FILE_DISPOSITION_INFO.
****************************************************************************/
-NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
- const char *pdata,
- int total_data,
- files_struct *fsp,
- struct smb_filename *smb_fname)
+NTSTATUS smb_check_file_disposition_info(struct files_struct *fsp,
+ const char *data,
+ int total_data,
+ bool *_delete_on_close)
{
- NTSTATUS status = NT_STATUS_OK;
bool delete_on_close;
uint32_t dosmode = 0;
+ NTSTATUS status;
if (total_data < 1) {
return NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_INVALID_HANDLE;
}
- delete_on_close = (CVAL(pdata,0) ? True : False);
+ delete_on_close = (PULL_LE_U8(data, 0) ? true : false);
+ *_delete_on_close = delete_on_close;
+
dosmode = fdos_mode(fsp);
- DEBUG(10,("smb_set_file_disposition_info: file %s, dosmode = %u, "
- "delete_on_close = %u\n",
- smb_fname_str_dbg(smb_fname),
- (unsigned int)dosmode,
- (unsigned int)delete_on_close ));
+ DBG_DEBUG("file [%s] dosmode = %u, delete_on_close = %s\n",
+ fsp_str_dbg(fsp),
+ (unsigned int)dosmode,
+ delete_on_close ? "yes" : "no");
- if (delete_on_close) {
- status = can_set_delete_on_close(fsp, dosmode);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ if (!delete_on_close) {
+ return NT_STATUS_OK;
+ }
+
+ status = can_set_delete_on_close(fsp, dosmode);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
+ const char *pdata,
+ int total_data,
+ files_struct *fsp,
+ struct smb_filename *smb_fname)
+{
+ NTSTATUS status;
+ bool delete_on_close;
+
+ status = smb_check_file_disposition_info(fsp,
+ pdata,
+ total_data,
+ &delete_on_close);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
/* The set is across all open files on this dev/inode pair. */