X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/269fa2d1d46469f330eaceaf0e2ca2bf5267abc6..b5af45d3e37e570183ff09f40c4e8ef09241ade2:/trie.h diff --git a/trie.h b/trie.h index 2f88291..727d976 100644 --- a/trie.h +++ b/trie.h @@ -9,7 +9,7 @@ * An entry in the trie file describing an actual file. */ struct trie_file { - unsigned long long blocks; + unsigned long long size; unsigned long long atime; }; @@ -50,6 +50,17 @@ int triebuild_finish(triebuild *tb); void triebuild_free(triebuild *tb); /* ---------------------------------------------------------------------- + * Anomalous function which modifies a trie after it's memory-mapped. + */ + +/* + * Invent new fake atimes for each directory in the trie, by + * taking the maximum (latest) of the directory's previously + * stored atime and the atimes of everything below it. + */ +void trie_fake_dir_atimes(void *t); + +/* ---------------------------------------------------------------------- * Functions to query a trie given a pointer to the start of the * memory-mapped file. */ @@ -99,6 +110,7 @@ unsigned long trie_count(const void *t); typedef struct triewalk triewalk; triewalk *triewalk_new(const void *t); const struct trie_file *triewalk_next(triewalk *tw, char *buf); +void triewalk_rebase(triewalk *tw, const void *t); void triewalk_free(triewalk *tw); /* ---------------------------------------------------------------------- @@ -107,3 +119,19 @@ void triewalk_free(triewalk *tw); */ void trie_set_index_offset(void *t, off_t ptr); off_t trie_get_index_offset(const void *t); + +/* ---------------------------------------------------------------------- + * Utility functions not directly involved with the trie. + */ + +/* + * Given a pathname in a buffer, adjust the pathname in place so + * that it points at a string which, when passed to trie_before, + * will reliably return the index of the thing that comes after + * that pathname and all its descendants. Usually this is done by + * suffixing ^A (since foo^A is guaranteeably the first thing that + * sorts after foo and foo/stuff); however, if the pathname + * actually ends in a path separator (e.g. if it's just "/"), that + * must be stripped off first. + */ +void make_successor(char *pathbuf);