ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
if (ret == -1) {
+ NTSTATUS close_status;
status = map_nt_error_from_unix_common(errno);
DEBUG(1, ("Unable to fstat stream: %s => %s\n",
smb_fname_str_dbg(smb_fname),
nt_errstr(status)));
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1) {
- DEBUG(0, ("vfs_default_durable_reconnect: "
- "SMB_VFS_CLOSE failed (%s) - leaking file "
- "descriptor\n", strerror(errno)));
+ close_status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(close_status)) {
+ DBG_ERR("fd_close failed (%s) - leaking file "
+ "descriptor\n", nt_errstr(close_status));
}
TALLOC_FREE(lck);
op->compat = NULL;
}
if (!S_ISREG(fsp->fsp_name->st.st_ex_mode)) {
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1) {
- DEBUG(0, ("vfs_default_durable_reconnect: "
- "SMB_VFS_CLOSE failed (%s) - leaking file "
- "descriptor\n", strerror(errno)));
+ NTSTATUS close_status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(close_status)) {
+ DBG_ERR("fd_close failed (%s) - leaking file "
+ "descriptor\n", nt_errstr(close_status));
}
TALLOC_FREE(lck);
op->compat = NULL;
file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
if (!file_id_equal(&cookie.id, &file_id)) {
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1) {
- DEBUG(0, ("vfs_default_durable_reconnect: "
- "SMB_VFS_CLOSE failed (%s) - leaking file "
- "descriptor\n", strerror(errno)));
+ NTSTATUS close_status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(close_status)) {
+ DBG_ERR("fd_close failed (%s) - leaking file "
+ "descriptor\n", nt_errstr(close_status));
}
TALLOC_FREE(lck);
op->compat = NULL;
&fsp->fsp_name->st,
fsp_str_dbg(fsp));
if (!ok) {
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1) {
- DEBUG(0, ("vfs_default_durable_reconnect: "
- "SMB_VFS_CLOSE failed (%s) - leaking file "
- "descriptor\n", strerror(errno)));
+ NTSTATUS close_status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(close_status)) {
+ DBG_ERR("fd_close failed (%s) - leaking file "
+ "descriptor\n", nt_errstr(close_status));
}
TALLOC_FREE(lck);
op->compat = NULL;
status = set_file_oplock(fsp);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("vfs_default_durable_reconnect failed to set oplock "
- "after opening file: %s\n", nt_errstr(status)));
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1) {
- DEBUG(0, ("vfs_default_durable_reconnect: "
- "SMB_VFS_CLOSE failed (%s) - leaking file "
- "descriptor\n", strerror(errno)));
+ NTSTATUS close_status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(close_status)) {
+ DBG_ERR("fd_close failed (%s) - leaking file "
+ "descriptor\n", nt_errstr(close_status));
}
TALLOC_FREE(lck);
op->compat = NULL;
* and errno=ELOOP.
*/
if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
- ret = SMB_VFS_CLOSE(fsp);
- SMB_ASSERT(ret == 0);
-
- fsp_set_fd(fsp, -1);
+ status = fd_close(fsp);
+ SMB_ASSERT(NT_STATUS_IS_OK(status));
fd = -1;
status = NT_STATUS_STOPPED_ON_SYMLINK;
}
int old_fd;
int new_fd;
NTSTATUS status;
- int ret;
if (!fsp->fsp_flags.have_proc_fds) {
return NT_STATUS_MORE_PROCESSING_REQUIRED;
mode);
if (new_fd == -1) {
status = map_nt_error_from_unix(errno);
- SMB_VFS_CLOSE(fsp);
- fsp_set_fd(fsp, -1);
+ fd_close(fsp);
return status;
}
- ret = SMB_VFS_CLOSE(fsp);
- fsp_set_fd(fsp, -1);
- if (ret != 0) {
- return map_nt_error_from_unix(errno);
+ status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
fsp_set_fd(fsp, new_fd);
}
if (!NT_STATUS_IS_OK(status)) {
- SMB_VFS_CLOSE(fsp);
+ fd_close(fsp);
TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return status;
static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
- int fd, ret;
+ int fd;
+ NTSTATUS status;
if (argc != 2) {
printf("Usage: close <fd>\n");
return NT_STATUS_OK;
}
- ret = SMB_VFS_CLOSE(vfs->files[fd]);
- if (ret == -1 )
- printf("close: error=%d (%s)\n", errno, strerror(errno));
+ status = fd_close(vfs->files[fd]);
+ if (!NT_STATUS_IS_OK(status))
+ printf("close: error=%s\n", nt_errstr(status));
else
printf("close: ok\n");
TALLOC_FREE(vfs->files[fd]);
vfs->files[fd] = NULL;
- return NT_STATUS_OK;
+ return status;
}
out:
TALLOC_FREE(sd);
- ret = SMB_VFS_CLOSE(fsp);
- if (ret == -1 )
- printf("close: error=%d (%s)\n", errno, strerror(errno));
+ status = fd_close(fsp);
+ if (!NT_STATUS_IS_OK(status))
+ printf("close: error= (%s)\n", nt_errstr(status));
TALLOC_FREE(fsp);