parent
f7ffcf6445
commit
c7bcb144b2
10
ChangeLog
10
ChangeLog
|
@ -54,15 +54,15 @@
|
|||
of using the opt global structure. Necessary so can call the
|
||||
modified ntfs_decompress_mapping_pairs() from mkntfs.c.
|
||||
- Add libntfs/debug.c providing:
|
||||
ntfs_debug_dump_run_list().
|
||||
ntfs_debug_dump_runlist().
|
||||
- Add new API call ntfs_check_if_mounted() to volume.[ch]. (Matthew
|
||||
Fanto, me)
|
||||
- Do folding assisting cleanups. (Richard Russon, me)
|
||||
- Add new API call is_boot_sector_ntfs() provided by bootsect.[hc].
|
||||
- Define and write more API calls provided by attrib.[ch]:
|
||||
ntfs_merge_run_lists(),
|
||||
ntfs_merge_runlists(),
|
||||
ntfs_decompress_mapping_pairs(),
|
||||
ntfs_attr_map_run_list(),
|
||||
ntfs_attr_map_runlist(),
|
||||
ntfs_{rl,attr}_vcn_to_lcn(),
|
||||
ntfs_attr_find_vcn(),
|
||||
ntfs_attr_init(),
|
||||
|
@ -119,7 +119,7 @@
|
|||
instead of aborting and returning error EIO to flag the corruption.
|
||||
- Add new syntactic sugar API provided by attrib.h:
|
||||
ntfs_walk_attrs(). (Szakacsits Szabolcs)
|
||||
- Add new API for compressing run lists into mapping pairs arrays
|
||||
- Add new API for compressing runlists into mapping pairs arrays
|
||||
provided by attrib.[ch] (adapted from mkntfs.c):
|
||||
ntfs_get_nr_significant_bytes(),
|
||||
ntfs_get_size_for_mapping_pairs(),
|
||||
|
@ -132,7 +132,7 @@
|
|||
flexible use.
|
||||
- Don't use string concatenation with __FUNCTION__ as gcc-3.x don't
|
||||
like it.
|
||||
- Move run list functions to runlist.[hc]. (Richard Russon)
|
||||
- Move runlist functions to runlist.[hc]. (Richard Russon)
|
||||
- Add new API to volume.[hc] and use it (Szakacsits Szabolcs):
|
||||
ntfs_is_version_supported(),
|
||||
NTFS_V{1_[12],2_x,3_[01]}() macros,
|
||||
|
|
|
@ -11,7 +11,7 @@ Regis Duchesne's NTFS documentation and from various LZ77 descriptions) and
|
|||
further refined by looking at a few compressed streams to figure out some
|
||||
uncertainties.
|
||||
|
||||
Note: You should also read the run list description with regards to compression
|
||||
Note: You should also read the runlist description with regards to compression
|
||||
in linux-ntfs/include/layout.h. Just search for "Attribute compression".
|
||||
FIXME: Should merge the info from there into this document some time.
|
||||
|
||||
|
@ -30,14 +30,14 @@ Each cb is independent of the other cbs and is thus the minimal unit we have
|
|||
to parse even if we wanted to decompress only one byte.
|
||||
|
||||
Also, a cb can be totally uncompressed and this would be indicated as a sparse
|
||||
cb in the run list.
|
||||
cb in the runlist.
|
||||
|
||||
Thus, we need to look at the run list of the compressed data stream, starting
|
||||
Thus, we need to look at the runlist of the compressed data stream, starting
|
||||
at the beginning of the first cb overlapping @page. So we convert the page
|
||||
offset into units of clusters (vcn), and round the vcn down to a mutliple of
|
||||
cb_size clusters.
|
||||
|
||||
We then scan the run list for the appropriate position. Based on what we find
|
||||
We then scan the runlist for the appropriate position. Based on what we find
|
||||
there, we decide how to proceed.
|
||||
|
||||
If the cb is not compressed at all, and covers the whole of @page, we pretend
|
||||
|
|
|
@ -156,14 +156,14 @@ typedef enum {
|
|||
|
||||
/**
|
||||
* ntfs_attr - ntfs in memory non-resident attribute structure
|
||||
* @rl: if not NULL, the decompressed run list
|
||||
* @rl: if not NULL, the decompressed runlist
|
||||
* @ni: base ntfs inode to which this attribute belongs
|
||||
* @type: attribute type
|
||||
* @name: Unicode name of the attribute
|
||||
* @name_len: length of @name in Unicode characters
|
||||
* @state: NTFS attribute specific flags descibing this attribute
|
||||
*
|
||||
* This structure exists purely to provide a mechanism of caching the run list
|
||||
* This structure exists purely to provide a mechanism of caching the runlist
|
||||
* of an attribute. If you want to operate on a particular attribute extent,
|
||||
* you should not be using this structure at all. If you want to work with a
|
||||
* resident attribute, you should not be using this structure at all. As a
|
||||
|
@ -175,9 +175,9 @@ typedef enum {
|
|||
* record, edit that, and then write back the mft record (or set the
|
||||
* corresponding ntfs inode dirty for delayed write back).
|
||||
*
|
||||
* @rl is the decompressed run list of the attribute described by this
|
||||
* @rl is the decompressed runlist of the attribute described by this
|
||||
* structure. Obviously this only makes sense if the attribute is not resident,
|
||||
* i.e. NAttrNonResident() is true. If the run list hasn't been decomressed yet
|
||||
* i.e. NAttrNonResident() is true. If the runlist hasn't been decomressed yet
|
||||
* @rl is NULL, so be prepared to cope with @rl == NULL.
|
||||
*
|
||||
* @ni is the base ntfs inode of the attribute described by this structure.
|
||||
|
@ -190,7 +190,7 @@ typedef enum {
|
|||
* structure. See ntfs_attr_state_bits above.
|
||||
*/
|
||||
struct _ntfs_attr {
|
||||
run_list_element *rl;
|
||||
runlist_element *rl;
|
||||
ntfs_inode *ni;
|
||||
ATTR_TYPES type;
|
||||
uchar_t *name;
|
||||
|
@ -251,14 +251,14 @@ extern s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos,
|
|||
extern s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos,
|
||||
s64 bk_cnt, const u32 bk_size, void *src);
|
||||
|
||||
extern int ntfs_attr_map_run_list(ntfs_attr *na, VCN vcn);
|
||||
extern int ntfs_attr_map_runlist(ntfs_attr *na, VCN vcn);
|
||||
|
||||
extern LCN ntfs_attr_vcn_to_lcn(ntfs_attr *na, const VCN vcn);
|
||||
extern run_list_element *ntfs_attr_find_vcn(ntfs_attr *na, const VCN vcn);
|
||||
extern runlist_element *ntfs_attr_find_vcn(ntfs_attr *na, const VCN vcn);
|
||||
|
||||
extern int ntfs_get_nr_significant_bytes(const s64 n);
|
||||
extern int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol,
|
||||
const run_list_element *rl);
|
||||
const runlist_element *rl);
|
||||
|
||||
extern int ntfs_write_significant_bytes(s8 *dst, const s8 *dst_max,
|
||||
const s64 n);
|
||||
|
|
|
@ -65,14 +65,14 @@ static __inline__ void Dperror(const char *s)
|
|||
errno = eo;
|
||||
}
|
||||
|
||||
extern void ntfs_debug_dump_run_list(const run_list_element *rl);
|
||||
extern void ntfs_debug_dump_runlist(const runlist_element *rl);
|
||||
|
||||
#else
|
||||
|
||||
static __inline__ void Dprintf(const char *fmt, ...) {}
|
||||
static __inline__ void Dputs(const char *s) {}
|
||||
static __inline__ void Dperror(const char *s) {}
|
||||
static __inline__ void ntfs_debug_dump_run_list(const run_list_element *rl) {}
|
||||
static __inline__ void ntfs_debug_dump_runlist(const runlist_element *rl) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ struct _ntfs_inode {
|
|||
*/
|
||||
u32 attr_list_size; /* Length of attribute list value in bytes. */
|
||||
u8 *attr_list; /* Attribute list value itself. */
|
||||
run_list *attr_list_rl; /* Run list for the attribute list value. */
|
||||
runlist *attr_list_rl; /* Run list for the attribute list value. */
|
||||
s32 nr_extents; /* For a base mft record, the number of
|
||||
attached extent inodes (0 if none), for
|
||||
extent records this is -1. */
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
#include "types.h"
|
||||
|
||||
/* Forward declarations */
|
||||
typedef struct _run_list_element run_list_element;
|
||||
typedef run_list_element run_list;
|
||||
typedef struct _runlist_element runlist_element;
|
||||
typedef runlist_element runlist;
|
||||
|
||||
#include "attrib.h"
|
||||
#include "volume.h"
|
||||
|
||||
/*
|
||||
* run_list_element - in memory vcn to lcn mapping array element
|
||||
* runlist_element - in memory vcn to lcn mapping array element
|
||||
* @vcn: starting vcn of the current array element
|
||||
* @lcn: starting lcn of the current array element
|
||||
* @length: length in clusters of the current array element
|
||||
|
@ -45,25 +45,25 @@ typedef run_list_element run_list;
|
|||
* When lcn == -1 this means that the count vcns starting at vcn are not
|
||||
* physically allocated (i.e. this is a hole / data is sparse).
|
||||
*/
|
||||
struct _run_list_element {/* In memory vcn to lcn mapping structure element. */
|
||||
struct _runlist_element {/* In memory vcn to lcn mapping structure element. */
|
||||
VCN vcn; /* vcn = Starting virtual cluster number. */
|
||||
LCN lcn; /* lcn = Starting logical cluster number. */
|
||||
s64 length; /* Run length in clusters. */
|
||||
};
|
||||
|
||||
extern LCN ntfs_rl_vcn_to_lcn(const run_list_element *rl, const VCN vcn);
|
||||
extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
|
||||
|
||||
extern s64 ntfs_rl_pwrite(const ntfs_volume *vol, const run_list_element *rl,
|
||||
extern s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl,
|
||||
const s64 pos, s64 count, void *b);
|
||||
|
||||
extern run_list_element *ntfs_merge_run_lists(run_list_element *drl,
|
||||
run_list_element *srl);
|
||||
extern runlist_element *ntfs_merge_runlists(runlist_element *drl,
|
||||
runlist_element *srl);
|
||||
|
||||
extern run_list_element *ntfs_decompress_mapping_pairs(const ntfs_volume *vol,
|
||||
const ATTR_RECORD *attr, run_list_element *old_rl);
|
||||
extern runlist_element *ntfs_decompress_mapping_pairs(const ntfs_volume *vol,
|
||||
const ATTR_RECORD *attr, runlist_element *old_rl);
|
||||
|
||||
extern int ntfs_build_mapping_pairs(const ntfs_volume *vol, s8 *dst,
|
||||
const int dst_len, const run_list_element *rl);
|
||||
const int dst_len, const runlist_element *rl);
|
||||
|
||||
#endif /* defined _NTFS_RUNLIST_H */
|
||||
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* ntfs_debug_dump_run_list - Dump a run list.
|
||||
* ntfs_debug_dump_runlist - Dump a runlist.
|
||||
*/
|
||||
void ntfs_debug_dump_run_list(const run_list_element *rl)
|
||||
void ntfs_debug_dump_runlist(const runlist_element *rl)
|
||||
{
|
||||
int i = 0;
|
||||
const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
|
||||
"LCN_ENOENT ", "LCN_EINVAL ",
|
||||
"LCN_unknown " };
|
||||
|
||||
Dputs("NTFS-fs DEBUG: Dumping run list (values in hex):");
|
||||
Dputs("NTFS-fs DEBUG: Dumping runlist (values in hex):");
|
||||
if (!rl) {
|
||||
Dputs("Run list not present.");
|
||||
return;
|
||||
|
@ -50,11 +50,11 @@ void ntfs_debug_dump_run_list(const run_list_element *rl)
|
|||
index = 4;
|
||||
Dprintf("%-16Lx %s %-16Lx%s\n", rl[i].vcn,
|
||||
lcn_str[index], rl[i].length,
|
||||
rl[i].length ? "" : " (run list end)");
|
||||
rl[i].length ? "" : " (runlist end)");
|
||||
} else
|
||||
Dprintf("%-16Lx %-16Lx %-16Lx%s\n", rl[i].vcn,
|
||||
rl[i].lcn, rl[i].length,
|
||||
rl[i].length ? "" : " (run list end)");
|
||||
rl[i].length ? "" : " (runlist end)");
|
||||
} while (rl[i++].length);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
|
|||
* is found, load the attribute list attribute value and attach it to the
|
||||
* ntfs_inode structure (->attr_list). Also set the NI_AttrList bit to indicate
|
||||
* this as well as the NI_AttrListNonResident bit if the the attribute list is
|
||||
* non-resident. In that case, also attach the decompressed run list to the
|
||||
* non-resident. In that case, also attach the decompressed runlist to the
|
||||
* ntfs_inode structure (->attr_list_rl).
|
||||
*
|
||||
* Return a pointer to the ntfs_inode structure on success or NULL on error,
|
||||
|
@ -159,7 +159,7 @@ ntfs_inode *ntfs_open_inode(ntfs_volume *vol, const MFT_REF mref)
|
|||
// FIXME: We are duplicating work here! (AIA)
|
||||
ni->attr_list_rl = ntfs_decompress_mapping_pairs(vol, ctx->attr, NULL);
|
||||
if (ni->attr_list_rl) {
|
||||
/* We got the run list, so we are done. */
|
||||
/* We got the runlist, so we are done. */
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ err_out:
|
|||
* error, @ni has not been freed. The user should attempt to handle the error
|
||||
* and call ntfs_close_inode() again. The following error codes are defined:
|
||||
*
|
||||
* EBUSY @ni is dirty and/or the attribute list run list is dirty.
|
||||
* EBUSY @ni is dirty and/or the attribute list runlist is dirty.
|
||||
*/
|
||||
int ntfs_close_inode(ntfs_inode *ni)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue