s3: lib: util: Add map_process_lock_to_ofd_lock() utility function.
authorJeremy Allison <jra@samba.org>
Thu, 12 May 2016 19:14:28 +0000 (21:14 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 20 May 2016 23:28:28 +0000 (01:28 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jeff Layton <jlayton@samba.org>
source3/include/proto.h
source3/lib/util.c

index 15e0095f882da177604673c1cb00853618918833..36a54992561ae9130a9523c2274d9b9b93e95d7f 100644 (file)
@@ -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);
index 36a27504b9f3ab12ea5da5ee443222e63ad0fb47..ad3362423b41279c192c72853f1da5ea3562dced 100644 (file)
@@ -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