Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1583 - trunk: . fsvs fsvs/src fsvs/src/dox

fsvs
Discussion topic

Back to topic list

svn commit: r1583 - trunk: . fsvs fsvs/src fsvs/src/dox

Author pmarek
Full name P.Marek
Date 2008-04-03 22:13:03 PDT
Message Author: pmarek
Date: 2008-04-03 22:13:03-0700
New Revision: 1583

Modified:
   trunk/ (props changed)
   trunk/fsvs/CHANGES
   trunk/fsvs/src/dox/options.dox
   trunk/fsvs/src/fsvs.c
   trunk/fsvs/src/interface.h
   trunk/fsvs/src/options.c
   trunk/fsvs/src/options.h
   trunk/fsvs/src/sync.c
   trunk/fsvs/src/waa.c

Log:
Dont parse $FSVS_WAA and $FSVS_CONF specially, just use normal option parsing.
Small bits of documentation updates.




Modified: trunk/fsvs/CHANGES
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/CHANGES​?view=diff&rev=1​583&p1=trunk/fsv​s/CHANGES&p2=tru​nk/fsvs/CHANGES&​r1=1582&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/CHANGES (original)
+++ trunk/fsvs/CHANGES 2008-04-03 22:13:03-0700
@@ -1,6 +1,10 @@
 Changes since 1.1.14
 - FSVS_WARNINGS removed. Use FSVS_WARNING.
 - Small fixes.
+- Handling of FSVS_WAA and FSVS_CONF now via the normal option handling, to
+ reduce code size. Now it's possible to use "-oconf=..." on the command
+ line, too.
+ (But it's not possible to override the paths from the config file.)
 
 Changes since 1.1.13
 - New option for conflict handling; allows "stop" (historical default),

Modified: trunk/fsvs/src/dox/options.dox
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/dox​/options.dox?view=di​ff&rev=1583&​p1=trunk/fsvs/src/do​x/options.dox&p2​=trunk/fsvs/src/dox/​options.dox&r1=1​582&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/src/dox/options.dox (original)
+++ trunk/fsvs/src/dox/options.dox 2008-04-03 22:13:03-0700
@@ -13,6 +13,7 @@
 <LI>\c colordiff - \ref o_colordiff
 <LI>\c commit_to - \ref o_commit_to
 <LI>\c conflict - \ref o_conflict
+<LI>\c conf - \ref o_conf. </UL>
 <LI>\c copyfrom_exp - \ref o_copyfrom_exp
 <LI>\c debug_output - \ref o_debug_output
 <LI>\c delay - \ref o_delay
@@ -26,7 +27,7 @@
 <LI>\c softroot - \ref o_softroot
 <LI>\c stat_color - \ref o_status_color
 <LI>\c warning - \ref o_warnings, but see \ref glob_opt_warnings "-W".
-</UL>
+<LI>\c waa - \ref o_waa. </UL>
 
 
 \section o__prio Priorities for option setting
@@ -442,5 +443,22 @@
 \endcode
 
 
+\section o_conf Path definitions for the config and WAA area
+
+\anchor o_waa
+
+The path given here is used to store the persistent configuration data
+needed by FSVS; please see \ref waa_files and \ref o__prio for more
+details, and the \ref o_softroot parameter as well as the \ref
+howto_backup_recovery for further discussion.
+
+\code
+ FSVS_CONF=/home/user/.fsvs-conf fsvs -o waa=/home/user/.fsvs-waa st
+\endcode
+
+\note Please note that these paths can be given \b only as environment
+variables (\c $FSVS_CONF resp. \c $FSVS_WAA) or as command line parameter;
+settings in config files are ignored.
+
  */
 // vi: filetype=doxygen spell spelllang=en_gb formatoptions+=ta :

Modified: trunk/fsvs/src/fsvs.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/fsv​s.c?view=diff&re​v=1583&p1=trunk/​fsvs/src/fsvs.c&​p2=trunk/fsvs/src/fs​vs.c&r1=1582​&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/src/fsvs.c (original)
+++ trunk/fsvs/src/fsvs.c 2008-04-03 22:13:03-0700
@@ -717,9 +717,9 @@
                 "Environment variables:\n"
                 "\n"
                 "$FSVS_CONF defines the location of the FSVS Configuration area\n"
- " Default is /etc/fsvs, but any writeable directory is allowed.\n"
+ " Default is " DEFAULT_CONF_PATH ", but any writeable directory is allowed.\n"
                 "$FSVS_WAA defines the location of the Working copy Administrative Area\n"
- " Default is /var/spool/fsvs, but any writeable directory is allowed.\n"
+ " Default is " DEFAULT_WAA_PATH ", but any writeable directory is allowed.\n"
                 );
     }
 
