Index: /trunk/Ohana/src/addstar/src/UpdateDatabase_Image.c
===================================================================
--- /trunk/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 6236)
@@ -3,5 +3,5 @@
 int UpdateDatabase_Image (AddstarClientOptions *options, Image *image, Coords *mosaic, Stars *stars, int Nstars) {
 
-  int i, Noverlap;
+  int i, Noverlap, status;
   Image *overlap;
   Catalog catalog;
@@ -32,11 +32,10 @@
 
     set_db (&db);
-
-    /* XXX EAM : this should be SOFT, not XCLD */
-    lock_image_db (&db, ImageCat);
+    status = dvo_image_lock (&db, ImageCat, 60.0, LCK_SOFT);
+    if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
 
     /* load images / build overlap : XXX EAM : split into two functions? */
     overlap = gimages (&db, image, mosaic, &Noverlap);
-    unlock_image_db (&db);
+    dvo_image_unlock (&db);
   }
 
@@ -50,5 +49,5 @@
   if (options[0].only_match || options[0].existing_regions) {
     SkyList *tmp;
-    tmp = SkyListExistingSubset (skylist);
+    tmp = SkyListExistingSubset (skylist, CATDIR);
     SkyListFree (skylist, FALSE);
     skylist = tmp;
@@ -87,12 +86,11 @@
     set_db (&db);
 
-    lock_image_db (&db, ImageCat);
+    status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD);
+    if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
 
-    /* load images / build overlap : XXX EAM : split into two functions */
+    /* load images / build overlap : XXX EAM : split into two functions? */
     overlap = gimages (&db, image, mosaic, &Noverlap);
 
-    if (db.dbstate == LCK_EMPTY) {
-      create_image_db (&db);
-    }
+    if (db.dbstate == LCK_EMPTY) create_image_db (&db);
   
     /* write out new image */
@@ -101,5 +99,5 @@
     dvo_image_update (&db, VERBOSE);
     SetProtect (FALSE);
-    unlock_image_db (&db);
+    dvo_image_unlock (&db);
   }
   return (TRUE);
Index: /trunk/Ohana/src/addstar/src/UpdateDatabase_Refcat.c
===================================================================
--- /trunk/Ohana/src/addstar/src/UpdateDatabase_Refcat.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/UpdateDatabase_Refcat.c	(revision 6236)
@@ -44,5 +44,5 @@
   if (options[0].only_match || options[0].existing_regions) {
     SkyList *tmp;
-    tmp = SkyListExistingSubset (skylist);
+    tmp = SkyListExistingSubset (skylist, CATDIR);
     SkyListFree (skylist, FALSE);
     skylist = tmp;
Index: /trunk/Ohana/src/addstar/src/UpdateDatabase_Reflist.c
===================================================================
--- /trunk/Ohana/src/addstar/src/UpdateDatabase_Reflist.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/UpdateDatabase_Reflist.c	(revision 6236)
@@ -46,8 +46,8 @@
 
   /* reduce regions to existing subset, if necessary */
-  SkyListSetPath (skylist, CATDIR);
+  SkyListSetFilenames (skylist, CATDIR, "cpt");
   if (options[0].only_match || options[0].existing_regions) {
     SkyList *tmp;
-    tmp = SkyListExistingSubset (skylist);
+    tmp = SkyListExistingSubset (skylist, CATDIR);
     SkyListFree (skylist, FALSE);
     skylist = tmp;
Index: /trunk/Ohana/src/addstar/src/addstar.c
===================================================================
--- /trunk/Ohana/src/addstar/src/addstar.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/addstar.c	(revision 6236)
@@ -3,5 +3,5 @@
 int main (int argc, char **argv) {
 
-  int Nm, Na, Ns;
+  int Nm, Na, Ns, status;
   int i, Nstars, Noverlap, Nsubset, Naverage, Nmeasure;
   Stars *stars, **subset;
@@ -35,9 +35,9 @@
   }
 
-  /* we use the image table to lock db access -- perhaps this is not necessary?*/
-  lock_image_db (&db, ImageCat);
+  /* we use the image table to lock db access -- perhaps this is not necessary? */
+  status = dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD);
+  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
   gettimeofday (&stop, NULL);
   dtime = DTIME (stop, start);
-  fprintf (stderr, "mark: lock_image_db: time %9.4f sec\n", dtime);
 
   switch (options.mode) {
@@ -80,5 +80,4 @@
     if ((catalog.Nave_disk == 0) && options.only_match) {
       unlock_catalog (&catalog);
-      free (catalog.filename);
       continue;
     }
@@ -157,5 +156,5 @@
   }
   ohana_memcheck (FALSE);
-  /* unlock_image_db (&db); */
+  dvo_image_unlock (&db); /* unlock? */
 
   gettimeofday (&stop, NULL);
Index: /trunk/Ohana/src/addstar/src/addstard.c
===================================================================
--- /trunk/Ohana/src/addstar/src/addstard.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/addstard.c	(revision 6236)
@@ -13,5 +13,5 @@
   /* store the sky table in a global for internal use */
   ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
-  SkyTableSetFilename (ServerSky, CATDIR, "cpt");
+  SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
 
   /* if we separate the incoming data from db update, spawn db thread here */
Index: /trunk/Ohana/src/addstar/src/image-db.c
===================================================================
--- /trunk/Ohana/src/addstar/src/image-db.c	(revision 6235)
+++ /trunk/Ohana/src/addstar/src/image-db.c	(revision 6236)
@@ -1,34 +1,3 @@
 # include "addstar.h"
-
-void lock_image_db (FITS_DB *db, char *filename) {
-
-  /* lock the image catalog */
-  check_permissions (filename);
-
-  db[0].lockstate = LCK_XCLD;
-  db[0].timeout   = 3600.0;
-  fits_db_init (db);
-
-  if (!fits_db_lock (db, filename)) {
-    fprintf (stderr, "ERROR: can't lock image catalog\n");
-    exit (1);
-  }
-}
-
-void unlock_image_db (FITS_DB *db) {
-
-  mode_t mode;
-
-  fprintf (stderr, "closing file\n");
-  if (db[0].f == NULL) {
-    fprintf (stderr, "re-closing file??\n");
-  }
-  fits_db_close (db);
-  db[0].f = NULL;
-
-  /* force permissions to 666 */
-  mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-  chmod (db[0].filename, mode);
-}
 
 void create_image_db (FITS_DB *db) {
