Author: adrian.chadd
Date: Thu Jul 16 01:33:22 2009
New Revision: 14198

Added:
    playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.c
    playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.h
Modified:
    playpen/LUSCA_HEAD_storework/libsqstore/Makefile.am

Log:
Add in the basic rebuild entry hacks from ufs_rebuild.



Modified: playpen/LUSCA_HEAD_storework/libsqstore/Makefile.am
==============================================================================
--- playpen/LUSCA_HEAD_storework/libsqstore/Makefile.am (original)
+++ playpen/LUSCA_HEAD_storework/libsqstore/Makefile.am Thu Jul 16 01:33:22  
2009
@@ -1,8 +1,11 @@
  ## Process this file with automake to produce Makefile.in

+INCLUDES       = -I. -I$(top_builddir)
+
  libsqstore_a_SOURCES = \
        store_log.c \
-       store_file_ufs.c
+       store_file_ufs.c \
+       rebuild_entry.c

  noinst_LIBRARIES = \
        libsqstore.a

Added: playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.c
==============================================================================
--- (empty file)
+++ playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.c     Thu Jul 16  
01:33:22 2009
@@ -0,0 +1,111 @@
+
+#include "config.h"
+
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#include <sys/stat.h>
+#include <dirent.h>
+
+#include "include/util.h"
+#include "include/squid_md5.h"
+
+#include "libcore/kb.h"
+#include "libcore/varargs.h"
+#include "libcore/mem.h"
+#include "libcore/tools.h"
+
+#include "libsqdebug/debug.h"
+
+#include "libsqtlv/tlv.h"
+
+#include "libsqstore/store_mgr.h"
+#include "libsqstore/store_meta.h"
+#include "libsqstore/store_log.h"
+#include "libsqstore/store_file_ufs.h"
+
+#include "rebuild_entry.h"
+
+void
+rebuild_entry_done(rebuild_entry_t *re)
+{
+       safe_free(re->md5_key);
+       safe_free(re->url);
+       safe_free(re->storeurl);
+}
+
+void
+rebuild_entry_init(rebuild_entry_t *re)
+{
+       bzero(re, sizeof(*re));
+       re->hdr_size = -1;
+       re->file_size = -1;
+       re->swap_filen = -1;
+}
+
+int
+parse_header(char *buf, int len, rebuild_entry_t *re)
+{
+       tlv *t, *tlv_list;
+       int bl = len;
+       int parsed = 0;
+
+       tlv_list = tlv_unpack(buf, &bl, STORE_META_END + 10);
+       if (tlv_list == NULL) {
+               return -1;
+       }
+
+       re->hdr_size = bl;
+
+       for (t = tlv_list; t; t = t->next) {
+           switch (t->type) {
+           case STORE_META_URL:
+               debug(47, 5) ("  STORE_META_URL\n");
+               /* XXX Is this OK? Is the URL guaranteed to be \0 terminated? */
+               re->url = xstrdup( (char *) t->value );
+               parsed++;
+               break;
+           case STORE_META_KEY_MD5:
+               debug(47, 5) ("  STORE_META_KEY_MD5\n");
+               /* XXX should double-check key length? */
+               re->md5_key = xmalloc(SQUID_MD5_DIGEST_LENGTH);
+               memcpy(re->md5_key, t->value, SQUID_MD5_DIGEST_LENGTH);
+               parsed++;
+               break;
+           case STORE_META_STD_LFS:
+               debug(47, 5) ("  STORE_META_STD_LFS\n");
+               /* XXX should double-check lengths match? */
+               memcpy(&re->mi, t->value, sizeof(re->mi));
+               parsed++;
+               break;
+           case STORE_META_OBJSIZE:
+               debug(47, 5) ("  STORE_META_OBJSIZE\n");
+               /* XXX is this typecast'ed to the right "size" on all platforms 
? */
+               break;
+           default:
+               break;
+           }
+       }
+       assert(tlv_list != NULL);
+       tlv_free(tlv_list);
+       return (parsed > 1);
+}

Added: playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.h
==============================================================================
--- (empty file)
+++ playpen/LUSCA_HEAD_storework/libsqstore/rebuild_entry.h     Thu Jul 16  
01:33:22 2009
@@ -0,0 +1,21 @@
+#ifndef        __REBUILD_ENTRY_H__
+#define        __REBUILD_ENTRY_H__
+
+
+struct _rebuild_entry {
+        storeMetaIndexNew mi;
+        char *md5_key;
+        char *url;
+        char *storeurl;
+        squid_file_sz file_size;                /* swap file size - object  
size + metadata */
+        int hdr_size;                           /* metadata size */
+        int swap_filen;
+};
+typedef struct _rebuild_entry rebuild_entry_t;
+
+extern void rebuild_entry_done(rebuild_entry_t *re);
+extern void rebuild_entry_init(rebuild_entry_t *re);
+extern int parse_header(char *buf, int len, rebuild_entry_t *re);
+
+
+#endif

--~--~---------~--~----~------------~-------~--~----~
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