summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-02-21 01:55:08 +0000
committerJeremy Allison <jra@samba.org>2007-02-21 01:55:08 +0000
commit6558f66eb3b9d2ae94cac1d49d7396ad78ea1084 (patch)
tree39ac4323421ab0c23649144a89e54a57920c7d60
parentda9d79832d6660ee505a82307bb09f96d6f0cbb9 (diff)
downloadsamba-6558f66eb3b9d2ae94cac1d49d7396ad78ea1084.tar.gz
samba-6558f66eb3b9d2ae94cac1d49d7396ad78ea1084.tar.xz
samba-6558f66eb3b9d2ae94cac1d49d7396ad78ea1084.zip
r21480: Make fd_open match fd_close be translating
errno into an NTSTATUS immediately. Jeremy.
-rw-r--r--source/smbd/open.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 89474874cc5..13ec9f952fe 100644
--- a/source/smbd/open.c
+++ b/source/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;
}