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

📄 tsk_fs.h

📁 linux下开发的针对所有磁盘的数据恢复的源码
💻 H
📖 第 1 页 / 共 3 页
字号:
    /**     * Metadata flags used in TSK_FS_META.flags and in request to inode_walk     */    enum TSK_FS_META_FLAG_ENUM {        TSK_FS_META_FLAG_ALLOC = 0x01,  ///< Metadata structure is currently in an allocated state        TSK_FS_META_FLAG_UNALLOC = 0x02,        ///< Metadata structure is currently in an unallocated state        TSK_FS_META_FLAG_USED = 0x04,   ///< Metadata structure has been allocated at least once        TSK_FS_META_FLAG_UNUSED = 0x08, ///< Metadata structure has never been allocated.         TSK_FS_META_FLAG_ORPHAN = 0x10, ///< Metadata structure is unallocated and has no file name pointing to it.        TSK_FS_META_FLAG_COMP = 0x20    ///< The file contents are compressed.     };    typedef enum TSK_FS_META_FLAG_ENUM TSK_FS_META_FLAG_ENUM;    enum TSK_FS_META_ATTR_FLAG_ENUM {        TSK_FS_META_ATTR_EMPTY, ///< The data in the attributes (if any) is not for this file        TSK_FS_META_ATTR_STUDIED,       ///< The data in the attributes are for this file        TSK_FS_META_ATTR_ERROR, ///< The attributes for this file could not be loaded    };    typedef enum TSK_FS_META_ATTR_FLAG_ENUM TSK_FS_META_ATTR_FLAG_ENUM;    /**     * Values for the mode field -- which identifies the file type      * and permissions.     */    enum TSK_FS_META_TYPE_ENUM {        TSK_FS_META_TYPE_UNDEF = 0x00,        TSK_FS_META_TYPE_REG = 0x01,    ///< Regular file        TSK_FS_META_TYPE_DIR = 0x02,    ///< Directory file        TSK_FS_META_TYPE_FIFO = 0x03,   ///< Named pipe (fifo)         TSK_FS_META_TYPE_CHR = 0x04,    ///< Character device         TSK_FS_META_TYPE_BLK = 0x05,    ///< Block device         TSK_FS_META_TYPE_LNK = 0x06,    ///< Symbolic link        TSK_FS_META_TYPE_SHAD = 0x07,   ///< SOLARIS ONLY         TSK_FS_META_TYPE_SOCK = 0x08,   ///< UNIX domain socket        TSK_FS_META_TYPE_WHT = 0x09,    ///< Whiteout        TSK_FS_META_TYPE_VIRT = 0x0a,   ///< "Virtual File" created by TSK for file system areas    };    typedef enum TSK_FS_META_TYPE_ENUM TSK_FS_META_TYPE_ENUM;#define TSK_FS_META_TYPE_STR_MAX 0x0b   ///< Number of file types in shortname array    extern char tsk_fs_meta_type_str[TSK_FS_META_TYPE_STR_MAX][2];    enum TSK_FS_META_MODE_ENUM {        /* The following describe the file permissions */        TSK_FS_META_MODE_ISUID = 0004000,       ///< set user id on execution         TSK_FS_META_MODE_ISGID = 0002000,       ///< set group id on execution         TSK_FS_META_MODE_ISVTX = 0001000,       ///< sticky bit         TSK_FS_META_MODE_IRUSR = 0000400,       ///< R for owner         TSK_FS_META_MODE_IWUSR = 0000200,       ///< W for owner         TSK_FS_META_MODE_IXUSR = 0000100,       ///< X for owner         TSK_FS_META_MODE_IRGRP = 0000040,       ///< R for group         TSK_FS_META_MODE_IWGRP = 0000020,       ///< W for group         TSK_FS_META_MODE_IXGRP = 0000010,       ///< X for group         TSK_FS_META_MODE_IROTH = 0000004,       ///< R for other         TSK_FS_META_MODE_IWOTH = 0000002,       ///< W for other         TSK_FS_META_MODE_IXOTH = 0000001        ///< X for other     };    typedef enum TSK_FS_META_MODE_ENUM TSK_FS_META_MODE_ENUM;#define TSK_FS_META_TAG 0x13524635    /**      * TSK data structure to store general file and directory metadata.      * Note that the file in the file     * system may have more metadata than is stored here.       * For performance reasons, the run list of the file content is not always known     * when the file is loaded.  It may be loaded only when needed by the internal code.      * The TSK_FS_META::content_ptr pointer contains file system-specific data that will be     * used to determine the full run. After it has been loaded, the TSK_FS_META::attr field     * will contain that info.       */    typedef struct {        int tag;                ///< \internal Will be set to TSK_FS_META_TAG if structure is allocated        TSK_FS_INFO *fs_info;   ///< Pointer to file system that file is located in.        TSK_FS_META_FLAG_ENUM flags;    ///< Flags for this file for its allocation status etc.        TSK_INUM_T addr;        ///< Address of the meta data structure for this file        TSK_FS_META_TYPE_ENUM type;     ///< File type        TSK_FS_META_MODE_ENUM mode;     ///< Unix-style permissions        int nlink;              ///< link count (number of file names pointing to this)        TSK_OFF_T size;         ///< file size (in bytes)        TSK_UID_T uid;          ///< owner id        TSK_GID_T gid;          ///< group id        /* @@@ Need to make these 64-bits ... ? */        time_t mtime;           ///< last file content modification time (stored in number of seconds since Jan 1, 1970 UTC)        time_t atime;           ///< last file content accessed time (stored in number of seconds since Jan 1, 1970 UTC)        time_t ctime;           ///< last file / metadata status change time (stored in number of seconds since Jan 1, 1970 UTC)        time_t crtime;          ///< Created time (stored in number of seconds since Jan 1, 1970 UTC)        /* filesystem specific times */        union {            struct {                time_t dtime;   ///< Linux deletion time            } ext2;            struct {                time_t bkup_time;       ///< HFS+ backup time            } hfs;        } time2;        void *content_ptr;      ///< Pointer to file system specific data that is used to store references to file content        size_t content_len;     ///< size of content  buffer        uint32_t seq;           ///< Sequence number for file (NTFS only, is incremented when entry is reallocated)         /** Contains run data on the file content (specific locations where content is stored).           * Check attr_state to determine if data in here is valid because not all file systems          * load this data when a file is loaded.  It may not be loaded until needed by one         * of the APIs. Most file systems will have only one attribute, but NTFS will have several. */        TSK_FS_ATTRLIST *attr;        TSK_FS_META_ATTR_FLAG_ENUM attr_state;  ///< State of the data in the TSK_FS_META::attr structure        TSK_FS_META_NAME_LIST *name2;   ///< Name of file stored in metadata (FAT and NTFS Only)        char *link;             ///< Name of target file if this is a symbolic link    } TSK_FS_META;/** String that is prepended to orphan FAT & NTFS files when the file * name is known, but the parent is not */#define TSK_FS_ORPHAN_STR "-ORPHAN_FILE-"    /**         * inode walk callback function definition.  This is called for every file        * that meets the critera specified when inode_walk was called.         * @param a_fs_file Pointer to the current file        * @param a_ptr Pointer that was specified by caller to inode_walk        * @returns Value that tells inode walk to continue or stop        */    typedef TSK_WALK_RET_ENUM(*TSK_FS_META_WALK_CB) (TSK_FS_FILE *        a_fs_file, void *a_ptr);    extern uint8_t tsk_fs_meta_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_start,        TSK_INUM_T a_end, TSK_FS_META_FLAG_ENUM a_flags,        TSK_FS_META_WALK_CB a_cb, void *a_ptr);    //@}    /************* NAME / DIR structures **********/    /** \name Generic File System File Name Data Structures */    //@{    /**    * File name flags that are used when specifying the status of     * a name in the TSK_FS_NAME structure     */    typedef enum {        TSK_FS_NAME_FLAG_ALLOC = 0x01,  ///< Name is in an allocated state        TSK_FS_NAME_FLAG_UNALLOC = 0x02,        ///< Name is in an unallocated state    } TSK_FS_NAME_FLAG_ENUM;    /**        * File type values -- as specified in the directory entry structure.     */    typedef enum {        TSK_FS_NAME_TYPE_UNDEF = 0,     ///< Unknown type        TSK_FS_NAME_TYPE_FIFO = 1,      ///< Named pipe         TSK_FS_NAME_TYPE_CHR = 2,       ///< Character device        TSK_FS_NAME_TYPE_DIR = 3,       ///< Directory         TSK_FS_NAME_TYPE_BLK = 4,       ///< Block device        TSK_FS_NAME_TYPE_REG = 5,       ///< Regular file         TSK_FS_NAME_TYPE_LNK = 6,       ///< Symbolic link         TSK_FS_NAME_TYPE_SOCK = 7,      ///< Socket         TSK_FS_NAME_TYPE_SHAD = 8,      ///< Shadow inode (solaris)         TSK_FS_NAME_TYPE_WHT = 9,       ///< Whiteout (openbsd)        TSK_FS_NAME_TYPE_VIRT = 10,     ///< Special (TSK added "Virtual" files)    } TSK_FS_NAME_TYPE_ENUM;#define TSK_FS_NAME_TYPE_STR_MAX 11     ///< Number of types that have a short string name    /* ascii representation of above types */    extern char tsk_fs_name_type_str[TSK_FS_NAME_TYPE_STR_MAX][2];#define  TSK_FS_NAME_TAG 0x23147869    /**     * Generic structure to store the file name information that is stored in     * a directory. Most file systems seperate the file name from the metadata, but     * some do not (such as FAT). This structure contains the name and address of the      * metadata.     */    typedef struct {        int tag;                ///< \internal Set to TSK_FS_NAME_ID if allocated, 0 if not        char *name;             ///< The name of the file (in UTF-8)        size_t name_size;       ///< The number of bytes allocated to name        char *shrt_name;        ///< The short name of the file (FAT and NTFS only) or null (in UTF-8)        size_t shrt_name_size;  ///< The number of bytes allocated to shrt_name        TSK_INUM_T meta_addr;   ///< Address of the metadata structure that the name points to.         uint32_t meta_seq;      ///< Sequence number for metadata structure (NTFS only)         TSK_FS_NAME_TYPE_ENUM type;     ///< File type information (directory, file, etc.)        TSK_FS_NAME_FLAG_ENUM flags;    ///< Flags that describe allocation status etc.     } TSK_FS_NAME;    /**     * Definition of callback function that is used by tsk_fs_dir_walk().  This is     * is called for each file in a directory.      * @param a_fs_file Pointer to the current file in the directory     * @param a_path Path of the file     * @param a_ptr Pointer that was originally passed by caller to tsk_fs_dir_walk.     * @returns Value to signal if tsk_fs_dir_walk should stop or continue.      */    typedef TSK_WALK_RET_ENUM(*TSK_FS_DIR_WALK_CB) (TSK_FS_FILE *        a_fs_file, const char *a_path, void *a_ptr);#define TSK_FS_DIR_TAG  0x97531246    /**     * A handle to a directory so that its files can be individually accessed.     */    typedef struct {        int tag;                ///< \internal Will be set to TSK_FS_DIR_TAG if structure is still allocated, 0 if not        TSK_FS_FILE *fs_file;   ///< Pointer to the file structure for the directory.        TSK_FS_NAME *names;     ///< Pointer to list of names in directory.         size_t names_used;      ///< Number of name structures in queue being used        size_t names_alloc;     ///< Number of name structures that were allocated        TSK_FS_INFO *fs_info;   ///< Pointer to file system the directory is located in    } TSK_FS_DIR;    /**     * Flags that are used when walking names in directories.  These are used to identify     * which files to call the callback function on.      */    typedef enum {        TSK_FS_DIR_WALK_FLAG_ALLOC = 0x01,      ///< Return allocated names in callback        TSK_FS_DIR_WALK_FLAG_UNALLOC = 0x02,    ///< Return unallocated names in callback        TSK_FS_DIR_WALK_FLAG_RECURSE = 0x04,    ///< Recurse into sub-directories         TSK_FS_DIR_WALK_FLAG_NOORPHAN = 0x08,   ///< Do not return (or recurse into) the special Orphan directory    } TSK_FS_DIR_WALK_FLAG_ENUM;    extern TSK_FS_DIR *tsk_fs_dir_open_meta(TSK_FS_INFO * a_fs,        TSK_INUM_T a_addr);    extern TSK_FS_DIR *tsk_fs_dir_open(TSK_FS_INFO * a_fs,        const char *a_dir);    extern uint8_t tsk_fs_dir_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_inode,        TSK_FS_DIR_WALK_FLAG_ENUM a_flags, TSK_FS_DIR_WALK_CB a_action,        void *a_ptr);    extern size_t tsk_fs_dir_getsize(const TSK_FS_DIR *);    extern TSK_FS_FILE *tsk_fs_dir_get(const TSK_FS_DIR *, size_t);    extern void tsk_fs_dir_close(TSK_FS_DIR *);    extern int8_t tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path,        TSK_INUM_T * a_result, TSK_FS_NAME * a_fs_name);    //@}    /********************* FILE Structure *************************/    /** \name Generic File System File  Data Structures */    //@{#define  TSK_FS_FILE_TAG 0x11212212    /**     * Generic structure used to refer to files in the file system.  A file will     * typically have a name and metadata.  This structure holds that type of information.     * When deleted files are being processed, this structure may have the name defined     * but not metadata because it no longer exists. Or, if you are calling meta_walk     * and are not processing at the name level, then the name will not be defined.       * always check these to make sure they are not null before they are read. */    struct TSK_FS_FILE {        int tag;                ///< \internal Will be set to TSK_FS_FILE_TAG if structure is allocated        TSK_FS_NAME *name;      ///< Pointer to name of file (or NULL if file was opened using metadata address)        TSK_FS_META *meta;      ///< Pointer to metadata of file (or NULL if name has invalid metadata address)        TSK_FS_INFO *fs_info;   ///< Pointer to file system that the file is located in.    };    /**     * Flags used by tsk_fs_file_read */    typedef enum {        TSK_FS_FILE_READ_FLAG_SLACK = 0x01,     ///< Allow read access into slack space        TSK_FS_FILE_READ_FLAG_NOID = 0x02,      ///< Ignore the Id argument given in the API (use only the type)    } TSK_FS_FILE_READ_FLAG_ENUM;    extern void tsk_fs_file_close(TSK_FS_FILE * a_fs_file);    extern TSK_FS_FILE *tsk_fs_file_open(TSK_FS_INFO * a_fs,        TSK_FS_FILE * a_fs_file, const char *a_path);    extern TSK_FS_FILE *tsk_fs_file_open_meta(TSK_FS_INFO * fs,        TSK_FS_FILE * fs_file, TSK_INUM_T addr);    extern ssize_t        tsk_fs_file_read(TSK_FS_FILE *, TSK_OFF_T, char *, size_t,        TSK_FS_FILE_READ_FLAG_ENUM);    extern ssize_t tsk_fs_file_read_type(TSK_FS_FILE *,        TSK_FS_ATTR_TYPE_ENUM, uint16_t, TSK_OFF_T, char *, size_t,        TSK_FS_FILE_READ_FLAG_ENUM);    extern const TSK_FS_ATTR *tsk_fs_file_attr_get(TSK_FS_FILE *        a_fs_file);    extern int tsk_fs_file_attr_getsize(TSK_FS_FILE * a_fs_file);    extern const TSK_FS_ATTR *tsk_fs_file_attr_get_idx(TSK_FS_FILE *        a_fs_file, int a_idx);    extern const TSK_FS_ATTR *tsk_fs_file_attr_get_type(TSK_FS_FILE *        a_fs_file, TSK_FS_ATTR_TYPE_ENUM, uint16_t, uint8_t);    extern uint8_t tsk_fs_file_walk(TSK_FS_FILE * a_fs_file,        TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action,        void *a_ptr);    extern uint8_t tsk_fs_file_walk_type(TSK_FS_FILE * a_fs_file,        TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id,        TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action,        void *a_ptr);    extern ssize_t tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr,        TSK_OFF_T a_offset, char *a_buf, size_t a_len,        TSK_FS_FILE_READ_FLAG_ENUM a_flags);    //@}/****************** Journal Structures *************/    /** \name Generic File System Journal Data Structures */    //@{

⌨️ 快捷键说明

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