如何恢复Linux上删除的文件 (6)

豆豆网   技术应用频道   2008年04月15日  【字号: 收藏本文

内容摘要:reiserfs 对于小文件的存取速度非常高,这取决于它所采用的精美的设计:reiserfs 文件系统就是一棵动态的 B+ 树,小文件和大文件的尾部数据都可以通过保存到叶子节点中而加快存取速度。本文将探讨 reiserfs 的设计和实现内幕,并从中探讨恢复删除文件的可能性。

  图 4. 格式化叶子节点的布局

如何恢复Linux上删除的文件 (6)

  从图中可以看出,每个格式化叶子节点都以一个数据块头开始,然后是从两端向中间伸展的条目头和条目数据的数组,空闲空间保留在中间,这种设计是为了扩充方便。

  所谓条目(item,或称为项)就是可以存储在单个节点中的一个数据容器,我们可以认为条目是由条目头和条目数据体组成的。

  清单5. item_head 结构定义

460 /* Everything in the filesystem is stored as a set of items. The
461   item head contains the key of the item, its free space (for
462   indirect items) and specifies the location of the item itself
463   within the block. */
464
465 struct item_head {
466     /* Everything in the tree is found by searching for it based on
467     * its key.*/
468     struct reiserfs_key ih_key;
469     union {
470         /* The free space in the last unformatted node of an
471          indirect item if this is an indirect item. This
472          equals 0xFFFF iff this is a direct item or stat data
473          item. Note that the key, not this field, is used to
474          determine the item type, and thus which field this
475          union contains. */
476         __le16 ih_free_space_reserved;
477         /* Iff this is a directory item, this field equals the
478          number of directory entries in the directory item. */
479         __le16 ih_entry_count;
480     } __attribute__ ((__packed__)) u;
481     __le16 ih_item_len;   /* total size of the item body */
482     __le16 ih_item_location;    /* an offset to the item body
483                     * within the block */
484     __le16 ih_version;   /* 0 for all old items, 2 for new
485                  ones. Highest bit is set by fsck
486                  temporary, cleaned after all
487                  done */
488 } __attribute__ ((__packed__));

来源:ibm    作者:冯锐 丁成    责编:豆豆技术应用

正在加载评论...