From: Jeremy Allison Date: Thu, 12 May 2016 19:14:28 +0000 (+0200) Subject: s3: lib: util: Add map_process_lock_to_ofd_lock() utility function. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=598538316786188f2d91c6e2c343c8051e27fd68;p=metze%2Fsamba%2Fwip.git s3: lib: util: Add map_process_lock_to_ofd_lock() utility function. Signed-off-by: Jeremy Allison Reviewed-by: Jeff Layton --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 15e0095f882d..36a54992561a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -386,6 +386,7 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist); void free_namearray(name_compare_entry *name_array); bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type); bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid); +int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks); bool is_myname(const char *s); void ra_lanman_string( const char *native_lanman ); const char *get_remote_arch_str(void); diff --git a/source3/lib/util.c b/source3/lib/util.c index 36a27504b9f3..ad3362423b41 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1184,6 +1184,37 @@ bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pi return True; } +#if defined(HAVE_OFD_LOCKS) +int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks) +{ + switch (op) { + case F_GETLK: + case F_OFD_GETLK: + op = F_OFD_GETLK; + break; + case F_SETLK: + case F_OFD_SETLK: + op = F_OFD_SETLK; + break; + case F_SETLKW: + case F_OFD_SETLKW: + op = F_OFD_SETLKW; + break; + default: + *use_ofd_locks = false; + return -1; + } + *use_ofd_locks = true; + return op; +} +#else /* HAVE_OFD_LOCKS */ +int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks) +{ + *use_ofd_locks = false; + return op; +} +#endif /* HAVE_OFD_LOCKS */ + #undef DBGC_CLASS #define DBGC_CLASS DBGC_ALL