Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit.c	(revision 25035)
@@ -180,5 +180,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit_skycells.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit_skycells.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit_skycells.c	(revision 25035)
@@ -55,5 +55,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/addstar.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/addstar.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/addstar.c	(revision 25035)
@@ -25,5 +25,5 @@
   options = args (argc, argv, options);
 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   if (sky == NULL) {
       fprintf (stderr, "ERROR: unable to load sky table data\n");
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/addstard.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/addstard.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/addstard.c	(revision 25035)
@@ -12,5 +12,5 @@
 
   /* store the sky table in a global for internal use */
-  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
 
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/addstart.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/addstart.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/addstart.c	(revision 25035)
@@ -12,5 +12,5 @@
 
   /* store the sky table in a global for internal use */
-  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
 
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/load2mass.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/load2mass.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/load2mass.c	(revision 25035)
@@ -16,5 +16,5 @@
 
   // load the full sky description table:
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/addstar/src/sedstar.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/addstar/src/sedstar.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/addstar/src/sedstar.c	(revision 25035)
@@ -15,5 +15,5 @@
   options = args_sedstar (argc, argv, options);
 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/delstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/delstar/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/delstar/src/ConfigInit.c	(revision 25035)
@@ -45,5 +45,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagefile.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagefile.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagefile.c	(revision 25035)
@@ -12,5 +12,5 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
Index: /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagename.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagename.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagename.c	(revision 25035)
@@ -15,5 +15,5 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
Index: /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_times.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_times.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/delstar/src/delete_times.c	(revision 25035)
@@ -15,5 +15,5 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
Index: /branches/eam_branches/20090715/Ohana/src/dvomerge/src/dvomerge.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/dvomerge/src/dvomerge.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/dvomerge/src/dvomerge.c	(revision 25035)
@@ -24,5 +24,5 @@
   // the first input define the photcode table & db layout
   sprintf (filename, "%s/Photcodes.dat", input1);
-  if (!LoadPhotcodes (filename, NULL)) {
+  if (!LoadPhotcodes (filename, NULL, FALSE)) {
     fprintf (stderr, "error loading photcode table %s\n", filename);
     exit (1);
@@ -30,5 +30,5 @@
   // save the photcodes in the output catdir
   sprintf (filename, "%s/Photcodes.dat", output);
-  if (!check_file_access (filename, TRUE, TRUE)) {
+  if (!check_file_access (filename, TRUE, TRUE, TRUE)) {
     fprintf (stderr, "error creating output catdir %s\n", output);
     exit (1);
@@ -40,12 +40,12 @@
 
   // load the sky table for the existing database
-  insky1 = SkyTableLoadOptimal (input1, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
+  insky1 = SkyTableLoadOptimal (input1, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (insky1, input1, "cpt");
 
-  insky2 = SkyTableLoadOptimal (input2, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
+  insky2 = SkyTableLoadOptimal (input2, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (insky2, input2, "cpt");
 
   // generate an output table populated at the desired depth
-  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, SKY_DEPTH, VERBOSE);
+  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (outsky, output, "cpt");
 
@@ -117,5 +117,5 @@
   // save the output sky table copy
   sprintf (filename, "%s/SkyTable.fits", output);
-  check_file_access (filename, TRUE, VERBOSE);
+  check_file_access (filename, TRUE, TRUE, VERBOSE);
   if (!SkyTableSave (outsky, filename)) {
     fprintf (stderr, "ERROR: failed to save sky table for %s\n", output);
Index: /branches/eam_branches/20090715/Ohana/src/dvosplit/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/dvosplit/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/dvosplit/src/ConfigInit.c	(revision 25035)
@@ -33,5 +33,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/dvosplit/src/dvosplit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/dvosplit/src/dvosplit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/dvosplit/src/dvosplit.c	(revision 25035)
@@ -18,5 +18,5 @@
 
   // load the sky table for the existing database
-  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
 
@@ -79,5 +79,5 @@
   // save sky table copy
   sprintf (filename, "%s/SkyTable.fits", CATDIR);
-  check_file_access (filename, TRUE, VERBOSE);
+  check_file_access (filename, TRUE, TRUE, VERBOSE);
   if (!SkyTableSave (sky, filename)) {
     fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
Index: /branches/eam_branches/20090715/Ohana/src/gastro/src/getptolemy.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/gastro/src/getptolemy.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/gastro/src/getptolemy.c	(revision 25035)
@@ -19,5 +19,5 @@
 
   /* load regions from GSC table, restrict to patch */
-  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   skylist = SkyListByPatch (sky, -1, &patch);
Index: /branches/eam_branches/20090715/Ohana/src/gastro2/src/getptolemy.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/gastro2/src/getptolemy.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/gastro2/src/getptolemy.c	(revision 25035)
@@ -21,5 +21,5 @@
 
   /* load regions from GSC table, restrict to patch */
-  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   skylist = SkyListByPatch (sky, -1, &patch);
Index: /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit.c	(revision 25035)
@@ -34,5 +34,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_coords.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_coords.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_coords.c	(revision 25035)
@@ -35,5 +35,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_extract.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_extract.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_extract.c	(revision 25035)
@@ -35,5 +35,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_overlaps.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_overlaps.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_overlaps.c	(revision 25035)
@@ -35,5 +35,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/getstar/src/getstar.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/getstar/src/getstar.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/getstar/src/getstar.c	(revision 25035)
@@ -13,5 +13,5 @@
   set_db (&db);
 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   if (!sky) exit (1);
     
Index: /branches/eam_branches/20090715/Ohana/src/imregister/base/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/imregister/base/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/imregister/base/ConfigInit.c	(revision 25035)
@@ -105,5 +105,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/imregister/imphot/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/imregister/imphot/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/imregister/imphot/ConfigInit.c	(revision 25035)
@@ -101,5 +101,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/doc/locking.txt
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/doc/locking.txt	(revision 25035)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/doc/locking.txt	(revision 25035)
@@ -0,0 +1,10 @@
+
+The DVO locking policy is a little bit broken.  DVO currently
+(2009.08.10) requires that users have write access to files because
+the code does not distinguish well cases where read-only (soft locks)
+are used vs cases of read/write (hard locks) are needed.
+
+DVO uses a somewhat strong locking policy in
+order to prevent users from getting inconsistent data.  This is good,
+but it prevents DVO letting users have read-only UNIX permissions on a
+database: it is necessary to have wrte from being able tb
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/include/dvo.h	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/include/dvo.h	(revision 25035)
@@ -325,5 +325,5 @@
 PhotCodeData *GetPhotcodeTable (void);
 
-int LoadPhotcodes (char *catdir_file, char *master_file);
+int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
 int LoadPhotcodesText (char *filename);
 int LoadPhotcodesFITS (char *filename);
@@ -432,5 +432,5 @@
 SkyTable  *SkyTableLoad        	   PROTO((char *filename, int VERBOSE));
 SkyTable  *SkyTableFromGSC     	   PROTO((char *filename, int depth, int VERBOSE));
-SkyTable  *SkyTableLoadOptimal 	   PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int depth, int VERBOSE));
+SkyTable  *SkyTableLoadOptimal 	   PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE));
 int        SkyTableSetDepth    	   PROTO((SkyTable *sky, int depth));
 SkyList   *SkyRegionByPoint    	   PROTO((SkyTable *table, int depth, double ra, double dec));
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/src/LoadPhotcodes.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/src/LoadPhotcodes.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/src/LoadPhotcodes.c	(revision 25035)
@@ -1,15 +1,20 @@
 # include <dvo.h>
 
-int LoadPhotcodes (char *catdir_file, char *master_file) {
+int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite) {
 
   /* first try to load the photcodes from the specified CATDIR location */
   if (LoadPhotcodesFITS (catdir_file)) return TRUE;
   
+  if (!readwrite) {
+    fprintf (stderr, "db is missing a photcode table & access is read-only -- create one with photcode-table -import\n");
+    return FALSE;
+  }
+
   /* next try to load the photcodes from the master text photcode file */
   /* automatically (or on demand?) save the text file to the FITS version */
   if (LoadPhotcodesText (master_file)) { 
-      if (!check_file_access (catdir_file, TRUE, TRUE)) return TRUE;
-      SavePhotcodesFITS (catdir_file);
-      return TRUE;
+    if (!check_file_access (catdir_file, TRUE, TRUE, TRUE)) return TRUE;
+    SavePhotcodesFITS (catdir_file);
+    return TRUE;
   }
 
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_catalog.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_catalog.c	(revision 25035)
@@ -180,4 +180,5 @@
 
   int Nsecfilt, mode;
+  int BACKUP, READWRITE;
 
   mode = DVO_OPEN_NONE;
@@ -192,9 +193,17 @@
   dvo_catalog_init (catalog, FALSE);
 
+  // default access control options:
   catalog[0].lockmode  = LCK_XCLD;
-  if (mode == DVO_OPEN_READ) catalog[0].lockmode  = LCK_SOFT;
+  BACKUP = TRUE;
+  READWRITE = TRUE;
+
+  // in read-only mode, do not backup or require write access
+  if (mode == DVO_OPEN_READ) {
+    catalog[0].lockmode  = LCK_SOFT;
+    BACKUP = FALSE;
+    READWRITE = FALSE;
+  }
   
-  // XXX make a backup?  always?
-  if (!check_file_access (catalog[0].filename, TRUE, VERBOSE)) {
+  if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
     if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
     return (FALSE);
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_image.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_image.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_image.c	(revision 25035)
@@ -4,6 +4,16 @@
 int dvo_image_lock (FITS_DB *db, char *filename, double timeout, int lockstate) {
 
-  /* lock the image catalog */
-  if (!check_file_access (filename, FALSE, TRUE)) return (FALSE);
+  int READWRITE;
+
+  // default access control options:
+  READWRITE = TRUE;
+
+  // in read-only mode, do not backup or require write access
+  if (lockstate == LCK_SOFT) {
+    READWRITE = FALSE;
+  }
+
+  // do not perform a backup here
+  if (!check_file_access (filename, FALSE, READWRITE, TRUE)) return (FALSE);
 
   db[0].lockstate = lockstate;
Index: /branches/eam_branches/20090715/Ohana/src/libdvo/src/skyregion_io.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libdvo/src/skyregion_io.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libdvo/src/skyregion_io.c	(revision 25035)
@@ -84,5 +84,5 @@
 }
 
-SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int depth, int verbose) {
+SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int readwrite, int depth, int verbose) {
 
   char filename[256];
@@ -93,5 +93,5 @@
   sprintf (filename, "%s/SkyTable.fits", catdir);
   if (stat (filename, &filestat)) goto SKYFILE;
-  if (!check_file_access (filename, FALSE, verbose)) goto SKYFILE;
+  if (!check_file_access (filename, FALSE, readwrite, verbose)) goto SKYFILE;
   sky = SkyTableLoad (filename, verbose);
   if (sky == NULL) {
@@ -106,5 +106,5 @@
   if (skyfile[0] != 0) goto GSCFILE;
   if (stat (skyfile, &filestat)) goto GSCFILE;
-  if (!check_file_access (skyfile, FALSE, verbose)) goto GSCFILE;
+  if (!check_file_access (skyfile, FALSE, readwrite, verbose)) goto GSCFILE;
   sky = SkyTableLoad (skyfile, verbose);
   if (sky == NULL) {
@@ -117,5 +117,5 @@
   /* create CATDIR copy */
   sprintf (filename, "%s/SkyTable.fits", catdir);
-  check_file_access (filename, FALSE, verbose);
+  check_file_access (filename, FALSE, readwrite, verbose);
   if (!SkyTableSave (sky, filename)) return NULL;
 
@@ -134,5 +134,5 @@
   /* create CATDIR copy */
   sprintf (filename, "%s/SkyTable.fits", catdir);
-  check_file_access (filename, FALSE, verbose);
+  check_file_access (filename, FALSE, readwrite, verbose);
   if (!SkyTableSave (sky, filename)) return NULL;
 
Index: /branches/eam_branches/20090715/Ohana/src/libohana/include/ohana.h
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libohana/include/ohana.h	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libohana/include/ohana.h	(revision 25035)
@@ -166,5 +166,5 @@
 int     mkdirhier              PROTO((char *path, int mode));
 void    make_backup            PROTO((char *filename));
-int     check_file_access      PROTO((char *basefile, int backup, int verbose));
+int     check_file_access      PROTO((char *basefile, int backup, int readwrite, int verbose));
 int     check_dir_access       PROTO((char *path, int verbose));
 int     check_file_exec        PROTO((char *filename));
Index: /branches/eam_branches/20090715/Ohana/src/libohana/src/findexec.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/libohana/src/findexec.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/libohana/src/findexec.c	(revision 25035)
@@ -67,5 +67,5 @@
    - file backup permission OK (optional)
 */
-int check_file_access (char *basefile, int BACKUP, int VERBOSE) {
+int check_file_access (char *basefile, int BACKUP, int READWRITE, int VERBOSE) {
   
   char *path, *filename;
@@ -74,7 +74,12 @@
   gid_t gid;
   int status;
+  int valid;
 
   uid = getuid();
   gid = getgid();
+
+  // XXX this function needs to call 'getgroups' to get the full list of the user's
+  // groups.  we would then need to loop over all groups in the gid test below 
+  // to see if any match the file.  test to see how slow this is.
 
   /* check permission to write to directory */
@@ -87,8 +92,18 @@
   status = stat (basefile, &filestat);
   if (status == 0) { /* file exists, are permissions OK? */
-    if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
-	((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) || 
-	((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
-    } else {
+    valid = FALSE;
+    if (!valid && (uid == filestat.st_uid)) {
+      valid = (filestat.st_mode & S_IRUSR) != 0;
+      valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
+    }
+    if (!valid && (gid == filestat.st_gid)) {
+      valid = (filestat.st_mode & S_IRGRP) != 0;
+      valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
+    }
+    if (!valid) {
+      valid = (filestat.st_mode & S_IROTH) != 0;
+      valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
+    }
+    if (!valid) {
       if (VERBOSE) fprintf (stderr, "can't write to %s\n", basefile);
       return (FALSE);
@@ -102,8 +117,18 @@
     status = stat (filename, &filestat);
     if (status == 0) { /* file exists, are permissions OK? */
-      if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
-	  ((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) || 
-	  ((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
-      } else {
+      valid = FALSE;
+      if (!valid && (uid == filestat.st_uid)) {
+	valid = (filestat.st_mode & S_IRUSR) != 0;
+	valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
+      }
+      if (!valid && (gid == filestat.st_gid)) {
+	valid = (filestat.st_mode & S_IRGRP) != 0;
+	valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
+      }
+      if (!valid) {
+	valid = (filestat.st_mode & S_IROTH) != 0;
+	valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
+      }
+      if (!valid) {
 	if (VERBOSE) fprintf (stderr, "can't write to %s\n", filename);
 	return (FALSE);
Index: /branches/eam_branches/20090715/Ohana/src/markrock/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/markrock/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/markrock/src/ConfigInit.c	(revision 25035)
@@ -44,5 +44,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/markrock/src/markrock.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/markrock/src/markrock.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/markrock/src/markrock.c	(revision 25035)
@@ -33,6 +33,6 @@
 
   /* if lockfile exists, program will complain and quit */
-  if (!check_file_access (argv[1], TRUE, TRUE)) exit (1);
-  if (!check_file_access (RockCat, TRUE, TRUE)) exit (1);
+  if (!check_file_access (argv[1], TRUE, TRUE, TRUE)) exit (1);
+  if (!check_file_access (RockCat, TRUE, TRUE, TRUE)) exit (1);
 
   catalog.filename = argv[1];
Index: /branches/eam_branches/20090715/Ohana/src/markstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/markstar/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/markstar/src/ConfigInit.c	(revision 25035)
@@ -54,5 +54,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/mosastro/src/getptolemy.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/mosastro/src/getptolemy.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/mosastro/src/getptolemy.c	(revision 25035)
@@ -19,5 +19,5 @@
 
   /* load regions from GSC table, restrict to patch */
-  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   skylist = SkyListByPatch (sky, -1, &patch);
Index: /branches/eam_branches/20090715/Ohana/src/opihi/cmd.data/Makefile
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/opihi/cmd.data/Makefile	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/opihi/cmd.data/Makefile	(revision 25035)
@@ -97,4 +97,5 @@
 $(SRC)/rebin.$(ARCH).o		\
 $(SRC)/resize.$(ARCH).o	\
+$(SRC)/relocate.$(ARCH).o	\
 $(SRC)/roll.$(ARCH).o		\
 $(SRC)/rotate.$(ARCH).o	\
Index: /branches/eam_branches/20090715/Ohana/src/opihi/dvo/photometry.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/opihi/dvo/photometry.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/opihi/dvo/photometry.c	(revision 25035)
@@ -325,5 +325,7 @@
     return (FALSE);
   }
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+
+  // XXX now that DVO does not allow write access, we can drop the MasterPhotcodeFile
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
     gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     return (FALSE);
Index: /branches/eam_branches/20090715/Ohana/src/opihi/dvo/region_list.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/opihi/dvo/region_list.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/opihi/dvo/region_list.c	(revision 25035)
@@ -42,5 +42,5 @@
 
   if (sky != NULL) SkyTableFree (sky);
-  sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, skydepth, verbose);
+  sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, FALSE, skydepth, verbose);
   if (sky == NULL) return FALSE;
 
Index: /branches/eam_branches/20090715/Ohana/src/photdbc/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/photdbc/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/photdbc/src/ConfigInit.c	(revision 25035)
@@ -64,5 +64,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/photdbc/src/photdbc.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/photdbc/src/photdbc.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/photdbc/src/photdbc.c	(revision 25035)
@@ -17,5 +17,5 @@
 
   // the output catalog needs to inherit the SKY_DEPTH of the input catalog
-  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, TRUE, SKY_DEPTH_HST, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   skylist = SkyListByPatch (sky, -1, &REGION);
Index: /branches/eam_branches/20090715/Ohana/src/relastro/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relastro/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relastro/src/ConfigInit.c	(revision 25035)
@@ -60,5 +60,5 @@
   /* update master photcode table if not defined */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/relastro/src/load_images.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relastro/src/load_images.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relastro/src/load_images.c	(revision 25035)
@@ -11,5 +11,5 @@
 
   // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/relastro/src/relastro_objects.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relastro/src/relastro_objects.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relastro/src/relastro_objects.c	(revision 25035)
@@ -11,5 +11,5 @@
 
   // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/relphot/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relphot/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relphot/src/ConfigInit.c	(revision 25035)
@@ -58,5 +58,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
Index: /branches/eam_branches/20090715/Ohana/src/relphot/src/load_images.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relphot/src/load_images.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relphot/src/load_images.c	(revision 25035)
@@ -11,5 +11,5 @@
 
   // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/relphot/src/relphot_objects.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/relphot/src/relphot_objects.c	(revision 25035)
@@ -11,5 +11,5 @@
 
   // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
+  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   
Index: /branches/eam_branches/20090715/Ohana/src/uniphot/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/uniphot/src/ConfigInit.c	(revision 25034)
+++ /branches/eam_branches/20090715/Ohana/src/uniphot/src/ConfigInit.c	(revision 25035)
@@ -36,5 +36,5 @@
   /* XXX this does not yet write out the master photcode table */
   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
-  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     exit (1);
