Blob


1 /*
2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 /*
18 * Meta data about a tracked on-disk file.
19 *
20 * Note that some fields are truncated results from stat(2). These are only
21 * used in order to detect modifications made to on-disk files, they are
22 * never written back to the filesystem.
23 */
24 struct got_index_entry {
25 uint32_t ctime_sec;
26 uint32_t ctime_nsec;
27 uint32_t mtime_sec;
28 uint32_t mtime_nsec;
29 uint32_t dev;
30 uint32_t ino;
31 uint32_t mode;
32 #define GOT_INDEX_ENTRY_MODE_OBJ_TYPE 0x0000000f
33 #define GOT_INDEX_ENTRY_MODE_PERMS 0x0000ff10
34 uint32_t uid;
35 uint32_t gid;
36 uint32_t size;
37 uint8_t obj_sha1[SHA1_DIGEST_LENGTH];
38 uint16_t flags;
39 #define GOT_INDEX_ENTRY_F_NAME_LEN 0x0fff
40 #define GOT_INDEX_ENTRY_F_STAGE 0x3000
41 #define GOT_INDEX_ENTRY_F_EXTENDED 0x4000
42 #define GOT_INDEX_ENTRY_F_ASSUME_VALID 0x8000
44 /* This is a unix-style path relative to top level directory. */
45 const char *path;
46 };
48 struct got_index {
49 uint32_t signature;
50 uint32_t version;
51 uint32_t nentries;
52 struct got_index_entry *entries;
53 /* extensions go here */
54 uint8_t sha1[SHA1_DIGEST_LENGTH];
55 };