@@ -1197,7 +1197,9 @@
         DEBUGP("argument %d: %s", eo_args, args[eo_args]);
 
 
- /* waa__init() depends on some global settings, so do here. */
+ /* waa__init() depends on some global settings, so do here.
+ * Must happen before loading values, as the WAA and CONF paths get
+ * fixed. */
     STOPIF( waa__init(), NULL);
 
     /* Load options from config file, whose path is specified eg. via

Modified: trunk/fsvs/src/interface.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/int​erface.h?view=diff​&rev=1583&p1=t​runk/fsvs/src/interf​ace.h&p2=trunk/f​svs/src/interface.h​&r1=1582&r2=1​583
====================​====================​====================​==================
--- trunk/fsvs/src/interface.h (original)
+++ trunk/fsvs/src/interface.h 2008-04-03 22:13:03-0700
@@ -20,17 +20,6 @@
  * environment variables and similar. */
 /** @{ */
 
-/** \anchor envs
- * \name Environment variables
- * @{ */
-/** The environment variable to override the spool
- * directory (default /var/spool/fsvs). */
-#define WAA__PATH_ENV "FSVS_WAA"
-
-/** The environment variable to override the configuration directory
- * (default /etc/fsvs). */
-#define CONF__PATH_ENV "FSVS_CONF"
-
 /** If this variable has a numeric value other than 0, the debuglevel is
  * set even before commandline parsing. */
 #define FSVS_DEBUG_ENV "FSVS_DEBUGLEVEL"
@@ -50,6 +39,12 @@
 /** @} */
 
 
+/** The default WAA path. */
+#define DEFAULT_WAA_PATH "/var/spool/fsvs"
+/** The default CONF path. */
+#define DEFAULT_CONF_PATH "/etc/fsvs"
+
+
 /** \name List of environment variables used for a chroot jail.
  * Note that these are not \c \#ifdef - marked, as we'd like to use
  * off-the-shelf binaries from newer distributions without modifications!

Modified: trunk/fsvs/src/options.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/opt​ions.c?view=diff​&rev=1583&p1=tru​nk/fsvs/src/options.​c&p2=trunk/fsvs/​src/options.c&r1​=1582&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/src/options.c (original)
+++ trunk/fsvs/src/options.c 2008-04-03 22:13:03-0700
@@ -10,6 +10,7 @@
 
 #include "global.h"
 #include "log.h"
+#include "interface.h"
 #include "options.h"
 #include "helper.h"
 #include "warnings.h"
@@ -183,6 +184,21 @@
         .name="commit_to", .cp_val=NULL, .parse=opt___store_string,
     },
 
+ /* I thought about using opt___normalized_path() for these two; but that
+ * would be a change in behaviour. */
+ [OPT__WAA_PATH] = {
+ .name="waa", .parse=opt___store_string,
+ /* Doing that here gives a warning "initializer not constant".
+ .cp_val=DEFAULT_WAA_PATH, .i_val=strlen(DEFAUL​T_WAA_PATH), */
+ .cp_val=NULL, .i_val=0,
+ },
+ [OPT__CONF_PATH] = {
+ .name="conf", .parse=opt___store_string,
+ /* Doing that here gives a warning "initializer not constant".
+ .cp_val=DEFAULT_CONF_PATH, .i_val=strlen(DEFAUL​T_CONF_PATH), */
+ .cp_val=NULL, .i_val=0,
+ },
+
     [OPT__EMPTY_COMMIT] = {
         .name="empty_commit", .i_val=OPT__YES,
         .parse=opt___string2val, .parm=opt___yes_no_auto+1,

Modified: trunk/fsvs/src/options.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/opt​ions.h?view=diff​&rev=1583&p1=tru​nk/fsvs/src/options.​h&p2=trunk/fsvs/​src/options.h&r1​=1582&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/src/options.h (original)
+++ trunk/fsvs/src/options.h 2008-04-03 22:13:03-0700
@@ -85,9 +85,16 @@
      * See \ref o_delay. */
     OPT__DELAY,
     /** Do expensive copyfrom checks?
- * See \ref o_copyfrom_exp*/
+ * See \ref o_copyfrom_exp */
     OPT__COPYFROM_EXP,
 
+ /** The base path of the WAA.
+ * See \ref o_waa. */
+ OPT__WAA_PATH,
+ /** The base path of the configuration area.
+ * See \ref o_conf. */
+ OPT__CONF_PATH,
+
     /** End of enum marker. */
     OPT__COUNT
 };

