From 3756467db6a661be91f4aeb484000e993e4a9a4c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 12:18:33 +0100 Subject: Move the posix pending close functionality down into the VFS layer. This hides the pending close fds from the outside. Call order of SMB_VFS_CLOSE is reversed. Originally, it was: fd_close -> fd_close_posix -> SMB_VFS_CLOSE -> close And now it is: fd_close -> SMB_VFS_CLOSE -> fd_close_posix -> close This is in preparation of removing the fd parameter from the SMB_VFS_CLOSE function. But it is also the right place for the pending close calls anyways. Michael (This used to be commit 3cf56b124a2886c6260455bba4bf77d08e9a4f77) --- source3/locking/posix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 1b88c472b0..f42d1ec6f8 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -620,7 +620,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) * which will lose all locks on all fd's open on this dev/inode, * just close. */ - ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd); + ret = close(fsp->fh->fd); fsp->fh->fd = -1; if (ret == -1) { return map_nt_error_from_unix(errno); @@ -651,7 +651,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", (unsigned int)count )); for(i = 0; i < count; i++) { - if (SMB_VFS_CLOSE(fsp,fd_array[i]) == -1) { + if (close(fd_array[i]) == -1) { saved_errno = errno; } } @@ -673,7 +673,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) * Finally close the fd associated with this fsp. */ - ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd); + ret = close(fsp->fh->fd); if (ret == 0 && saved_errno != 0) { errno = saved_errno; -- cgit From 96e9e83ee021db69179fe924144e6ba3dea1b73d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 13:03:16 +0100 Subject: Don't modify the fsp in fd_close_posix() anymore. Now that it is inside the vfs layer, this function should not alter the fsp (i.e. set fsp->fh->fd = -1) anymore. That belongs above the vfs layer. Michael (This used to be commit df264bf3e00d7d77afcf55e54d2669b9ffa9af4a) --- source3/locking/posix.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index f42d1ec6f8..844a86e863 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -621,7 +621,6 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) * just close. */ ret = close(fsp->fh->fd); - fsp->fh->fd = -1; if (ret == -1) { return map_nt_error_from_unix(errno); } @@ -636,7 +635,6 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) */ add_fd_to_close_entry(fsp); - fsp->fh->fd = -1; return NT_STATUS_OK; } @@ -680,8 +678,6 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) ret = -1; } - fsp->fh->fd = -1; - if (ret == -1) { return map_nt_error_from_unix(errno); } -- cgit From 2f8dde9ec8110557c23df6ea66913a7d39425415 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 13:28:28 +0100 Subject: Change fd_close_posix() to return int instead of NTSTATUS. The errno is handed up through the VFS layer to the callers. Michael (This used to be commit d928e6648d61cf2d3c1b77db440efb835b729a84) --- source3/locking/posix.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 844a86e863..aedc12dede 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -607,7 +607,7 @@ static size_t get_posix_pending_close_entries(TALLOC_CTX *mem_ctx, to delete all locks on this fsp before this function is called. ****************************************************************************/ -NTSTATUS fd_close_posix(struct files_struct *fsp) +int fd_close_posix(struct files_struct *fsp) { int saved_errno = 0; int ret; @@ -620,11 +620,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) * which will lose all locks on all fd's open on this dev/inode, * just close. */ - ret = close(fsp->fh->fd); - if (ret == -1) { - return map_nt_error_from_unix(errno); - } - return NT_STATUS_OK; + return close(fsp->fh->fd); } if (get_windows_lock_ref_count(fsp)) { @@ -635,7 +631,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) */ add_fd_to_close_entry(fsp); - return NT_STATUS_OK; + return 0; } /* @@ -678,11 +674,7 @@ NTSTATUS fd_close_posix(struct files_struct *fsp) ret = -1; } - if (ret == -1) { - return map_nt_error_from_unix(errno); - } - - return NT_STATUS_OK; + return ret; } /**************************************************************************** -- cgit From 8c9060240eec82d750904d8b07fd38b168a84bea Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 13:41:46 +0100 Subject: Slight reformatting of fd_close_posix(), while I'm at it. Wrap lines and remove trailing space. Michael (This used to be commit 74ed53a115b2063d4d5c8572af8f1302bc658882) --- source3/locking/posix.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index aedc12dede..32e1ee9fbf 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -614,7 +614,9 @@ int fd_close_posix(struct files_struct *fsp) int *fd_array = NULL; size_t count, i; - if (!lp_locking(fsp->conn->params) || !lp_posix_locking(fsp->conn->params)) { + if (!lp_locking(fsp->conn->params) || + !lp_posix_locking(fsp->conn->params)) + { /* * No locking or POSIX to worry about or we want POSIX semantics * which will lose all locks on all fd's open on this dev/inode, @@ -626,8 +628,9 @@ int fd_close_posix(struct files_struct *fsp) if (get_windows_lock_ref_count(fsp)) { /* - * There are outstanding locks on this dev/inode pair on other fds. - * Add our fd to the pending close tdb and set fsp->fh->fd to -1. + * There are outstanding locks on this dev/inode pair on + * other fds. Add our fd to the pending close tdb and set + * fsp->fh->fd to -1. */ add_fd_to_close_entry(fsp); @@ -642,7 +645,8 @@ int fd_close_posix(struct files_struct *fsp) count = get_posix_pending_close_entries(talloc_tos(), fsp, &fd_array); if (count) { - DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", (unsigned int)count )); + DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", + (unsigned int)count)); for(i = 0; i < count; i++) { if (close(fd_array[i]) == -1) { @@ -672,7 +676,7 @@ int fd_close_posix(struct files_struct *fsp) if (ret == 0 && saved_errno != 0) { errno = saved_errno; ret = -1; - } + } return ret; } -- cgit