| 56 | } |
| 57 | |
| 58 | int read_fsmonitor_extension(struct index_state *istate, const void *data, |
| 59 | unsigned long sz) |
| 60 | { |
| 61 | const char *index = data; |
| 62 | uint32_t hdr_version; |
| 63 | uint32_t ewah_size; |
| 64 | struct ewah_bitmap *fsmonitor_dirty; |
| 65 | int ret; |
| 66 | uint64_t timestamp; |
| 67 | struct strbuf last_update = STRBUF_INIT; |
| 68 | |
| 69 | if (sz < sizeof(uint32_t) + 1 + sizeof(uint32_t)) |
| 70 | return error("corrupt fsmonitor extension (too short)"); |
| 71 | |
| 72 | hdr_version = get_be32(index); |
| 73 | index += sizeof(uint32_t); |
| 74 | if (hdr_version == INDEX_EXTENSION_VERSION1) { |
| 75 | timestamp = get_be64(index); |
| 76 | strbuf_addf(&last_update, "%"PRIu64"", timestamp); |
| 77 | index += sizeof(uint64_t); |
| 78 | } else if (hdr_version == INDEX_EXTENSION_VERSION2) { |
| 79 | strbuf_addstr(&last_update, index); |
| 80 | index += last_update.len + 1; |
| 81 | } else { |
| 82 | return error("bad fsmonitor version %d", hdr_version); |
| 83 | } |
| 84 | |
| 85 | istate->fsmonitor_last_update = strbuf_detach(&last_update, NULL); |
| 86 | |
| 87 | ewah_size = get_be32(index); |
| 88 | index += sizeof(uint32_t); |
| 89 | |
| 90 | fsmonitor_dirty = ewah_new(); |
| 91 | ret = ewah_read_mmap(fsmonitor_dirty, index, ewah_size); |
| 92 | if (ret != ewah_size) { |
| 93 | ewah_free(fsmonitor_dirty); |
| 94 | return error("failed to parse ewah bitmap reading fsmonitor index extension"); |
| 95 | } |
| 96 | istate->fsmonitor_dirty = fsmonitor_dirty; |
| 97 | |
| 98 | if (!istate->split_index) |
| 99 | assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); |
| 100 | |
| 101 | trace2_data_string("index", NULL, "extension/fsmn/read/token", |
| 102 | istate->fsmonitor_last_update); |
| 103 | trace_printf_key(&trace_fsmonitor, |
| 104 | "read fsmonitor extension successful '%s'", |
| 105 | istate->fsmonitor_last_update); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | void fill_fsmonitor_bitmap(struct index_state *istate) |
| 110 | { |
no test coverage detected