diff options
author | Volker Lendecke <vl@samba.org> | 2014-09-14 13:10:58 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-12-16 18:56:03 +0100 |
commit | 7be1dfa05c6b3c9077f09fd29f6ffdd8ea4011ec (patch) | |
tree | f6522abd34c0c64aa57b2dc4ec27b013e89d1d58 /lib | |
parent | 10fdf4f5eb1f1c0a0f12050fe8241c3e92f715d9 (diff) | |
download | samba-7be1dfa05c6b3c9077f09fd29f6ffdd8ea4011ec.tar.gz samba-7be1dfa05c6b3c9077f09fd29f6ffdd8ea4011ec.tar.xz samba-7be1dfa05c6b3c9077f09fd29f6ffdd8ea4011ec.zip |
lib: Add map_unix_error_from_tdb
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util_tdb.c | 57 | ||||
-rw-r--r-- | lib/util/util_tdb.h | 7 |
2 files changed, 63 insertions, 1 deletions
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c index 811c2a40f7..f84ab3314e 100644 --- a/lib/util/util_tdb.c +++ b/lib/util/util_tdb.c @@ -426,3 +426,60 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err) }; return result; } + +int map_unix_error_from_tdb(enum TDB_ERROR err) +{ + int result = EINVAL; + + switch (err) { + case TDB_SUCCESS: + result = 0; + break; + case TDB_ERR_CORRUPT: + result = EILSEQ; + break; + case TDB_ERR_IO: + result = EIO; + break; + case TDB_ERR_OOM: + result = ENOMEM; + break; + case TDB_ERR_EXISTS: + result = EEXIST; + break; + + case TDB_ERR_LOCK: + /* + * TDB_ERR_LOCK is very broad, we could for example + * distinguish between fcntl locks and invalid lock + * sequences. EWOULDBLOCK is wrong, but there is no real + * generic lock error code in errno.h + */ + result = EWOULDBLOCK; + break; + + case TDB_ERR_NOLOCK: + case TDB_ERR_LOCK_TIMEOUT: + /* + * These two ones in the enum are not actually used + */ + result = ENOLCK; + break; + case TDB_ERR_NOEXIST: + result = ENOENT; + break; + case TDB_ERR_EINVAL: + result = EINVAL; + break; + case TDB_ERR_RDONLY: + result = EROFS; + break; + case TDB_ERR_NESTING: + /* + * Well, this db is already busy... + */ + result = EBUSY; + break; + }; + return result; +} diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h index 12c472c36d..7a457f736f 100644 --- a/lib/util/util_tdb.h +++ b/lib/util/util_tdb.h @@ -139,5 +139,10 @@ int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA d NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err); -#endif /* _____LIB_UTIL_UTIL_TDB_H__ */ +/**************************************************************************** + Return an errno from a TDB_ERROR +****************************************************************************/ +int map_unix_error_from_tdb(enum TDB_ERROR err); + +#endif /* _____LIB_UTIL_UTIL_TDB_H__ */ |