static SegmentStore *segment_store;
static OutputStream *info_dump = NULL;
+static TarSegmentStore *tss = NULL;
+
static SegmentPartitioner *index_segment, *data_segment;
/* Buffer for holding a single block of data read from a file. */
/* Read the contents of a file (specified by an open file descriptor) and copy
* the data to the store. */
-void dumpfile(int fd, dictionary &file_info)
+void dumpfile(int fd, dictionary &file_info, ostream &metadata)
{
struct stat stat_buf;
fstat(fd, &stat_buf);
int64_t size = 0;
+ string segment_list = "data:";
if ((stat_buf.st_mode & S_IFMT) != S_IFREG) {
printf("file is no longer a regular file!\n");
index_data->write_uuid(block_segment_uuid);
index_data->write_u32(block_object_id);
+ // tarstore processing
+ string blockid = tss->write_object(block_buf, bytes, "data");
+ segment_list += " " + blockid;
+
size += bytes;
}
file_info["sha1"] = string((const char *)hash.checksum(),
hash.checksum_size());
file_info["data"] = encode_objref(segment_uuid, object_id);
+
+ metadata << segment_list << "\n";
}
void scanfile(const string& path, ostream &metadata)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
file_info["size"] = encode_u64(stat_buf.st_size);
- dumpfile(fd, file_info);
+ dumpfile(fd, file_info, metadata);
close(fd);
break;
{
block_buf = new char[LBS_BLOCK_SIZE];
+ tss = new TarSegmentStore(".");
segment_store = new SegmentStore(".");
SegmentWriter *sw = segment_store->new_segment();
info_dump = sw->new_object(NULL, "ROOT");
fprintf(stderr, "IOException: %s\n", e.getError().c_str());
}
- Tarfile *t = new Tarfile("tarstore.tar", uuid);
const char testdata[] = "Test string.";
- t->write_object(0, testdata, strlen(testdata));
- t->write_object(1, testdata, strlen(testdata));
- t->write_object(2, testdata, strlen(testdata));
+ tss->write_object(testdata, strlen(testdata));
+ tss->write_object(testdata, strlen(testdata));
+ tss->write_object(testdata, strlen(testdata));
const string md = metadata.str();
- t->write_object(3, md.data(), md.size());
+ string root = tss->write_object(md.data(), md.size(), "root");
+
+ fprintf(stderr, "Metadata root is at %s\n", root.c_str());
- delete t;
+ tss->sync();
+ delete tss;
delete index_segment;
delete data_segment;