fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
index.h
Go to the documentation of this file.
1
3#ifndef FSAUTOPROC_INDEX_H
4#define FSAUTOPROC_INDEX_H
5
6#include <stdint.h>
7#include <stdio.h>
8
9#include "fs.h"
10
13struct inode_s {
14 char* fp;
15 uint64_t fphash;
16 struct fsstat_s st;
17 uint64_t xx;
18 struct inode_s* next;
19};
20
23struct ibucket_s {
24 struct inode_s* head;
25 struct inode_s* tail;
26};
27
32#define INDEXBUCKETS 4096
33
38#define INDEXBUCKETSMASK 0xFFF
39
42struct index_s {
44 long size;
45};
46
51uint64_t indexhash(const char* fp);
52
58struct inode_s* indexfind(const struct index_s* idx, const char* fp,
59 uint64_t fphash);
60
67int indexwrite(struct index_s* idx, FILE* s);
68
75int indexread(struct index_s* idx, FILE* s);
76
85struct inode_s* indexput(struct index_s* idx, const char* fp, uint64_t fphash,
86 const struct fsstat_s* st, uint64_t xx);
87
90void indexfree(struct index_s* idx);
91
98struct inode_s** indexlist(const struct index_s* idx);
99
100#endif// FSAUTOPROC_INDEX_H
Filesystem walk and stat functions.
int indexread(struct index_s *idx, FILE *s)
Reads a file stream and deserializes the contents into a map of individual file nodes.
Definition index.c:82
struct inode_s ** indexlist(const struct index_s *idx)
Flattens the index map into an unsorted array of nodes. The list is dynamically allocated and must be...
Definition index.c:137
int indexwrite(struct index_s *idx, FILE *s)
Flattens the index map into a sorted array of nodes (by filepath). The list is then written to the fi...
Definition index.c:59
#define INDEXBUCKETS
The fixed number of buckets in the index map.
Definition index.h:32
uint64_t indexhash(const char *fp)
Hashes the filepath string for use in the index map.
Definition index.c:22
struct inode_s * indexfind(const struct index_s *idx, const char *fp, uint64_t fphash)
Searches the index for a node with a matching filepath.
Definition index.c:32
void indexfree(struct index_s *idx)
Frees all nodes in the index map.
Definition index.c:133
struct inode_s * indexput(struct index_s *idx, const char *fp, uint64_t fphash, const struct fsstat_s *st, uint64_t xx)
Copies the node and inserts it into the index mapping.
Definition index.c:106
Stat structure for storing the last modified time and file size.
Definition fs.h:10
Index bucket structure for storing linked list head/tail pointers.
Definition index.h:23
struct inode_s * head
Head of the linked list of nodes in the bucket.
Definition index.h:24
struct inode_s * tail
Tail of the linked list of nodes in the bucket.
Definition index.h:25
Index map structure for storing file nodes.
Definition index.h:42
long size
Number of sum nodes in the index.
Definition index.h:44
struct ibucket_s buckets[INDEXBUCKETS]
Array of index buckets.
Definition index.h:43
Individual file node in the index map.
Definition index.h:13
struct fsstat_s st
File stat info structure.
Definition index.h:16
uint64_t xx
xxHash64 hash value
Definition index.h:17
struct inode_s * next
Next node in the index map.
Definition index.h:18
char * fp
File path (string duplicated)
Definition index.h:14
uint64_t fphash
File path hash value.
Definition index.h:15