Author: adrian.chadd
Date: Sun May  3 00:29:11 2009
New Revision: 14030

Modified:
    branches/LUSCA_HEAD/tools/ufs_log_dump.c

Log:
The ufs_log_dump program for now will only handle the -new- swaplog file  
format
and only in the natively compiled size.

I'll worry about re-establishing the sensible backwards compatible stuff  
later
on if it is ever needed.

Handling the non-native compiled size will come later when I've written some
further library functions to abstract out reading (and writing) the swap log
contents in a semi-sensible buffered fashion.



Modified: branches/LUSCA_HEAD/tools/ufs_log_dump.c
==============================================================================
--- branches/LUSCA_HEAD/tools/ufs_log_dump.c    (original)
+++ branches/LUSCA_HEAD/tools/ufs_log_dump.c    Sun May  3 00:29:11 2009
@@ -65,12 +65,12 @@
  storeMetaText(storeSwapLogData *d)
  {
        static char buf[1024];
-       char *ks = storeKeyText(d->key);
+       const char *ks = storeKeyText(d->key);

        buf[0] = '\0';

        snprintf(buf, 1024, "op %s; fileno %X; timestamp %ld; lastref %ld;  
expires %ld; lastmod %ld; filesize %ld; refcount %d; flags %d; key %s",
-           swap_log_op_str[d->op],
+           swap_log_op_str[(int) d->op],
            (int) d->swap_filen,
            (long int) d->timestamp,
            (long int) d->lastref,
@@ -83,7 +83,6 @@
        return buf;
  }

-
  void
  read_file(const char *path)
  {
@@ -100,15 +99,15 @@
        }

        /* read the header */
-       len = read(fd, buf, BUFSIZE);
+       len = read(fd, buf, sizeof(storeSwapLogData));
        if (len < 0) {
                perror("read");
                close(fd);
                return;
        }

-       if (len < sizeof(*hdr)) {
-               perror("too small");
+       if (len != sizeof(storeSwapLogData)) {
+               perror("not enough data");
                close(fd);
                return;
        }
@@ -116,15 +115,9 @@
        hdr = (storeSwapLogHeader *) buf;

        /* Which version is the swaplog? For now, we only support the -new-  
version */
+
        printf("swaplog header version: %d; record size: %d\n", hdr->version,  
hdr->record_size);
        printf("size of current swaplog entry: %d\n", sizeof(storeSwapLogData));
-
-       /* The "starting" point for this record is the -record- size, not the  
swaplog header size. */
-       if (lseek(fd, hdr->record_size, SEEK_SET) < 0) {
-               perror("lseek");
-               close(fd);
-               return;
-       }

        /* Start reading entries */
        while ((len = read(fd, buf, sizeof(storeSwapLogData))) > 0) {

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