summaryrefslogtreecommitdiff
path: root/lib/ntdb/open.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-18 22:30:28 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-19 05:38:06 +0200
commit3bccb610c166df1ce2ea5c8a80daa451bd6edf67 (patch)
tree15d51fa61d52c29af1c65ecef0a7e5a51dcd56dc /lib/ntdb/open.c
parentc7273629a24feea03d60f17e706806c261130c57 (diff)
downloadsamba-3bccb610c166df1ce2ea5c8a80daa451bd6edf67.tar.gz
samba-3bccb610c166df1ce2ea5c8a80daa451bd6edf67.tar.bz2
samba-3bccb610c166df1ce2ea5c8a80daa451bd6edf67.zip
ntdb: use NTDB_LOG_WARNING level for failed open() without O_CREAT.
This is a fairly common pattern in Samba, and if we log an error on every open it spams the logs. On the other hand, other errors are potentially more serious, so we still use NTDB_LOG_ERROR on them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/open.c')
-rw-r--r--lib/ntdb/open.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ntdb/open.c b/lib/ntdb/open.c
index 8dce4ce6f2..56b504b5c0 100644
--- a/lib/ntdb/open.c
+++ b/lib/ntdb/open.c
@@ -517,9 +517,17 @@ _PUBLIC_ struct ntdb_context *ntdb_open(const char *name, int ntdb_flags,
ntdb->file->map_size = 0;
if ((ntdb->file->fd = open(name, open_flags, mode)) == -1) {
+ enum ntdb_log_level lvl;
/* errno set by open(2) */
saved_errno = errno;
- ntdb_logerr(ntdb, NTDB_ERR_IO, NTDB_LOG_ERROR,
+
+ /* Probing for files like this is a common pattern. */
+ if (!(open_flags & O_CREAT) && errno == ENOENT) {
+ lvl = NTDB_LOG_WARNING;
+ } else {
+ lvl = NTDB_LOG_ERROR;
+ }
+ ntdb_logerr(ntdb, NTDB_ERR_IO, lvl,
"ntdb_open: could not open file %s: %s",
name, strerror(errno));