#include <linux/blkdev.h>
#include <linux/fs.h>
#include <linux/random.h>
#include <linux/slab.h>
#include "debug.h"
#include "ntfs.h"
#include "ntfs_fs.h"
#define MaxLogFileSize …
#define DefaultLogPageSize …
#define MinLogRecordPages …
struct RESTART_HDR { … };
#define LFS_NO_CLIENT …
#define LFS_NO_CLIENT_LE …
struct CLIENT_REC { … };
static_assert(…);
struct RESTART_AREA { … };
struct LOG_REC_HDR { … };
static_assert(…);
#define RESTART_ENTRY_ALLOCATED …
#define RESTART_ENTRY_ALLOCATED_LE …
struct RESTART_TABLE { … };
static_assert(…);
struct ATTR_NAME_ENTRY { … };
struct OPEN_ATTR_ENRTY { … };
struct OPEN_ATTR_ENRTY_32 { … };
#define SIZEOF_OPENATTRIBUTEENTRY0 …
static_assert(…);
struct DIR_PAGE_ENTRY { … };
static_assert(…);
struct DIR_PAGE_ENTRY_32 { … };
static_assert(…);
static_assert(…);
enum transact_state { … };
struct TRANSACTION_ENTRY { … };
static_assert(…);
struct NTFS_RESTART { … };
static_assert(…);
struct NEW_ATTRIBUTE_SIZES { … };
struct BITMAP_RANGE { … };
struct LCN_RANGE { … };
#define LfsClientRecord …
#define LfsClientRestart …
struct CLIENT_ID { … };
struct LFS_RECORD_HDR { … };
#define LOG_RECORD_MULTI_PAGE …
static_assert(…);
struct LFS_RECORD { … };
static_assert(…);
struct RECORD_PAGE_HDR { … };
#define LOG_PAGE_LOG_RECORD_END …
static inline bool is_log_record_end(const struct RECORD_PAGE_HDR *hdr)
{ … }
static_assert(…);
#define INITIAL_NUMBER_TRANSACTIONS …
enum NTFS_LOG_OPERATION { … };
static const u8 AttributeRequired[] = …;
static inline bool is_target_required(u16 op)
{ … }
static inline bool can_skip_action(enum NTFS_LOG_OPERATION op)
{ … }
enum { … };
static inline u32 bytes_per_rt(const struct RESTART_TABLE *rt)
{ … }
static inline u32 lrh_length(const struct LOG_REC_HDR *lr)
{ … }
struct lcb { … };
static void lcb_put(struct lcb *lcb)
{ … }
static inline void oldest_client_lsn(const struct CLIENT_REC *ca,
__le16 next_client, u64 *oldest_lsn)
{ … }
static inline bool is_rst_page_hdr_valid(u32 file_off,
const struct RESTART_HDR *rhdr)
{ … }
static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
{ … }
static inline bool is_client_area_valid(const struct RESTART_HDR *rhdr,
bool usa_error)
{ … }
static inline void remove_client(struct CLIENT_REC *ca,
const struct CLIENT_REC *cr, __le16 *head)
{ … }
static inline void add_client(struct CLIENT_REC *ca, u16 index, __le16 *head)
{ … }
static inline void *enum_rstbl(struct RESTART_TABLE *t, void *c)
{ … }
static inline struct DIR_PAGE_ENTRY *find_dp(struct RESTART_TABLE *dptbl,
u32 target_attr, u64 vcn)
{ … }
static inline u32 norm_file_page(u32 page_size, u32 *l_size, bool use_default)
{ … }
static bool check_log_rec(const struct LOG_REC_HDR *lr, u32 bytes, u32 tr,
u32 bytes_per_attr_entry)
{ … }
static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes)
{ … }
static inline void free_rsttbl_idx(struct RESTART_TABLE *rt, u32 off)
{ … }
static inline struct RESTART_TABLE *init_rsttbl(u16 esize, u16 used)
{ … }
static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl,
u32 add, u32 free_goal)
{ … }
static inline void *alloc_rsttbl_idx(struct RESTART_TABLE **tbl)
{ … }
static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo)
{ … }
struct restart_info { … };
#define RESTART_SINGLE_PAGE_IO …
#define NTFSLOG_WRAPPED …
#define NTFSLOG_MULTIPLE_PAGE_IO …
#define NTFSLOG_NO_LAST_LSN …
#define NTFSLOG_REUSE_TAIL …
#define NTFSLOG_NO_OLDEST_LSN …
struct ntfs_log { … };
static inline u32 lsn_to_vbo(struct ntfs_log *log, const u64 lsn)
{ … }
static inline u32 next_page_off(struct ntfs_log *log, u32 off)
{ … }
static inline u32 lsn_to_page_off(struct ntfs_log *log, u64 lsn)
{ … }
static inline u64 vbo_to_lsn(struct ntfs_log *log, u32 off, u64 Seq)
{ … }
static inline bool is_lsn_in_file(struct ntfs_log *log, u64 lsn)
{ … }
static inline u32 hdr_file_off(struct ntfs_log *log,
struct RECORD_PAGE_HDR *hdr)
{ … }
static inline u64 base_lsn(struct ntfs_log *log,
const struct RECORD_PAGE_HDR *hdr, u64 lsn)
{ … }
static inline bool verify_client_lsn(struct ntfs_log *log,
const struct CLIENT_REC *client, u64 lsn)
{ … }
static int read_log_page(struct ntfs_log *log, u32 vbo,
struct RECORD_PAGE_HDR **buffer, bool *usa_error)
{ … }
static int log_read_rst(struct ntfs_log *log, bool first,
struct restart_info *info)
{ … }
static void log_init_pg_hdr(struct ntfs_log *log, u16 major_ver, u16 minor_ver)
{ … }
static void log_create(struct ntfs_log *log, const u64 last_lsn,
u32 open_log_count, bool wrapped, bool use_multi_page)
{ … }
static struct RESTART_AREA *log_create_ra(struct ntfs_log *log)
{ … }
static u32 final_log_off(struct ntfs_log *log, u64 lsn, u32 data_len)
{ … }
static int next_log_lsn(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh,
u64 *lsn)
{ … }
static u32 current_log_avail(struct ntfs_log *log)
{ … }
static bool check_subseq_log_page(struct ntfs_log *log,
const struct RECORD_PAGE_HDR *rp, u32 vbo,
u64 seq)
{ … }
static int last_log_lsn(struct ntfs_log *log)
{ … }
static int read_log_rec_buf(struct ntfs_log *log,
const struct LFS_RECORD_HDR *rh, void *buffer)
{ … }
static int read_rst_area(struct ntfs_log *log, struct NTFS_RESTART **rst_,
u64 *lsn)
{ … }
static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb)
{ … }
static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode,
struct lcb **lcb_)
{ … }
static int find_client_next_lsn(struct ntfs_log *log, struct lcb *lcb, u64 *lsn)
{ … }
static int read_next_log_rec(struct ntfs_log *log, struct lcb *lcb, u64 *lsn)
{ … }
bool check_index_header(const struct INDEX_HDR *hdr, size_t bytes)
{ … }
static inline bool check_index_buffer(const struct INDEX_BUFFER *ib, u32 bytes)
{ … }
static inline bool check_index_root(const struct ATTRIB *attr,
struct ntfs_sb_info *sbi)
{ … }
static inline bool check_attr(const struct MFT_REC *rec,
const struct ATTRIB *attr,
struct ntfs_sb_info *sbi)
{ … }
static inline bool check_file_record(const struct MFT_REC *rec,
const struct MFT_REC *rec2,
struct ntfs_sb_info *sbi)
{ … }
static inline int check_lsn(const struct NTFS_RECORD_HEADER *hdr,
const u64 *rlsn)
{ … }
static inline bool check_if_attr(const struct MFT_REC *rec,
const struct LOG_REC_HDR *lrh)
{ … }
static inline bool check_if_index_root(const struct MFT_REC *rec,
const struct LOG_REC_HDR *lrh)
{ … }
static inline bool check_if_root_index(const struct ATTRIB *attr,
const struct INDEX_HDR *hdr,
const struct LOG_REC_HDR *lrh)
{ … }
static inline bool check_if_alloc_index(const struct INDEX_HDR *hdr,
u32 attr_off)
{ … }
static inline void change_attr_size(struct MFT_REC *rec, struct ATTRIB *attr,
u32 nsize)
{ … }
struct OpenAttr { … };
static inline int cmp_type_and_name(const struct ATTRIB *a1,
const struct ATTRIB *a2)
{ … }
static struct OpenAttr *find_loaded_attr(struct ntfs_log *log,
const struct ATTRIB *attr, CLST rno)
{ … }
static struct ATTRIB *attr_create_nonres_log(struct ntfs_sb_info *sbi,
enum ATTR_TYPE type, u64 size,
const u16 *name, size_t name_len,
__le16 flags)
{ … }
static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
const struct LOG_REC_HDR *lrh, u32 op, void *data,
u32 dlen, u32 rec_len, const u64 *rlsn)
{ … }
int log_replay(struct ntfs_inode *ni, bool *initialized)
{ … }