Author: adrian.chadd
Date: Wed Jul  8 04:39:13 2009
New Revision: 14156

Modified:
    playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_rebuild.c

Log:
Add in a command parameter to tell ufs_rebuild what to try.

The options are "probe and do what you can", "force dir build" and
"force log build."



Modified: playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_rebuild.c
==============================================================================
--- playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_rebuild.c  (original)
+++ playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_rebuild.c  Wed Jul  8  
04:39:13 2009
@@ -1,6 +1,7 @@
  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>
+#include <string.h>

  #include "include/config.h"
  #include "include/squid_md5.h"
@@ -23,23 +24,51 @@
        REBUILD_LOG
  } rebuild_type_t;

+static rebuild_type_t
+probe_dir(store_ufs_dir_t *u)
+{
+       if (store_ufs_has_valid_rebuild_log(u))
+               return REBUILD_LOG;
+       return REBUILD_DISK;
+}
+
+static void
+usage(const char *cmdname)
+{
+       printf("Usage: %s <command> <store path> <l1> <l2> <path to 
swapfile>\n",  
cmdname);
+       printf("  where <command> is one of rebuild-dir, rebuild-log or  
rebuild.\n");
+}
+
+
  int
  main(int argc, char *argv[])
  {
+       const char *cmd;
+       store_ufs_dir_t store_ufs_info;
+       rebuild_type_t rebuild_type;
+
        /* Setup the debugging library */
        _db_init("ALL,1");
        _db_set_stderr_debug(1);
-       store_ufs_dir_t store_ufs_info;
-       rebuild_type_t rebuild_type;

        if (argc < 5) {
-               printf("Usage: %s <store path> <l1> <l2> <path to swapfile>\n", 
argv[0]);
+               usage(argv[0]);
                exit(1);
        }
+       cmd = argv[1];

-       store_ufs_init(&store_ufs_info, argv[1], atoi(argv[2]), atoi(argv[3]),  
argv[4]);
+       store_ufs_init(&store_ufs_info, argv[2], atoi(argv[3]), atoi(argv[4]),  
argv[5]);

-       rebuild_type = REBUILD_DISK;
+       if (strcmp(cmd, "rebuild-dir") == 0) {
+               rebuild_type = REBUILD_DISK;
+       } else if (strcmp(cmd, "rebuild-log") == 0) {
+               rebuild_type = REBUILD_LOG;
+       } else if (strcmp(cmd, "rebuild") == 0) {
+               rebuild_type = probe_dir(&store_ufs_info);
+       } else {
+               usage(argv[0]);
+               exit(1);
+       }

        /* Output swap header to stdout */
        (void) storeSwapLogPrintHeader(1);

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to