Changeset 62 for trunk/samba/source/smbd/trans2.c
- Timestamp:
- Aug 21, 2007, 11:34:46 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba/source/smbd/trans2.c
r39 r62 878 878 oplock_request, 879 879 &smb_action, &fsp); 880 880 881 881 if (!NT_STATUS_IS_OK(status)) { 882 882 if (open_was_deferred(SVAL(inbuf,smb_mid))) { … … 884 884 return -1; 885 885 } 886 return ERROR_ NT(status);886 return ERROR_OPEN(status); 887 887 } 888 888 … … 2011 2011 path or an invalid name). Catch this as the resume name is only compared, never used in 2012 2012 a file access. JRA. */ 2013 if (NT_STATUS_EQUAL(ntstatus,NT_STATUS_OBJECT_PATH_SYNTAX_BAD)) {2014 pstrcpy(resume_name, "..");2015 } else if (NT_STATUS_EQUAL(ntstatus,NT_STATUS_OBJECT_NAME_INVALID)) {2016 pstrcpy(resume_name, "."); 2017 } else{2013 srvstr_pull(inbuf, resume_name, params+12, 2014 sizeof(resume_name), total_params - 12, 2015 STR_TERMINATE); 2016 2017 if (!(ISDOT(resume_name) || ISDOTDOT(resume_name))) { 2018 2018 return ERROR_NT(ntstatus); 2019 2019 } … … 4857 4857 } 4858 4858 4859 if(allocation_size == get_file_size(*psbuf)) {4860 return NT_STATUS_OK;4861 }4862 4863 4859 DEBUG(10,("smb_set_file_allocation_info: file %s : setting new allocation size to %.0f\n", 4864 4860 fname, (double)allocation_size )); 4865 4861 4866 4862 if (fsp && fsp->fh->fd != -1) { 4867 4863 /* Open file handle. */ 4868 if (vfs_allocate_file_space(fsp, allocation_size) == -1) { 4869 return map_nt_error_from_unix(errno); 4864 /* Only change if needed. */ 4865 if (allocation_size != get_file_size(*psbuf)) { 4866 if (vfs_allocate_file_space(fsp, allocation_size) == -1) { 4867 return map_nt_error_from_unix(errno); 4868 } 4869 } 4870 /* But always update the time. */ 4871 if (null_timespec(fsp->pending_modtime)) { 4872 /* 4873 * This is equivalent to a write. Ensure it's seen immediately 4874 * if there are no pending writes. 4875 */ 4876 set_filetime(fsp->conn, fsp->fsp_name, timespec_current()); 4870 4877 } 4871 4878 return NT_STATUS_OK; … … 4882 4889 FORCE_OPLOCK_BREAK_TO_NONE, 4883 4890 NULL, &new_fsp); 4884 4891 4885 4892 if (!NT_STATUS_IS_OK(status)) { 4886 4893 /* NB. We check for open_was_deferred in the caller. */ 4887 4894 return status; 4888 4895 } 4889 if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) { 4890 status = map_nt_error_from_unix(errno); 4891 close_file(new_fsp,NORMAL_CLOSE); 4892 return status; 4893 } 4896 4897 /* Only change if needed. */ 4898 if (allocation_size != get_file_size(*psbuf)) { 4899 if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) { 4900 status = map_nt_error_from_unix(errno); 4901 close_file(new_fsp,NORMAL_CLOSE); 4902 return status; 4903 } 4904 } 4905 4906 /* Changing the allocation size should set the last mod time. */ 4907 /* Don't need to call set_filetime as this will be flushed on 4908 * close. */ 4909 4910 fsp_set_pending_modtime(new_fsp, timespec_current()); 4894 4911 4895 4912 close_file(new_fsp,NORMAL_CLOSE); … … 5537 5554 files_struct *fsp = NULL; 5538 5555 uint16 flags = 0; 5556 char del = 1; 5539 5557 int info = 0; 5558 int i; 5559 struct share_mode_lock *lck = NULL; 5540 5560 5541 5561 if (total_data < 2) { … … 5565 5585 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 5566 5586 FILE_OPEN, 5567 FILE_DELETE_ON_CLOSE,5587 0, 5568 5588 FILE_FLAG_POSIX_SEMANTICS|0777, 5569 &info, 5589 &info, 5570 5590 &fsp); 5571 5591 } else { 5572 char del = 1;5573 5592 5574 5593 status = open_file_ntcreate(conn, … … 5583 5602 &info, 5584 5603 &fsp); 5585 /*5586 * For file opens we must set the delete on close5587 * after the open.5588 */5589 5590 if (!NT_STATUS_IS_OK(status)) {5591 return status;5592 }5593 5594 status = smb_set_file_disposition_info(conn,5595 &del,5596 1,5597 fsp,5598 fname,5599 psbuf);5600 5604 } 5601 5605 … … 5603 5607 return status; 5604 5608 } 5609 5610 /* 5611 * Don't lie to client. If we can't really delete due to 5612 * non-POSIX opens return SHARING_VIOLATION. 5613 */ 5614 5615 lck = get_share_mode_lock(NULL, fsp->dev, fsp->inode, NULL, NULL); 5616 if (lck == NULL) { 5617 DEBUG(0, ("smb_posix_unlink: Could not get share mode " 5618 "lock for file %s\n", fsp->fsp_name)); 5619 close_file(fsp, NORMAL_CLOSE); 5620 return NT_STATUS_INVALID_PARAMETER; 5621 } 5622 5623 /* 5624 * See if others still have the file open. If this is the case, then 5625 * don't delete. If all opens are POSIX delete we can set the delete 5626 * on close disposition. 5627 */ 5628 for (i=0; i<lck->num_share_modes; i++) { 5629 struct share_mode_entry *e = &lck->share_modes[i]; 5630 if (is_valid_share_mode_entry(e)) { 5631 if (e->flags & SHARE_MODE_FLAG_POSIX_OPEN) { 5632 continue; 5633 } 5634 /* Fail with sharing violation. */ 5635 close_file(fsp, NORMAL_CLOSE); 5636 TALLOC_FREE(lck); 5637 return NT_STATUS_SHARING_VIOLATION; 5638 } 5639 } 5640 5641 /* 5642 * Set the delete on close. 5643 */ 5644 status = smb_set_file_disposition_info(conn, 5645 &del, 5646 1, 5647 fsp, 5648 fname, 5649 psbuf); 5650 5651 if (!NT_STATUS_IS_OK(status)) { 5652 close_file(fsp, NORMAL_CLOSE); 5653 TALLOC_FREE(lck); 5654 return status; 5655 } 5656 TALLOC_FREE(lck); 5605 5657 return close_file(fsp, NORMAL_CLOSE); 5606 5658 } … … 5997 6049 if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) { 5998 6050 return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED, ERRSRV, ERRbadpath); 6051 } 6052 if (info_level == SMB_POSIX_PATH_OPEN) { 6053 return ERROR_OPEN(status); 5999 6054 } 6000 6055 return ERROR_NT(status);
Note:
See TracChangeset
for help on using the changeset viewer.