⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsk_fs.h

📁 linux下开发的针对所有磁盘的数据恢复的源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/*** The Sleuth Kit **** Brian Carrier [carrier <at> sleuthkit [dot] org]** Copyright (c) 2003-2008 Brian Carrier.  All rights reserved**** TASK** Copyright (c) 2002 @stake Inc.  All rights reserved** ** Copyright (c) 1997,1998,1999, International Business Machines          ** Corporation and others. All Rights Reserved.*//** \file tsk_fs.h * External header file for file system support. * Note that this file is not meant to be directly included.   * It is included by both libtsk.h and tsk_fs_i.h. *//* LICENSE* .ad* .fi*	This software is distributed under the IBM Public License.* AUTHOR(S)*	Wietse Venema*	IBM T.J. Watson Research*	P.O. Box 704*	Yorktown Heights, NY 10598, USA--*//** * \defgroup fslib File System Functions */#ifndef _TSK_FS_H#define _TSK_FS_H#include <sys/types.h>#ifdef __cplusplusextern "C" {#endif    typedef struct TSK_FS_INFO TSK_FS_INFO;    typedef struct TSK_FS_FILE TSK_FS_FILE;/**************** BLOCK Structure *******************/    /** \name Generic File System Block Data Structure */    //@{    /** Flags that are used in TSK_FS_BLOCK and in callback of file_walk.         * Note that some of these are dependent. A block can be either TSK_FS_BLOCK_FLAG_ALLOC        * or TSK_FS_BLOCK_FLAG_UNALLOC.  It can be one of TSK_FS_BLOCK_FLAG_RAW, TSK_FS_BLOCK_FLAG_BAD,        * TSK_FS_BLOCK_FLAG_RES, TSK_FS_BLOCK_FLAG_SPARSE, or TSK_FS_BLOCK_FLAG_COMP.  Note that some of         * these are set only by file_walk because they are file-level details, such as compression and sparse.        */    enum TSK_FS_BLOCK_FLAG_ENUM {        TSK_FS_BLOCK_FLAG_UNUSED = 0x0000,      ///< Used to show that TSK_FS_BLOCK structure has no data in it        TSK_FS_BLOCK_FLAG_ALLOC = 0x0001,       ///< Block is allocated (and not TSK_FS_BLOCK_FLAG_UNALLOC)        TSK_FS_BLOCK_FLAG_UNALLOC = 0x0002,     ///< Block is unallocated (and not TSK_FS_BLOCK_FLAG_ALLOC)        TSK_FS_BLOCK_FLAG_CONT = 0x0004,        ///< Block (could) contain file content (and not TSK_FS_BLOCK_FLAG_META)        TSK_FS_BLOCK_FLAG_META = 0x0008,        ///< Block (could) contain file system metadata (and not TSK_FS_BLOCK_FLAG_CONT)        TSK_FS_BLOCK_FLAG_RAW = 0x0010, ///< The data has been read raw from the disk and is not compressed, encrypted, sparse etc.        TSK_FS_BLOCK_FLAG_BAD = 0x0020, ///< Block has been marked as bad by the file system        TSK_FS_BLOCK_FLAG_RES = 0x0040, ///< The data passed in the file_walk callback is from an NTFS resident file        TSK_FS_BLOCK_FLAG_SPARSE = 0x0080,      ///< The data passed in the file_walk calback was stored as sparse (all zeros)        TSK_FS_BLOCK_FLAG_COMP = 0x0100 ///< The data passed in the file_walk callback was stored in a compressed form    };    typedef enum TSK_FS_BLOCK_FLAG_ENUM TSK_FS_BLOCK_FLAG_ENUM;    /**    * Flags that are used to specify which blocks to call the tsk_fs_block_walk() callback function with.     */    enum TSK_FS_BLOCK_WALK_FLAG_ENUM {        TSK_FS_BLOCK_WALK_FLAG_ALLOC = 0x01,    ///< Allocated blocks        TSK_FS_BLOCK_WALK_FLAG_UNALLOC = 0x02,  ///< Unallocated blocks        TSK_FS_BLOCK_WALK_FLAG_CONT = 0x04,     ///< Blocks that could store file content        TSK_FS_BLOCK_WALK_FLAG_META = 0x08,     ///< Blocks that could store file system metadata    };    typedef enum TSK_FS_BLOCK_WALK_FLAG_ENUM TSK_FS_BLOCK_WALK_FLAG_ENUM;#define TSK_FS_BLOCK_TAG 0x1b7c3f4a    /**     * Generic data strcture to hold block data with metadata    */    typedef struct {        int tag;                ///< \internal Will be set to TSK_FS_BLOCK_TAG if structure is valid / allocated         TSK_FS_INFO *fs_info;   ///< Pointer to file system that block is from        char *buf;              ///< Buffer with block data (of size TSK_FS_INFO::block_size)        TSK_DADDR_T addr;       ///< Address of block        TSK_FS_BLOCK_FLAG_ENUM flags;   /// < Flags for block (alloc or unalloc)    } TSK_FS_BLOCK;    /**    * Function definition used for callback to tsk_fs_block_walk().      *     * @param a_block Pointer to block structure that holds block content and flags     * @param a_ptr Pointer that was supplied by the caller who called tsk_fs_block_walk     * @returns Value to identify if walk should continue, stop, or stop because of error     */    typedef TSK_WALK_RET_ENUM(*TSK_FS_BLOCK_WALK_CB) (const TSK_FS_BLOCK *        a_block, void *a_ptr);    // external block-level functions    extern void tsk_fs_block_free(TSK_FS_BLOCK * a_fs_block);    extern TSK_FS_BLOCK *tsk_fs_block_get(TSK_FS_INFO * fs,        TSK_FS_BLOCK * fs_block, TSK_DADDR_T addr);    extern uint8_t tsk_fs_block_walk(TSK_FS_INFO * a_fs,        TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk,        TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action,        void *a_ptr);    //@}/**************** DATA and DATA_LIST Structures ************/    /** \name Generic File System File Content Data Structures */    //@{    /* The location of "most" file content is stored in the generic TSK      * data structures as runs (starting address and length).      */    /**      * Flags used for a TSK_FS_ATTR_RUN entry.      */    typedef enum {        TSK_FS_ATTR_RUN_FLAG_FILLER = 0x01,     ///< Entry is a filler for a run that has not been seen yet in the processing (or has been lost)        TSK_FS_ATTR_RUN_FLAG_SPARSE = 0x02      ///< Entry is a sparse run where all data in the run is zeros    } TSK_FS_ATTR_RUN_FLAG_ENUM;    typedef struct TSK_FS_ATTR_RUN TSK_FS_ATTR_RUN;    /**     * Holds information about a single data run, which has a starting address and length.     * A run describes a consecutive list of blocks that have been allocated to a file.      * A file may have many such runs and they are stringed together in a linked list.     * The entries in the list must be stored in sequential order (based on offset in file).     */    struct TSK_FS_ATTR_RUN {        TSK_FS_ATTR_RUN *next;  ///< Pointer to the next run in the attribute (or NULL)        TSK_DADDR_T offset;     ///< Offset (in blocks) of this run in the file        TSK_DADDR_T addr;       ///< Starting block address (in file system) of run        TSK_DADDR_T len;        ///< Number of blocks in run (0 when entry is not in use)        TSK_FS_ATTR_RUN_FLAG_ENUM flags;        ///< Flags for run    };    /**     * Flags used for the TSK_FS_ATTR structure, which is used to      * store file content metadata.      */    typedef enum {        TSK_FS_ATTR_INUSE = 0x01,       ///< data structure is in use        TSK_FS_ATTR_NONRES = 0x02,      ///< Contains non-resident data (i.e. located in blocks)        TSK_FS_ATTR_RES = 0x04, ///< Contains resident data (i.e. in a small buffer)        TSK_FS_ATTR_ENC = 0x10, ///< Contains encrypted data        TSK_FS_ATTR_COMP = 0x20,        ///< Contains compressed data        TSK_FS_ATTR_SPARSE = 0x40,      ///< Contains sparse data        TSK_FS_ATTR_RECOVERY = 0x80,    ///< Data was determined in file recovery mode    } TSK_FS_ATTR_FLAG_ENUM;    /**         * File walk callback function definition.  This is called for         * chunks of content in the file being processed.          * @param a_fs_file Pointer to file being processed        * @param a_off Byte offset in file that this data is for        * @param a_addr Address of data being passed (valid only if a_flags have RAW set)        * @param a_buf Pointer to buffer with file content        * @param a_len Size of data in buffer (in bytes)        * @param a_flags Flags about the file content        * @param a_ptr Pointer that was specified by caller to inode_walk        * @returns Value that tells file walk to continue or stop        */    typedef TSK_WALK_RET_ENUM(*TSK_FS_FILE_WALK_CB) (TSK_FS_FILE *        a_fs_file, TSK_OFF_T a_off, TSK_DADDR_T a_addr, char *a_buf,        size_t a_len, TSK_FS_BLOCK_FLAG_ENUM a_flags, void *a_ptr);    /**     * Flags used by tsk_fs_file_walk to determine when the callback function should     * be used. */    typedef enum {        TSK_FS_FILE_WALK_FLAG_SLACK = 0x01,     ///< Include the file's slack space in the callback.        TSK_FS_FILE_WALK_FLAG_NOID = 0x02,      ///< Ignore the Id argument given in the API (use only the type)        TSK_FS_FILE_WALK_FLAG_AONLY = 0x04,     ///< Provide callback with only addresses and no file content.        TSK_FS_FILE_WALK_FLAG_NOSPARSE = 0x08,  ///< Do not include sparse blocks in the callback.    } TSK_FS_FILE_WALK_FLAG_ENUM;    /**     * These are based on the NTFS type values.      */    typedef enum {        TSK_FS_ATTR_TYPE_DEFAULT = 0x0, // 16        TSK_FS_ATTR_TYPE_NTFS_SI = 0x10,        // 16        TSK_FS_ATTR_TYPE_NTFS_ATTRLIST = 0x20,  // 32        TSK_FS_ATTR_TYPE_NTFS_FNAME = 0x30,     // 48        TSK_FS_ATTR_TYPE_NTFS_VVER = 0x40,      // 64 (NT)        TSK_FS_ATTR_TYPE_NTFS_OBJID = 0x40,     // 64 (2K)        TSK_FS_ATTR_TYPE_NTFS_SEC = 0x50,       // 80        TSK_FS_ATTR_TYPE_NTFS_VNAME = 0x60,     // 96        TSK_FS_ATTR_TYPE_NTFS_VINFO = 0x70,     // 112        TSK_FS_ATTR_TYPE_NTFS_DATA = 0x80,      // 128        TSK_FS_ATTR_TYPE_NTFS_IDXROOT = 0x90,   // 144        TSK_FS_ATTR_TYPE_NTFS_IDXALLOC = 0xA0,  // 160        TSK_FS_ATTR_TYPE_NTFS_BITMAP = 0xB0,    // 176        TSK_FS_ATTR_TYPE_NTFS_SYMLNK = 0xC0,    // 192 (NT)        TSK_FS_ATTR_TYPE_NTFS_REPARSE = 0xC0,   // 192 (2K)        TSK_FS_ATTR_TYPE_NTFS_EAINFO = 0xD0,    // 208        TSK_FS_ATTR_TYPE_NTFS_EA = 0xE0,        // 224        TSK_FS_ATTR_TYPE_NTFS_PROP = 0xF0,      //  (NT)        TSK_FS_ATTR_TYPE_NTFS_LOG = 0x100       //  (2K)    } TSK_FS_ATTR_TYPE_ENUM;#define TSK_FS_ATTR_ID_DEFAULT  0       ///< Default Data ID used if file system does not assign one.    typedef struct TSK_FS_ATTR TSK_FS_ATTR;    /**     * Holds information about the location of file content (or a file attribute). For most file systems, a file     * has only a single attribute that stores the file content.      * Other file systems, such as NTFS, have multiple     * attributes.  If multiple attributes exist, they are stored in a linked list.     * Attributes can be "resident", which means the data is stored     * in a small buffer instead of being stored in a full file system block.     * "Non-resident" attributes store data in blocks and they are stored in      * the data structure as a series of runs.       * This structure is used to represent both of these cases.     *     * The non-resident data has several size values.      * \verbatim     * |--------------------------------------------------------------------|     * |skiplen|---------------allocsize------------------------------------|     * |skiplen|---------------size-----------------------------------|     * |skiplen|---------------initsize------------|     * \endverbatim     */    struct TSK_FS_ATTR {        TSK_FS_ATTR *next;      ///< Pointer to next attribute in list        TSK_FS_FILE *fs_file;   ///< Pointer to the file that this is from        TSK_FS_ATTR_FLAG_ENUM flags;    ///< Flags for attribute        char *name;             ///< Name of attribute (could be NULL) (in UTF-8)        size_t name_size;       ///< Number of bytes allocated to name        TSK_FS_ATTR_TYPE_ENUM type;     ///< Type of attribute        uint16_t id;            ///< Id of attribute        TSK_OFF_T size;         ///< Size in bytes of attribute (does not include skiplen for non-resident)        /**         * Data associated with a non-resident file / attribute.          * The data is stored in one or more data runs.          */        struct {            TSK_FS_ATTR_RUN *run;       ///< Linked list of runs for non-resident attributes            TSK_FS_ATTR_RUN *run_end;   ///< Pointer to final run in the list            uint32_t skiplen;   ///< Number of initial bytes in run to skip before content begins. The size field does not include this length.             TSK_OFF_T allocsize;        ///< Number of bytes that are allocated in all clusters of non-resident run (will be larger than size - does not include skiplen).  This is used for slack space.            TSK_OFF_T initsize; ///< Number of bytes (starting from offset 0) that have data (including FILLER) saved for them (smaller then or equal to size - NTFS only).              uint32_t compsize;  ///< Size of compression units (needed only if NTFS file is compressed)        } nrd;        /**         * Data associated with a resident attribute / file.           * The data is stored in a buffer.          */        struct {            uint8_t *buf;       ///< Buffer for resident data            size_t buf_size;    ///< Number of bytes allocated to buf        } rd;        /* Special file (compressed, encrypted, etc.) */         ssize_t(*r) (const TSK_FS_ATTR * fs_attr,            TSK_OFF_T a_offset, char *a_buf, size_t a_len);         uint8_t(*w) (const TSK_FS_ATTR * fs_attr,            int flags, TSK_FS_FILE_WALK_CB, void *);    };    /**     * Structure used as the head of an attribute list.       */    typedef struct {        TSK_FS_ATTR *head;    } TSK_FS_ATTRLIST;    extern uint8_t tsk_fs_attr_walk(const TSK_FS_ATTR * a_fs_attr,        TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action,        void *a_ptr);    //@}/**************** META_NAME_LIST Structure *******************/    /** \name Generic File System File Metadata Data Structures */    //@{    /**     * Size of name array in TSK_FS_META_NAME_LIST structure     */#define TSK_FS_META_NAME_LIST_NSIZE    512    typedef struct TSK_FS_META_NAME_LIST TSK_FS_META_NAME_LIST;    /**     * Relatively generic structure to hold file names that are stored with     * the file metadata.  Note that this is different from the     * file name stored in the directory heirarchy, which is      * part of the tsk_fs_name_... code.  This is currently     * used for NTFS and FAT file systems only.     */    struct TSK_FS_META_NAME_LIST {        TSK_FS_META_NAME_LIST *next;    ///< Pointer to next name (or NULL)        char name[TSK_FS_META_NAME_LIST_NSIZE]; ///< Name in UTF-8 (does not include parent directory name)        TSK_INUM_T par_inode;   ///< Inode address of parent directory (NTFS only)        uint32_t par_seq;       ///< Sequence number of parent directory (NTFS only)    };/****************** META Structure ***************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -