summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-22 06:49:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:02:24 -0500
commit651f3903f0a380a951bfe5bf80322f1ab2330705 (patch)
treef96181de82ae443863b3c07bd692ee63e87b38a5 /source4
parent517238f0aa1a578aec69a40e92022a7636780c3a (diff)
downloadsamba-651f3903f0a380a951bfe5bf80322f1ab2330705.tar.gz
samba-651f3903f0a380a951bfe5bf80322f1ab2330705.tar.bz2
samba-651f3903f0a380a951bfe5bf80322f1ab2330705.zip
r3131: - make map_nt_error_from_unix() return NT_STATUS_UNSUCCESSFUL if errno is 0
- more consistent checking for system call return values in simple backend (This used to be commit 375a9a1347abf0b917cf94ea0cabcdea37d60e98)
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/util/errormap.c6
-rw-r--r--source4/ntvfs/simple/vfs_simple.c16
2 files changed, 7 insertions, 15 deletions
diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c
index 482743b03b..650dc55e50 100644
--- a/source4/libcli/util/errormap.c
+++ b/source4/libcli/util/errormap.c
@@ -1534,13 +1534,13 @@ const struct unix_error_map unix_dos_nt_errmap[] = {
/*********************************************************************
Map an NT error code from a Unix error code.
*********************************************************************/
-
NTSTATUS map_nt_error_from_unix(int unix_error)
{
int i = 0;
- if (unix_error == 0)
- return NT_STATUS_OK;
+ if (unix_error == 0) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
/* Look through list */
while(unix_dos_nt_errmap[i].unix_error != 0) {
diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c
index f72d557b58..faf8f17b78 100644
--- a/source4/ntvfs/simple/vfs_simple.c
+++ b/source4/ntvfs/simple/vfs_simple.c
@@ -262,8 +262,6 @@ static NTSTATUS svfs_qpathinfo(struct ntvfs_module_context *ntvfs,
DEBUG(19,("svfs_qpathinfo: file %s\n", unix_path));
if (stat(unix_path, &st) == -1) {
DEBUG(19,("svfs_qpathinfo: file %s errno=%d\n", unix_path, errno));
- if (errno == 0)
- errno = ENOENT;
return map_nt_error_from_unix(errno);
}
DEBUG(19,("svfs_qpathinfo: file %s, stat done\n", unix_path));
@@ -290,8 +288,6 @@ static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs,
}
if (fstat(info->generic.in.fnum, &st) == -1) {
- if (errno == 0)
- errno = ENOENT;
return map_nt_error_from_unix(errno);
}
@@ -372,15 +368,11 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs,
do_open:
fd = open(unix_path, flags, 0644);
if (fd == -1) {
- if (errno == 0)
- errno = ENOENT;
return map_nt_error_from_unix(errno);
}
if (fstat(fd, &st) == -1) {
DEBUG(9,("svfs_open: fstat errno=%d\n", errno));
- if (errno == 0)
- errno = ENOENT;
close(fd);
return map_nt_error_from_unix(errno);
}
@@ -465,7 +457,7 @@ static NTSTATUS svfs_rename(struct ntvfs_module_context *ntvfs,
unix_path1 = svfs_unix_path(ntvfs, req, ren->rename.in.pattern1);
unix_path2 = svfs_unix_path(ntvfs, req, ren->rename.in.pattern2);
- if (rename(unix_path1, unix_path2) != 0) {
+ if (rename(unix_path1, unix_path2) == -1) {
return map_nt_error_from_unix(errno);
}
@@ -593,7 +585,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs,
return NT_STATUS_INVALID_HANDLE;
}
- if (close(io->close.in.fnum) != 0) {
+ if (close(io->close.in.fnum) == -1) {
return map_nt_error_from_unix(errno);
}
@@ -669,7 +661,7 @@ static NTSTATUS svfs_setfileinfo(struct ntvfs_module_context *ntvfs,
case RAW_SFILEINFO_END_OF_FILE_INFO:
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
if (ftruncate(info->end_of_file_info.file.fnum,
- info->end_of_file_info.in.size) != 0) {
+ info->end_of_file_info.in.size) == -1) {
return map_nt_error_from_unix(errno);
}
break;
@@ -752,7 +744,7 @@ static NTSTATUS svfs_fsattr(struct ntvfs_module_context *ntvfs,
return ntvfs_map_fsattr(req, fs, ntvfs);
}
- if (stat(private->connectpath, &st) != 0) {
+ if (stat(private->connectpath, &st) == -1) {
return map_nt_error_from_unix(errno);
}