#include <linux/blkdev.h>
#include <linux/buffer_head.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include "debug.h"
#include "ntfs.h"
#include "ntfs_fs.h"
static const struct INDEX_NAMES { … } s_index_names[INDEX_MUTEX_TOTAL] = …;
static int cmp_fnames(const void *key1, size_t l1, const void *key2, size_t l2,
const void *data)
{ … }
static int cmp_uint(const void *key1, size_t l1, const void *key2, size_t l2,
const void *data)
{ … }
static int cmp_sdh(const void *key1, size_t l1, const void *key2, size_t l2,
const void *data)
{ … }
static int cmp_uints(const void *key1, size_t l1, const void *key2, size_t l2,
const void *data)
{ … }
static inline NTFS_CMP_FUNC get_cmp_func(const struct INDEX_ROOT *root)
{ … }
struct bmp_buf { … };
static int bmp_buf_get(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t bit, struct bmp_buf *bbuf)
{ … }
static void bmp_buf_put(struct bmp_buf *bbuf, bool dirty)
{ … }
static int indx_mark_used(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t bit)
{ … }
static int indx_mark_free(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t bit)
{ … }
static int scan_nres_bitmap(struct ntfs_inode *ni, struct ATTRIB *bitmap,
struct ntfs_index *indx, size_t from,
bool (*fn)(const ulong *buf, u32 bit, u32 bits,
size_t *ret),
size_t *ret)
{ … }
static bool scan_for_free(const ulong *buf, u32 bit, u32 bits, size_t *ret)
{ … }
static int indx_find_free(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t *bit, struct ATTRIB **bitmap)
{ … }
static bool scan_for_used(const ulong *buf, u32 bit, u32 bits, size_t *ret)
{ … }
int indx_used_bit(struct ntfs_index *indx, struct ntfs_inode *ni, size_t *bit)
{ … }
static const struct NTFS_DE *hdr_find_split(const struct INDEX_HDR *hdr)
{ … }
static const struct NTFS_DE *hdr_insert_head(struct INDEX_HDR *hdr,
const void *ins, u32 ins_bytes)
{ … }
static bool index_hdr_check(const struct INDEX_HDR *hdr, u32 bytes)
{ … }
static bool index_buf_check(const struct INDEX_BUFFER *ib, u32 bytes,
const CLST *vbn)
{ … }
void fnd_clear(struct ntfs_fnd *fnd)
{ … }
static int fnd_push(struct ntfs_fnd *fnd, struct indx_node *n,
struct NTFS_DE *e)
{ … }
static struct indx_node *fnd_pop(struct ntfs_fnd *fnd)
{ … }
static bool fnd_is_empty(struct ntfs_fnd *fnd)
{ … }
static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
const struct INDEX_HDR *hdr, const void *key,
size_t key_len, const void *ctx, int *diff)
{ … }
static struct NTFS_DE *hdr_insert_de(const struct ntfs_index *indx,
struct INDEX_HDR *hdr,
const struct NTFS_DE *de,
struct NTFS_DE *before, const void *ctx)
{ … }
static inline struct NTFS_DE *hdr_delete_de(struct INDEX_HDR *hdr,
struct NTFS_DE *re)
{ … }
void indx_clear(struct ntfs_index *indx)
{ … }
int indx_init(struct ntfs_index *indx, struct ntfs_sb_info *sbi,
const struct ATTRIB *attr, enum index_mutex_classed type)
{ … }
static struct indx_node *indx_new(struct ntfs_index *indx,
struct ntfs_inode *ni, CLST vbn,
const __le64 *sub_vbn)
{ … }
struct INDEX_ROOT *indx_get_root(struct ntfs_index *indx, struct ntfs_inode *ni,
struct ATTRIB **attr, struct mft_inode **mi)
{ … }
static int indx_write(struct ntfs_index *indx, struct ntfs_inode *ni,
struct indx_node *node, int sync)
{ … }
int indx_read(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn,
struct indx_node **node)
{ … }
int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct INDEX_ROOT *root, const void *key, size_t key_len,
const void *ctx, int *diff, struct NTFS_DE **entry,
struct ntfs_fnd *fnd)
{ … }
int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct INDEX_ROOT *root, struct NTFS_DE **entry,
struct ntfs_fnd *fnd)
{ … }
int indx_find_raw(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct INDEX_ROOT *root, struct NTFS_DE **entry,
size_t *off, struct ntfs_fnd *fnd)
{ … }
static int indx_create_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
CLST *vbn)
{ … }
static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
CLST *vbn)
{ … }
static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct NTFS_DE *new_de,
struct NTFS_DE *root_de, const void *ctx,
struct ntfs_fnd *fnd, bool undo)
{ … }
static int
indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
struct INDEX_ROOT *root, const struct NTFS_DE *new_de,
const void *ctx, int level, struct ntfs_fnd *fnd)
{ … }
int indx_insert_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct NTFS_DE *new_de, const void *ctx,
struct ntfs_fnd *fnd, bool undo)
{ … }
static struct indx_node *indx_find_buffer(struct ntfs_index *indx,
struct ntfs_inode *ni,
const struct INDEX_ROOT *root,
__le64 vbn, struct indx_node *n)
{ … }
static int indx_shrink(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t bit)
{ … }
static int indx_free_children(struct ntfs_index *indx, struct ntfs_inode *ni,
const struct NTFS_DE *e, bool trim)
{ … }
static int indx_get_entry_to_replace(struct ntfs_index *indx,
struct ntfs_inode *ni,
const struct NTFS_DE *de_next,
struct NTFS_DE **de_to_replace,
struct ntfs_fnd *fnd)
{ … }
int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
const void *key, u32 key_len, const void *ctx)
{ … }
int indx_update_dup(struct ntfs_inode *ni, struct ntfs_sb_info *sbi,
const struct ATTR_FILE_NAME *fname,
const struct NTFS_DUP_INFO *dup, int sync)
{ … }