Modified: trunk/fsvs/src/sync.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/syn​c.c?view=diff&re​v=1583&p1=trunk/​fsvs/src/sync.c&​p2=trunk/fsvs/src/sy​nc.c&r1=1582​&r2=1583
====================​====================​====================​==================
--- trunk/fsvs/src/sync.c (original)
+++ trunk/fsvs/src/sync.c 2008-04-03 22:13:03-0700
@@ -29,7 +29,7 @@
  *
  * This is normally not needed; the use cases are
  * - debugging and
- * - recovering from data loss in \c $FSVS_WAA (\c /var/spool/fsvs ).
+ * - recovering from data loss in \ref o_waa "$FSVS_WAA".
  *
  * It is (currently) important if you want to backup two similar
  * machines. Then you can commit one machine into a subdirectory of your

Modified: trunk/fsvs/src/waa.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/waa​.c?view=diff&rev​=1583&p1=trunk/f​svs/src/waa.c&p2​=trunk/fsvs/src/waa.​c&r1=1582&r2​=1583
====================​====================​====================​==================
--- trunk/fsvs/src/waa.c (original)
+++ trunk/fsvs/src/waa.c 2008-04-03 22:13:03-0700
@@ -51,19 +51,12 @@
 /** The extension temporary files in the WAA get. */
 static const char ext_tmp[]=".tmp";
 
-/** The base path of the WAA. */
-static char const *waa_path;
-/** The length of \ref waa_path. */
-static int waa_len;
-/** The base path of the configuration area. */
-static char const *conf_path;
-/** The length of \ref conf_path. */
-static int conf_len;
 
 /** -.
- * They are long enough to hold \ref waa_path plus the 3-level deep
- * subdirectory structure for cache and data files.
- * The \ref conf_path plus additional data gets it own buffers.
+ * They are long enough to hold the \ref OPT__WAA_PATH "waa path" plus the
+ * 3-level deep subdirectory structure for cache and data files.
+ * The \ref OPT__CONF_PATH "conf path" plus additional data gets it own
+ * buffers.
  * @{ */
 char *waa_tmp_path, *waa_tmp_fn,
                         *conf_tmp_path, *conf_tmp_fn;
@@ -126,15 +119,16 @@
 
 
 /** Convenience function for creating two paths. */
-inline void waa___init_path(char *dest, const char *const src,
- int *len, char **eos)
+inline void waa___init_path(enum opt__settings_e which,
+ char *dest, char **eos)
 {
     int l;
 
 
     l=0;
     if (strncmp(opt__get_st​ring(OPT__SOFTROOT),​
- src, opt__get_int(OPT__SOFTROOT)) != 0 )
+ opt__get_string(which),
+ opt__get_int(OPT__SOFTROOT)) != 0 )
     {
         strcpy(dest, opt__get_string(OPT_​_SOFTROOT));
         l=opt__get_int(OPT__SOFTROOT);
@@ -143,7 +137,7 @@
       dest[l++]=PATH_SEPARATOR;
     }
 
- l+= strlen( strcpy(dest+l, src) );
+ l+= strlen( strcpy(dest+l, opt__get_string(which) ) );
 
     /* ensure a delimiter */
     if (dest[l-1] != PATH_SEPARATOR)
@@ -153,9 +147,10 @@
     }
 
     *eos=dest + l;
- *len=l;
+ opt__set_int(which, PRIO_MUSTHAVE, l);
 }
 
+
 /** -.
  * If not a WAA-less operation, find the WAA and define an ignore
  * pattern. */
@@ -168,36 +163,49 @@
     /* If we're doing an import/export operation, we must not use the waa
      * area. We may be running off a KNOPPIX CD, or whatever.
      *
- * What we *need* is the conf directory ... it might have options for us.
- *
- * So waa_path is NULL, and serves as a validation point - every access
- * tried will get a SEGV and can be debugged. */
- conf_path=getenv(CON​F__PATH_ENV);
- if (!conf_path ) conf_path="/etc/fsvs";
+ * What we *need* is the conf directory ... it might have options for us.
+ * */
+
+ /** \todo remove when gcc doesn't warn about \c strlen("const")
+ * initializers. See debian bug #60xxxx.
+ * And see below for WAA_PATH, too. */
+ if (opt__get_int(OPT__C​ONF_PATH)==0)
+ {
+ opt__set_string(OPT__CONF_PATH, PRIO_MUSTHAVE, DEFAULT_CONF_PATH);
+ opt__set_int(OPT__CONF_PATH, PRIO_MUSTHAVE, strlen(DEFAULT_CONF_PATH));
+ }
+
 
     /* at least /w or some such */
