diff options
author | Jeremy Allison <jra@samba.org> | 2007-02-21 01:55:08 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:18:07 -0500 |
commit | a9dbdf937c4901c4e791bff0753bafe709bc0fa5 (patch) | |
tree | 49b37b35ba73ff9bcb212302619589dc33a02f7a /source3 | |
parent | cedcf06b22bb30ca52a8bbb21fd331ec20ef9180 (diff) | |
download | samba-a9dbdf937c4901c4e791bff0753bafe709bc0fa5.tar.gz samba-a9dbdf937c4901c4e791bff0753bafe709bc0fa5.tar.bz2 samba-a9dbdf937c4901c4e791bff0753bafe709bc0fa5.zip |
r21480: Make fd_open match fd_close be translating
errno into an NTSTATUS immediately.
Jeremy.
(This used to be commit 71dd02cc164197152e76d8141f906390c4bd1526)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/open.c | 21 |
1 files changed, 12 insertions, 9 deletions
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; } |