summaryrefslogtreecommitdiff
path: root/src/metaentry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/metaentry.c')
-rw-r--r--src/metaentry.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/metaentry.c b/src/metaentry.c
index 1eeed5b..6e27f11 100644
--- a/src/metaentry.c
+++ b/src/metaentry.c
@@ -432,6 +432,52 @@ mentries_tofile_v0(const struct metahash *mhash, FILE * to)
}
}
+/* Stores metaentries to a Format 1 file */
+static void
+mentries_tofile_v1(const struct metahash *mhash, FILE * to)
+{
+ const struct metaentry *mentry;
+ int key;
+ struct tm tm;
+ char tmbuf[20];
+ unsigned i;
+
+ fputc('\n', to);
+
+ for (key = 0; key < HASH_INDEXES; key++) {
+ for (mentry = mhash->bucket[key]; mentry; mentry = mentry->next) {
+ write_string_url(mentry->path, to);
+
+ fputc('\t', to);
+ write_string_url(mentry->owner, to);
+
+ fputc('\t', to);
+ write_string_url(mentry->group, to);
+
+ fputc('\t', to);
+ fprintf(to, "%.6o", mentry->mode);
+
+ fputc('\t', to);
+ gmtime_r(&mentry->mtime, &tm);
+ strftime(tmbuf, sizeof(tmbuf), "%Y-%m-%dT%H:%M:%S", &tm);
+ fputs(tmbuf, to);
+
+ fputc('.', to);
+ fprintf(to, "%.9ldZ", mentry->mtimensec);
+
+ for (i = 0; i < mentry->xattrs; i++) {
+ fputc('\t', to);
+ write_string_url(mentry->xattr_names[i], to);
+ fputc('\t', to);
+ write_binary_url(mentry->xattr_values[i],
+ mentry->xattr_lvalues[i], to);
+ }
+
+ fputc('\n', to);
+ }
+ }
+}
+
/* Stores metaentries to a file */
void
mentries_tofile(const struct metahash *mhash, const char *path, int format)
@@ -442,6 +488,7 @@ mentries_tofile(const struct metahash *mhash, const char *path, int format)
switch (format) {
case 0: formatstr = VERSION_0; tofile = mentries_tofile_v0; break;
+ case 1: formatstr = VERSION_1; tofile = mentries_tofile_v1; break;
default:
msg(MSG_CRITICAL, "Unknown format %d\n", format);
exit(EXIT_FAILURE);