- conf_len=strlen(conf_path);
- STOPIF_CODE_ERR( conf_len<3, EINVAL,
- "environment variable " CONF__PATH_ENV " should be set to a directory");
+ STOPIF_CODE_ERR( opt__get_int(OPT__CO​NF_PATH)<3, EINVAL,
+ "The CONF path is invalid; a (non-root) path is expected.");
 
 
- if (!action->is_import_export)
+ if (action->is_import_export)
+ {
+ /* So the WAA path is NULL, and serves as a validation point - every
+ * access tried will get a SEGV and can be debugged. */
+ opt__set_string(OPT__WAA_PATH, PRIO_MUSTHAVE, NULL);
+ opt__set_int(OPT__WAA_PATH, PRIO_MUSTHAVE, 0);
+ }
+ else
     {
- waa_path=getenv(WAA__PATH_ENV);
- if (!waa_path ) waa_path="/var/spool/fsvs";
+ if (opt__get_int(OPT__W​AA_PATH)==0)
+ {
+ opt__set_string(OPT__WAA_PATH, PRIO_MUSTHAVE, DEFAULT_WAA_PATH);
+ opt__set_int(OPT__WAA_PATH, PRIO_MUSTHAVE, strlen(DEFAULT_WAA_PATH));
+ }
 
- waa_len=strlen(waa_path);
- STOPIF_CODE_ERR( waa_len<3, EINVAL,
- "environment variable " WAA__PATH_ENV " should be set to a directory");
+ STOPIF_CODE_ERR( opt__get_int(OPT__WA​A_PATH)<3, EINVAL,
+ "The WAA path should be set to a directory below \"/\".");
 
         /* validate existence and save dev/inode for later checking */
- STOPIF( hlp__lstat(waa_path, &waa_stat),
+ STOPIF( hlp__lstat(opt__get_​string(OPT__WAA_PATH​), &waa_stat),
                 "stat() of waa-path '%s' failed. "
- "Does your local storage area exist? ", waa_path);
+ "Does your local storage area exist? ",
+ opt__get_string(OPT_​_WAA_PATH));
         DEBUGP("got the WAA as inode %llu", (t_ull)waa_stat.ino);
     }
- else
- waa_len=0;
 
 
     /* This memory has lifetime of the process.
@@ -205,21 +213,24 @@
      * The memory allocated is enough for the longest possible path. */
     waa_tmp_path_len=
         opt__get_int(OPT__SOFTROOT) + 1 +
- (waa_len > conf_len ? waa_len : conf_len) + 1 +
+ ( max(opt__get_int(OPT​__WAA_PATH),
+ opt__get_int(OPT__CONF_PATH)) ) + 1 +
         APR_MD5_DIGESTSIZE*2 + 3 +
         WAA__MAX_EXT_LENGTH + strlen(ext_tmp) + 1 +4;
     DEBUGP("using %d bytes for temporary WAA+conf paths", waa_tmp_path_len);
 
+ /* Here the paths are set at highest priority, so they can't get changed
+ * afterwards. */
     conf_tmp_path=malloc​(waa_tmp_path_len);
     STOPIF_ENOMEM(!conf_tmp_path);
- waa___init_path(conf_tmp_path, conf_path, &conf_len, &conf_tmp_fn);
+ waa___init_path(OPT__CONF_PATH, conf_tmp_path, &conf_tmp_fn);
 
     if (!action->is_import_export)
     {
         waa_tmp_path=malloc(​waa_tmp_path_len);
         STOPIF_ENOMEM(!waa_tmp_path);
 
- waa___init_path(waa_tmp_path, waa_path, &waa_len, &waa_tmp_fn);
+ waa___init_path(OPT__WAA_PATH, waa_tmp_path, &waa_tmp_fn);
     }
 
 ex:

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1583 - trunk: . fsvs fsvs/src fsvs/src/dox pmarek P.Marek 2008-04-03 22:13:03 PDT
Messages per page: