1N/A/*
1N/A * index.h - Defines for NTFS index handling. Part of the Linux-NTFS project.
1N/A *
1N/A * Copyright (c) 2004 Anton Altaparmakov
1N/A * Copyright (c) 2004-2005 Richard Russon
1N/A * Copyright (c) 2005-2006 Yura Pakhuchiy
1N/A * Copyright (c) 2006 Szabolcs Szakacsits
1N/A *
1N/A * This program/include file is free software; you can redistribute it and/or
1N/A * modify it under the terms of the GNU General Public License as published
1N/A * by the Free Software Foundation; either version 2 of the License, or
1N/A * (at your option) any later version.
1N/A *
1N/A * This program/include file is distributed in the hope that it will be
1N/A * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
1N/A * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A * GNU General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU General Public License
1N/A * along with this program (in the main directory of the Linux-NTFS
1N/A * distribution in the file COPYING); if not, write to the Free Software
1N/A * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1N/A */
1N/A
1N/A#ifndef _NTFS_INDEX_H
1N/A#define _NTFS_INDEX_H
1N/A
1N/A#include "attrib.h"
1N/A#include "types.h"
1N/A#include "layout.h"
1N/A#include "inode.h"
1N/A#include "mft.h"
1N/A
1N/A#define VCN_INDEX_ROOT_PARENT ((VCN)-2)
1N/A
1N/A#define MAX_PARENT_VCN 32
1N/A
1N/A/**
1N/A * struct ntfs_index_context -
1N/A * @ni: inode containing the @entry described by this context
1N/A * @name: name of the index described by this context
1N/A * @name_len: length of the index name
1N/A * @entry: index entry (points into @ir or @ib)
1N/A * @data: index entry data (points into @entry)
1N/A * @data_len: length in bytes of @data
1N/A * @cr:
1N/A * @is_in_root: TRUE if @entry is in @ir or FALSE if it is in @ib
1N/A * @ir: index root if @is_in_root or NULL otherwise
1N/A * @actx: attribute search context if in root or NULL otherwise
1N/A * @ia_na: opened INDEX_ALLOCATION attribute
1N/A * @ib: index block if @is_in_root is FALSE or NULL otherwise
1N/A * @ib_vcn: VCN from which @ib where read from
1N/A * @ib_dirty: TRUE if index block was changed
1N/A * @parent_pos: parent entries' positions in the index block
1N/A * @parent_vcn: entry's parent nodes or VCN_INDEX_ROOT_PARENT for root
1N/A * @max_depth: number of the parent nodes
1N/A * @pindex: maximum it's the number of the parent nodes
1N/A * @block_size: index block size
1N/A * @vcn_size_bits: VCN size bits for this index block
1N/A *
1N/A * @ni is the inode this context belongs to.
1N/A *
1N/A * @entry is the index entry described by this context. @data and @data_len
1N/A * are the index entry data and its length in bytes, respectively. @data
1N/A * simply points into @entry. This is probably what the user is interested in.
1N/A *
1N/A * If @is_in_root is TRUE, @entry is in the index root attribute @ir described
1N/A * by the attribute search context @actx and inode @ni. @ib, @ib_vcn and
1N/A * @ib_dirty are undefined in this case.
1N/A *
1N/A * If @is_in_root is FALSE, @entry is in the index allocation attribute and @ib
1N/A * and @ib_vcn point to the index allocation block and VCN where it's placed,
1N/A * respectively. @ir and @actx are NULL in this case. @ia_na is opened
1N/A * INDEX_ALLOCATION attribute. @ib_dirty is TRUE if index block was changed and
1N/A * FALSE otherwise.
1N/A *
1N/A * To obtain a context call ntfs_index_ctx_get().
1N/A *
1N/A * When finished with the @entry and its @data, call ntfs_index_ctx_put() to
1N/A * free the context and other associated resources.
1N/A *
1N/A * If the index entry was modified, call ntfs_index_entry_mark_dirty() before
1N/A * the call to ntfs_index_ctx_put() to ensure that the changes are written
1N/A * to disk.
1N/A */
1N/Atypedef struct {
1N/A ntfs_inode *ni;
1N/A ntfschar *name;
1N/A u32 name_len;
1N/A INDEX_ENTRY *entry;
1N/A void *data;
1N/A u16 data_len;
1N/A COLLATION_RULES cr;
1N/A BOOL is_in_root;
1N/A INDEX_ROOT *ir;
1N/A ntfs_attr_search_ctx *actx;
1N/A ntfs_attr *ia_na;
1N/A INDEX_BLOCK *ib;
1N/A VCN ib_vcn;
1N/A BOOL ib_dirty;
1N/A int parent_pos[MAX_PARENT_VCN];
1N/A VCN parent_vcn[MAX_PARENT_VCN];
1N/A int max_depth;
1N/A int pindex;
1N/A u32 block_size;
1N/A u8 vcn_size_bits;
1N/A} ntfs_index_context;
1N/A
1N/Aextern ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *ni,
1N/A ntfschar *name, u32 name_len);
1N/Aextern void ntfs_index_ctx_put(ntfs_index_context *ictx);
1N/Aextern void ntfs_index_ctx_reinit(ntfs_index_context *ictx);
1N/A
1N/Aextern int ntfs_index_lookup(const void *key, const int key_len,
1N/A ntfs_index_context *ictx);
1N/A
1N/Aextern int ntfs_index_add_filename(ntfs_inode *ni, FILE_NAME_ATTR *fn,
1N/A MFT_REF mref);
1N/Aextern int ntfs_index_rm(ntfs_index_context *ictx);
1N/A
1N/Aextern INDEX_ROOT *ntfs_index_root_get(ntfs_inode *ni, ATTR_RECORD *attr);
1N/A
1N/Aextern VCN ntfs_ie_get_vcn(INDEX_ENTRY *ie);
1N/A
1N/Aextern char *ntfs_ie_filename_get(INDEX_ENTRY *ie);
1N/Aextern void ntfs_ie_filename_dump(INDEX_ENTRY *ie);
1N/Aextern void ntfs_ih_filename_dump(INDEX_HEADER *ih);
1N/A
1N/Aextern void ntfs_index_entry_mark_dirty(ntfs_index_context *ictx);
1N/A
1N/A#endif /* _NTFS_INDEX_H */