On Mon, Aug 19, 2013 at 2:42 AM, Thomas Gummerer <[email protected]> wrote:
> +static int read_entry(struct cache_entry **ce, char *pathname, size_t
> pathlen,
> + void *mmap, unsigned long mmap_size,
> + unsigned int first_entry_offset,
> + unsigned int foffsetblock)
> +{
> + int len, offset_to_offset;
> + char *name;
> + uint32_t foffsetblockcrc, *filecrc, *beginning, *end, entry_offset;
> + struct ondisk_cache_entry *disk_ce;
> +
> + beginning = ptr_add(mmap, foffsetblock);
> + end = ptr_add(mmap, foffsetblock + 4);
> + len = ntoh_l(*end) - ntoh_l(*beginning) - sizeof(struct
> ondisk_cache_entry) - 5;
> + entry_offset = first_entry_offset + ntoh_l(*beginning);
> + name = ptr_add(mmap, entry_offset);
> + disk_ce = ptr_add(mmap, entry_offset + len + 1);
> + *ce = cache_entry_from_ondisk(disk_ce, pathname, name, len, pathlen);
> + filecrc = ptr_add(mmap, entry_offset + len + 1 + sizeof(*disk_ce));
> + offset_to_offset = htonl(foffsetblock);
> + foffsetblockcrc = crc32(0, (Bytef*)&offset_to_offset, 4);
> + if (!check_crc32(foffsetblockcrc,
> + ptr_add(mmap, entry_offset), len + 1 + sizeof(*disk_ce),
> + ntoh_l(*filecrc)))
> + return -1;
> +
> + return 0;
> +}
Last thought before book+bed time. I wonder if moving the name part to
the end of the entry (i.e. chaging on disk format) would simplify this
code. The new ondisk_cache_entry would be something like this
struct ondisk_cache_entry {
uint16_t flags;
uint16_t mode;
struct cache_time mtime;
uint32_t size;
int stat_crc;
unsigned char sha1[20];
char name[FLEX_ARRAY];
};
--
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html