Directory serialization (but not deserialization).
authorMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 3 Sep 2009 23:59:50 +0000 (16:59 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Thu, 3 Sep 2009 23:59:50 +0000 (16:59 -0700)
bluesky/serialize.c

index 7cb16a5..d0273cc 100644 (file)
@@ -62,6 +62,31 @@ void bluesky_serialize_inode(GString *out, BlueSkyInode *inode)
             g_string_append_c(out, '\0');
         }
         break;
+
+    case BLUESKY_DIRECTORY:
+    {
+        uint32_t seq;
+        uint64_t inum;
+        GSequenceIter *i = g_sequence_get_begin_iter(inode->dirents);
+
+        while (!g_sequence_iter_is_end(i)) {
+            BlueSkyDirent *d = g_sequence_get(i);
+
+            seq = GUINT32_TO_LE(d->cookie);
+            inum = GUINT64_TO_LE(d->inum);
+            g_string_append_len(out, (gchar *)&seq, sizeof(uint32_t));
+            g_string_append_len(out, (gchar *)&inum, sizeof(uint64_t));
+            g_string_append(out, d->name);
+            g_string_append_c(out, '\0');
+
+            i = g_sequence_iter_next(i);
+        }
+
+        seq = GUINT32_TO_LE(0);
+        g_string_append_len(out, (gchar *)&seq, sizeof(uint32_t));
+
+        break;
+    }
     default:
         g_warning("Serialization for inode type %d not implemented!\n",
                   inode->type);