allow posix locking database to be opened read-only (for smbstatus)
authorAndrew Tridgell <tridge@samba.org>
Tue, 13 Jun 2000 15:46:46 +0000 (15:46 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 13 Jun 2000 15:46:46 +0000 (15:46 +0000)
(This used to be commit b9d78738bb30da3d989dfacc95cfde529f2afca5)

source3/locking/locking.c
source3/locking/posix.c

index 302b5b56c98b3c6b8f3586f66f3906bee2d7401d..8fc1c4a4bcdd627c2bae7d5471dc5eac68d1c577 100644 (file)
@@ -233,7 +233,7 @@ BOOL locking_init(int read_only)
                return False;
        }
        
-       if (!posix_locking_init())
+       if (!posix_locking_init(read_only))
                return False;
 
        return True;
index 6ab4bef4cc256550c0b636bf5370a6507726df4c..69df55ba3ca6099a54fccc5a9769e711c1591f4a 100644 (file)
@@ -1346,25 +1346,25 @@ void posix_locking_close_file(files_struct *fsp)
  Create the in-memory POSIX lock databases.
 ********************************************************************/
 
-BOOL posix_locking_init(void)
+BOOL posix_locking_init(int read_only)
 {
        if (posix_lock_tdb && posix_pending_close_tdb)
                return True;
-
+       
        if (!posix_lock_tdb)
                posix_lock_tdb = tdb_open(NULL, 0, TDB_INTERNAL,
-                                         O_RDWR|O_CREAT, 0644);
-    if (!posix_lock_tdb) {
-        DEBUG(0,("Failed to open POSIX byte range locking database.\n"));
+                                         read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644);
+       if (!posix_lock_tdb) {
+               DEBUG(0,("Failed to open POSIX byte range locking database.\n"));
                return False;
-    }
+       }
        if (!posix_pending_close_tdb)
                posix_pending_close_tdb = tdb_open(NULL, 0, TDB_INTERNAL,
-                   O_RDWR|O_CREAT, 0644);
-    if (!posix_pending_close_tdb) {
-        DEBUG(0,("Failed to open POSIX pending close database.\n"));
+                                                  read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644);
+       if (!posix_pending_close_tdb) {
+               DEBUG(0,("Failed to open POSIX pending close database.\n"));
                return False;
-    }
+       }
 
        return True;
 }