From a9dbdf937c4901c4e791bff0753bafe709bc0fa5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Feb 2007 01:55:08 +0000 Subject: r21480: Make fd_open match fd_close be translating errno into an NTSTATUS immediately. Jeremy. (This used to be commit 71dd02cc164197152e76d8141f906390c4bd1526) --- source3/smbd/open.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source3/smbd/open.c') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 32f70eb0af..f03c8216d4 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -38,13 +38,13 @@ struct deferred_open_record { fd support routines - attempt to do a dos_open. ****************************************************************************/ -static BOOL fd_open(struct connection_struct *conn, +static NTSTATUS fd_open(struct connection_struct *conn, const char *fname, files_struct *fsp, int flags, mode_t mode) { - int sav; + NTSTATUS status = NT_STATUS_OK; #ifdef O_NOFOLLOW if (!lp_symlinks(SNUM(conn))) { @@ -53,14 +53,15 @@ static BOOL fd_open(struct connection_struct *conn, #endif fsp->fh->fd = SMB_VFS_OPEN(conn,fname,fsp,flags,mode); - sav = errno; + if (fsp->fh->fd == -1) { + status = map_nt_error_from_unix(errno); + } DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", fname, flags, (int)mode, fsp->fh->fd, (fsp->fh->fd == -1) ? strerror(errno) : "" )); - errno = sav; - return fsp->fh->fd != -1; + return status; } /**************************************************************************** @@ -205,6 +206,7 @@ static NTSTATUS open_file(files_struct *fsp, uint32 access_mask, /* client requested access mask. */ uint32 open_access_mask) /* what we're actually using in the open. */ { + NTSTATUS status = NT_STATUS_OK; int accmode = (flags & O_ACCMODE); int local_flags = flags; BOOL file_existed = VALID_STAT(*psbuf); @@ -287,11 +289,12 @@ static NTSTATUS open_file(files_struct *fsp, } /* Actually do the open */ - if (!fd_open(conn, path, fsp, local_flags, unx_mode)) { + status = fd_open(conn, path, fsp, local_flags, unx_mode); + if (!NT_STATUS_IS_OK(status)) { DEBUG(3,("Error opening file %s (%s) (local_flags=%d) " "(flags=%d)\n", - path,strerror(errno),local_flags,flags)); - return map_nt_error_from_unix(errno); + path,nt_errstr(status),local_flags,flags)); + return status; } if ((local_flags & O_CREAT) && !file_existed) { @@ -332,7 +335,7 @@ static NTSTATUS open_file(files_struct *fsp, /* For a non-io open, this stat failing means file not found. JRA */ if (ret == -1) { - NTSTATUS status = map_nt_error_from_unix(errno); + status = map_nt_error_from_unix(errno); fd_close(conn, fsp); return status; } -- cgit