int i;
int num_share_modes;
int oplock_contention_count = 0;
- share_mode_entry *old_shares = 0;
+ share_mode_entry *old_shares = NULL;
BOOL fcbopen = False;
BOOL broke_oplock;
num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
- if(num_share_modes == 0)
+ if(num_share_modes == 0) {
+ SAFE_FREE(old_shares);
return 0;
+ }
if (desired_access && ((desired_access & ~(SYNCHRONIZE_ACCESS|FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES))==0) &&
((desired_access & (SYNCHRONIZE_ACCESS|FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES)) != 0)) {
/* Stat open that doesn't trigger oplock breaks or share mode checks... ! JRA. */
+ SAFE_FREE(old_shares);
return num_share_modes;
}
return -1;
}
- broken_entry = malloc(sizeof(struct share_mode_entry_list));
+ broken_entry = SMB_MALLOC_P(struct share_mode_entry_list);
if (!broken_entry) {
smb_panic("open_mode_check: malloc fail.\n");
}
free_broken_entry_list(broken_entry_list);
} while(broke_oplock);
- if(old_shares != 0)
- SAFE_FREE(old_shares);
-
/*
* Refuse to grant an oplock in case the contention limit is
* reached when going through the lock list multiple times.
oplock_contention_count ));
}
+ SAFE_FREE(old_shares);
return num_share_modes;
}
struct pending_message_list *pml = NULL;
uint16 mid = get_current_mid();
/* We add aARCH to this as this mode is only used if the file is created new. */
- mode_t mode = unix_mode(conn,new_dos_mode | aARCH,fname);
+ mode_t mode = unix_mode(conn,new_dos_mode | aARCH,fname, True);
if (oplock_request == INTERNAL_OPEN_ONLY) {
internal_only_open = True;
(*Access) = open_mode;
}
+ action = 0;
+
if (file_existed && !(flags2 & O_TRUNC))
action = FILE_WAS_OPENED;
if (file_existed && (flags2 & O_TRUNC))
}
if (delete_on_close) {
- NTSTATUS result = set_delete_on_close_internal(fsp, delete_on_close);
+ uint32 dosmode = existing_dos_mode;
+ NTSTATUS result;
+
+ if (action == FILE_WAS_OVERWRITTEN || action == FILE_WAS_CREATED) {
+ dosmode = new_dos_mode;
+ }
+ result = set_delete_on_close_internal(fsp, delete_on_close, dosmode);
if (NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_OK)) {
+ uint8 u_e_c;
+ uint32 u_e_code;
/* Remember to delete the mode we just added. */
if (add_share_mode) {
del_share_mode(fsp, NULL);
unlock_share_entry_fsp(fsp);
fd_close(conn,fsp);
file_free(fsp);
+ ntstatus_to_dos(result, &u_e_c, &u_e_code);
+ unix_ERR_ntstatus = result;
+ unix_ERR_class = u_e_c;
+ unix_ERR_code = u_e_code;
return NULL;
}
}
if (action == FILE_WAS_OVERWRITTEN || action == FILE_WAS_CREATED) {
/* Files should be initially set as archive */
if (lp_map_archive(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn))) {
- file_set_dosmode(conn, fname, new_dos_mode | aARCH, NULL);
+ file_set_dosmode(conn, fname, new_dos_mode | aARCH, NULL, True);
}
}
return NULL;
}
- if(vfs_MkDir(conn,fname, unix_mode(conn,aDIR, fname)) < 0) {
+ if(vfs_MkDir(conn,fname, unix_mode(conn,aDIR, fname, True)) < 0) {
DEBUG(2,("open_directory: unable to create %s. Error was %s\n",
fname, strerror(errno) ));
file_free(fsp);
string_set(&fsp->fsp_name,fname);
if (delete_on_close) {
- NTSTATUS result = set_delete_on_close_internal(fsp, delete_on_close);
+ NTSTATUS result = set_delete_on_close_internal(fsp, delete_on_close, 0);
if (NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_OK)) {
file_free(fsp);