X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Fexfat-utils.git;a=blobdiff_plain;f=libexfat%2Fexfat.h;h=2342be4f531a5b0c489e81ee0710186b6a00dab2;hp=21b760e2c1e0294d4c4321ecdc82af690cc77107;hb=b389db553b85947429af3c455bb324da02429abd;hpb=2fa6c5654e0a345af10df5227b77d9f468759f20 diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 21b760e..2342be4 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -4,7 +4,7 @@ implementation. Free exFAT implementation. - Copyright (C) 2010-2017 Andrew Nayenko + Copyright (C) 2010-2018 Andrew Nayenko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,10 @@ #ifndef EXFAT_H_INCLUDED #define EXFAT_H_INCLUDED +#ifndef ANDROID +/* Android.bp is used instead of autotools when targeting Android */ #include "config.h" +#endif #include "compiler.h" #include "exfatfs.h" #include @@ -43,8 +46,8 @@ #define SECTOR_SIZE(sb) (1 << (sb).sector_bits) #define CLUSTER_SIZE(sb) (SECTOR_SIZE(sb) << (sb).spc_bits) -#define CLUSTER_INVALID(c) \ - ((c) < EXFAT_FIRST_DATA_CLUSTER || (c) > EXFAT_LAST_DATA_CLUSTER) +#define CLUSTER_INVALID(sb, c) ((c) < EXFAT_FIRST_DATA_CLUSTER || \ + (c) - EXFAT_FIRST_DATA_CLUSTER >= le32_to_cpu((sb).cluster_count)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -61,6 +64,9 @@ #define BMAP_CLR(bitmap, index) \ ((bitmap)[BMAP_BLOCK(index)] &= ~BMAP_MASK(index)) +#define EXFAT_REPAIR(hook, ef, ...) \ + (exfat_ask_to_fix(ef) && exfat_fix_ ## hook(ef, __VA_ARGS__)) + /* The size of off_t type must be 64 bits. File systems larger than 2 GB will be corrupted with 32-bit off_t. */ STATIC_ASSERT(sizeof(off_t) == 8); @@ -119,6 +125,7 @@ struct exfat gid_t gid; int ro; bool noatime; + enum { EXFAT_REPAIR_NO, EXFAT_REPAIR_ASK, EXFAT_REPAIR_YES } repair; }; /* in-core nodes iterator */ @@ -135,6 +142,7 @@ struct exfat_human_bytes }; extern int exfat_errors; +extern int exfat_errors_fixed; void exfat_bug(const char* format, ...) PRINTF NORETURN; void exfat_error(const char* format, ...) PRINTF; @@ -161,7 +169,7 @@ ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node, int exfat_opendir(struct exfat* ef, struct exfat_node* dir, struct exfat_iterator* it); void exfat_closedir(struct exfat* ef, struct exfat_iterator* it); -struct exfat_node* exfat_readdir(struct exfat* ef, struct exfat_iterator* it); +struct exfat_node* exfat_readdir(struct exfat_iterator* it); int exfat_lookup(struct exfat* ef, struct exfat_node** node, const char* path); int exfat_split(struct exfat* ef, struct exfat_node** parent, @@ -225,4 +233,12 @@ void exfat_unix2exfat(time_t unix_time, le16_t* date, le16_t* time, uint8_t* centisec); void exfat_tzset(void); +bool exfat_ask_to_fix(const struct exfat* ef); +bool exfat_fix_invalid_vbr_checksum(const struct exfat* ef, void* sector, + uint32_t vbr_checksum); +bool exfat_fix_invalid_node_checksum(const struct exfat* ef, + struct exfat_node* node); +bool exfat_fix_unknown_entry(struct exfat* ef, struct exfat_node* dir, + const struct exfat_entry* entry, off_t offset); + #endif /* ifndef EXFAT_H_INCLUDED */