-/* LBS: An LFS-inspired filesystem backup system
- * Copyright (C) 2007 Michael Vrable
+/* Cumulus: Smart Filesystem Backup to Dumb Servers
*
- * Backups are structured as a collection of objects, which may refer to other
+ * Copyright (C) 2007 The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/* Backups are structured as a collection of objects, which may refer to other
* objects. Object references are used to name other objects or parts of them.
* This file defines the class for representing object references and the
* textual representation of these references. */
#include <assert.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <uuid/uuid.h>
#include <string>
if (range_valid) {
char buf[64];
- if (range_start == 0) {
+ if (range_exact) {
+ sprintf(buf, "[=%zu]", range_length);
+ } else if (type == REF_ZERO) {
sprintf(buf, "[%zu]", range_length);
} else {
sprintf(buf, "[%zu+%zu]", range_start, range_length);
}
// Range
- bool have_range = false;
+ bool have_range = false, range_exact = false;
int64_t range1 = 0, range2 = 0;
if (*t == '[') {
t++;
+
+ if (*t == '=') {
+ range_exact = true;
+ t++;
+ }
+
s = t;
while (*t >= '0' && *t <= '9')
t++;
} else {
if (*t != '+')
return ObjectReference();
+ if (range_exact)
+ return ObjectReference();
string val(s, t - s);
range1 = atoll(val.c_str());
ref.set_checksum(checksum);
if (have_range)
- ref.set_range(range1, range2);
+ ref.set_range(range1, range2, range_exact);
return ref;
}
if (!range_valid || !ref.range_valid)
return false;
+ if (range_exact || ref.range_exact)
+ return false;
+
if (range_start + range_length == ref.range_start) {
range_length += ref.range_length;
return true;