Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv25998
Modified Files:
aops.c attrib.c attrib.h compress.c dir.c inode.c mft.c ntfs.h
super.c types.h volume.h
Log Message:
merge the gcc-2.95 and Anton's changes into the trunk
Index: aops.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/aops.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -U2 -r1.54 -r1.55
--- aops.c 25 Feb 2002 04:00:58 -0000 1.54
+++ aops.c 4 Mar 2002 22:56:14 -0000 1.55
@@ -101,5 +101,7 @@
/* Convert the vcn to the corresponding logical cluster number (lcn). */
- lcn = vcn_to_lcn(ni->run_list, vcn);
+ read_lock(&ni->run_list.lock);
+ lcn = vcn_to_lcn(ni->run_list.rl, vcn);
+ read_unlock(&ni->run_list.lock);
/* Successful remap. */
if (lcn >= 0) {
@@ -296,5 +298,7 @@
return 0;
}
- lcn = vcn_to_lcn(vol->mftbmp_rl, vcn);
+ read_lock(&vol->mftbmp_rl.lock);
+ lcn = vcn_to_lcn(vol->mftbmp_rl.rl, vcn);
+ read_unlock(&vol->mftbmp_rl.lock);
ntfs_debug("lcn = 0x%Lx.", (long long)lcn);
if (lcn < 0LL) {
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/attrib.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -U2 -r1.67 -r1.68
--- attrib.c 25 Feb 2002 04:30:08 -0000 1.67
+++ attrib.c 4 Mar 2002 22:56:14 -0000 1.68
@@ -27,6 +27,8 @@
/**
* rl_mm - run_list memmove
+ *
+ * It is up to the caller to serialize access to the run list @base.
*/
-static inline void rl_mm (run_list *base, int dst, int src, int size)
+static inline void rl_mm(run_list_element *base, int dst, int src, int size)
{
if ((dst != src) && (size > 0))
@@ -36,7 +38,10 @@
/**
* rl_mc - run_list memory copy
+ *
+ * It is up to the caller to serialize access to the run lists @dstbase and
+ * @srcbase.
*/
-static inline void rl_mc (run_list *dstbase, int dst, run_list *srcbase,
- int src, int size)
+static inline void rl_mc(run_list_element *dstbase, int dst,
+ run_list_element *srcbase, int src, int size)
{
if (size > 0)
@@ -54,4 +59,6 @@
* memory, this function returns and entire page of memory.
*
+ * It is up to the caller to serialize access to the run list @orig.
+ *
* N.B. If the new allocation doesn't require a different number of pages in
* memory, the function will return the original pointer.
@@ -62,7 +69,8 @@
* -EINVAL, Invalid parameters were passed in.
*/
-static inline run_list * ntfs_rl_realloc (run_list *orig, int old, int new)
+static inline run_list_element *ntfs_rl_realloc(run_list_element *orig,
+ int old, int new)
{
- run_list *nrl;
+ run_list_element *nrl;
old = PAGE_ALIGN (old * sizeof (run_list));
@@ -90,8 +98,10 @@
* must be adjacent.
*
+ * It is up to the caller to serialize access to the run lists @one and @two.
+ *
* Return: TRUE Success, the run_lists were merged
* FALSE Failure, the run_lists were not merged
*/
-static inline BOOL ntfs_rl_merge (run_list *one, run_list *two)
+static inline BOOL ntfs_rl_merge(run_list_element *one, run_list_element *two)
{
BUG_ON (!one || !two);
@@ -117,7 +127,9 @@
*
* Append a run_list after element @loc in @orig. Merge the right end of
- * the new run_list, if necesary. Adjust the size of the hole before the
+ * the new run_list, if necessary. Adjust the size of the hole before the
* appended run_list.
*
+ * It is up to the caller to serialize access to the run lists @orig and @new.
+ *
* Return: Pointer, The new, combined, run_list
*
@@ -125,13 +137,13 @@
* -EINVAL, Invalid parameters were passed in.
*/
-static inline run_list * ntfs_rl_append (run_list *orig, int osize,
- run_list *new, int nsize, int loc)
+static inline run_list_element *ntfs_rl_append(run_list_element *orig,
+ int osize, run_list_element *new, int nsize, int loc)
{
- run_list *res;
+ run_list_element *res;
BOOL right;
BUG_ON (!orig || !new);
- /* First, merge the right hand end, if necesary. */
+ /* First, merge the right hand end, if necessary. */
right = ntfs_rl_merge (new + nsize - 1, orig + loc + 1);
@@ -164,7 +176,9 @@
*
* Insert a run_list before element @loc in @orig. Merge the left end of
- * the new run_list, if necesary. Adjust the size of the hole after the
+ * the new run_list, if necessary. Adjust the size of the hole after the
* inserted run_list.
*
+ * It is up to the caller to serialize access to the run lists @orig and @new.
+ *
* Return: Pointer, The new, combined, run_list
*
@@ -172,8 +186,8 @@
* -EINVAL, Invalid parameters were passed in.
*/
-static inline run_list * ntfs_rl_insert (run_list *orig, int osize,
- run_list *new, int nsize, int loc)
+static inline run_list_element *ntfs_rl_insert(run_list_element *orig,
+ int osize, run_list_element *new, int nsize, int loc)
{
- run_list *res;
+ run_list_element *res;
BOOL left = FALSE;
BOOL disc = FALSE; /* Discontinuity */
@@ -253,5 +267,7 @@
*
* Replace the run_list at @loc with @new. Merge the left and right ends of
- * the inserted run_list, if necesary.
+ * the inserted run_list, if necessary.
+ *
+ * It is up to the caller to serialize access to the run lists @orig and @new.
*
* Return: Pointer, The new, combined, run_list
@@ -260,8 +276,8 @@
* -EINVAL, Invalid parameters were passed in.
*/
-static inline run_list * ntfs_rl_replace (run_list *orig, int osize,
- run_list *new, int nsize, int loc)
+static inline run_list_element *ntfs_rl_replace(run_list_element *orig,
+ int osize, run_list_element *new, int nsize, int loc)
{
- run_list *res;
+ run_list_element *res;
BOOL left = FALSE;
BOOL right;
@@ -303,4 +319,6 @@
* run_lists is necessary. Adjust the size of the holes either side.
*
+ * It is up to the caller to serialize access to the run lists @orig and @new.
+ *
* Return: Pointer, The new, combined, run_list
*
@@ -308,8 +326,8 @@
* -EINVAL, Invalid parameters were passed in.
*/
-static inline run_list * ntfs_rl_split (run_list *orig, int osize,
- run_list *new, int nsize, int loc)
+static inline run_list_element *ntfs_rl_split(run_list_element *orig, int osize,
+ run_list_element *new, int nsize, int loc)
{
- run_list *res;
+ run_list_element *res;
BUG_ON (!orig || !new);
@@ -341,4 +359,6 @@
* or completely within a hole in @drl.
*
+ * It is up to the caller to serialize access to the run lists @drl and @srl.
+ *
* Merging of run lists is necessary in two cases:
* 1. When attribute lists are used and a further extent is being mapped.
@@ -361,7 +381,7 @@
* -ERANGE, The run_lists overlap and cannot be merged.
*/
-run_list * merge_run_lists (run_list *drl, run_list *srl)
+run_list_element *merge_run_lists(run_list_element *drl, run_list_element *srl)
{
- run_list *nrl; /* New run list. */
+ run_list_element *nrl; /* New run list. */
int di, si; /* Current index into @[ds]rl. */
int sstart; /* First index with lcn > LCN_RL_NOT_MAPPED. */
@@ -530,4 +550,6 @@
* longer valid.
*
+ * It is up to the caller to serialize access to the run list @old_rl.
+ *
* Check the return value for error with IS_ERR(ret_val). If this is FALSE,
* the function was successful, the return value is the new run list, and if
@@ -547,12 +569,12 @@
* run list if overlap present and return error).
*/
-run_list *decompress_mapping_pairs(const ntfs_volume *vol,
- const ATTR_RECORD *attr, run_list *old_rl)
+run_list_element *decompress_mapping_pairs(const ntfs_volume *vol,
+ const ATTR_RECORD *attr, run_list_element *old_rl)
{
VCN vcn; /* Current vcn. */
LCN lcn; /* Current lcn. */
s64 deltaxcn; /* Change in [vl]cn. */
- run_list *rl = NULL; /* The output run_list. */
- run_list *rl2; /* Temporary run_list. */
+ run_list_element *rl = NULL; /* The output run_list. */
+ run_list_element *rl2; /* Temporary run_list. */
u8 *buf; /* Current position in mapping pairs array. */
u8 *attr_end; /* End of attribute. */
@@ -773,5 +795,4 @@
attr_search_context *ctx;
MFT_RECORD *mrec;
- run_list *rl;
const uchar_t *name;
u32 name_len;
@@ -810,7 +831,25 @@
}
- /* Decode the run list. */
- rl = decompress_mapping_pairs(ni->vol, ctx->attr, ni->run_list);
+ /* Lock the run list. */
+ write_lock(&ni->run_list.lock);
+ /* Make sure someone else didn't do the work while we were spinning. */
+ if (likely(vcn_to_lcn(ni->run_list.rl, vcn) <= LCN_RL_NOT_MAPPED)) {
+ run_list_element *rl;
+
+ /* Decode the run list. */
+ rl = decompress_mapping_pairs(ni->vol, ctx->attr,
+ ni->run_list.rl);
+
+ /* Flag any errors or set the run list if successful. */
+ if (unlikely(IS_ERR(rl)))
+ err = PTR_ERR(rl);
+ else
+ ni->run_list.rl = rl;
+ }
+
+ /* Unlock the run list. */
+ write_unlock(&ni->run_list.lock);
+
put_attr_search_ctx(ctx);
@@ -819,12 +858,6 @@
/* If an error occured, return it. */
- if (IS_ERR(rl))
- return PTR_ERR(rl);
-
- /* Everything ok, set the run list. */
- ni->run_list = rl;
-
ntfs_debug("Done.");
- return 0;
+ return err;
unm_err_out:
@@ -842,4 +875,6 @@
* corresponding lcns.
*
+ * It is up to the caller to serialize access to the run list @rl.
+ *
* Since lcns must be >= 0, we use negative return values with special meaning:
*
@@ -852,5 +887,5 @@
* -4 = LCN_EINVAL Input parameter error (if debug enabled).
*/
-LCN vcn_to_lcn(const run_list *rl, const VCN vcn)
+LCN vcn_to_lcn(const run_list_element *rl, const VCN vcn)
{
int i;
@@ -1058,7 +1093,10 @@
* Note, @size does not need to be a multiple of the cluster size.
*
+ * It is up to the caller to serialize access to the run list @rl.
+ *
* Return 0 on success or -errno on error.
*/
-int load_attribute_list(ntfs_volume *vol, run_list *rl, u8 *al, const s64 size)
+int load_attribute_list(ntfs_volume *vol, run_list_element *rl, u8 *al,
+ const s64 size)
{
LCN lcn;
Index: attrib.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/attrib.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -U2 -r1.16 -r1.17
--- attrib.h 25 Feb 2002 04:00:58 -0000 1.16
+++ attrib.h 4 Mar 2002 22:56:14 -0000 1.17
@@ -67,10 +67,10 @@
} attr_search_context;
-extern run_list *decompress_mapping_pairs(const ntfs_volume *vol,
- const ATTR_RECORD *attr, run_list *run_list);
+extern run_list_element *decompress_mapping_pairs(const ntfs_volume *vol,
+ const ATTR_RECORD *attr, run_list_element *old_rl);
extern int map_run_list(ntfs_inode *ni, VCN vcn);
-extern LCN vcn_to_lcn(const run_list *rl, const VCN vcn);
+extern LCN vcn_to_lcn(const run_list_element *rl, const VCN vcn);
extern BOOL find_attr(const ATTR_TYPES type, const uchar_t *name,
@@ -82,5 +82,5 @@
const u32 val_len, attr_search_context *ctx);
-extern int load_attribute_list(ntfs_volume *vol, run_list *rl, u8 *al,
+extern int load_attribute_list(ntfs_volume *vol, run_list_element *rl, u8 *al,
const s64 size);
Index: compress.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/compress.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -U2 -r1.33 -r1.34
--- compress.c 25 Feb 2002 04:00:58 -0000 1.33
+++ compress.c 4 Mar 2002 22:56:14 -0000 1.34
@@ -119,4 +119,7 @@
* @cb_size: size of compression block @cb_start in bytes (IN)
*
+ * The caller must have disabled preemption. ntfs_decompress() reenables it when
+ * the critical section is finished.
+ *
* This decompresses the compression block @cb_start into the array of
* destination pages @dest_pages starting at index @dest_index into @dest_pages
@@ -136,6 +139,6 @@
* unpredicatbly! You have been warned!
*
- * Note: This function may not sleep until it has finished accessing the
- * compression block @cb_start.
+ * Note to hackers: This function may not sleep until it has finished accessing
+ * the compression block @cb_start as it is a per-CPU buffer.
*/
static int ntfs_decompress(struct page *dest_pages[], int *dest_index,
@@ -186,4 +189,6 @@
err = 0;
return_error:
+ /* We can sleep from now on, so we reenable preemption. */
+ preempt_enable();
/* Second stage: finalize completed pages. */
for (i = 0; i < nr_completed_pages; i++) {
@@ -565,5 +570,7 @@
}
/* Find lcn of vcn and convert it into blocks. */
- lcn = vcn_to_lcn(ni->run_list, vcn);
+ read_lock(&ni->run_list.lock);
+ lcn = vcn_to_lcn(ni->run_list.rl, vcn);
+ read_unlock(&ni->run_list.lock);
ntfs_debug("Reading vcn = 0x%Lx, lcn = 0x%Lx.",
(long long)vcn, (long long)lcn);
@@ -624,8 +631,7 @@
* Get the compression buffer corresponding to the current CPU. We must
* not sleep any more until we are finished with the compression buffer.
- * If on a preemptible kernel, disable preemption.
+ * If on a preemptible kernel, now disable preemption.
*/
- // preempt_disable();
- // don't forget preempt_enable(); later!
+ preempt_disable();
cb = ntfs_compression_buffers[smp_processor_id()];
@@ -663,5 +669,6 @@
/* Sparse cb, zero out page range overlapping the cb. */
ntfs_debug("Found sparse compression block.");
- /* We can sleep from now on. */
+ /* We can sleep from now on, so we reenable preemption. */
+ preempt_enable();
if (cb_max_ofs)
cb_max_page--;
@@ -744,5 +751,7 @@
cur_ofs = cb_max_ofs;
}
- /* We can sleep from now on. Second stage: finalize pages. */
+ /* We can sleep from now on, so we reenable preemption. */
+ preempt_enable();
+ /* Second stage: finalize pages. */
for (; cur2_page < cb_max_page; cur2_page++) {
page = pages[cur2_page];
@@ -771,5 +780,8 @@
cb_max_page, cb_max_ofs, xpage, &xpage_done,
cb_pos, cb_size - (cb_pos - cb));
- /* We can sleep from now on. */
+ /*
+ * We can sleep from now on, preemption already reenabled by
+ * ntfs_decompess.
+ */
if (err) {
ntfs_error(vol->sb, "ntfs_decompress() failed with "
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/dir.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -U2 -r1.47 -r1.48
--- dir.c 25 Feb 2002 04:00:58 -0000 1.47
+++ dir.c 4 Mar 2002 22:56:14 -0000 1.48
@@ -82,5 +82,5 @@
ctx)) {
ntfs_error(sb, "Index root attribute missing in directory "
- "inode %Li.",
+ "inode 0x%Lx.",
(unsigned long long)dir_ni->mft_no);
err = -EIO;
@@ -189,6 +189,6 @@
if (!NInoIndexAllocPresent(dir_ni)) {
ntfs_error(sb, "No index allocation attribute but index entry "
- "requires one. Directory inode %Li is corrupt "
- "or driver bug.",
+ "requires one. Directory inode 0x%Lx is "
+ "corrupt or driver bug.",
(unsigned long long)dir_ni->mft_no);
err = -EIO;
@@ -219,5 +219,5 @@
if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
- "inode %Li or driver bug.",
+ "inode 0x%Lx or driver bug.",
(unsigned long long)dir_ni->mft_no);
err = -EIO;
@@ -225,7 +225,8 @@
}
if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
- ntfs_error(sb, "Actual VCN (%Li) of index buffer is different "
- "from expected VCN (%Li). Directory inode %Li "
- "is corrupt or driver bug.",
+ ntfs_error(sb, "Actual VCN (0x%Lx) of index buffer is "
+ "different from expected VCN (0x%Lx). "
+ "Directory inode 0x%Lx is corrupt or driver "
+ "bug.",
(long long)sle64_to_cpu(ia->index_block_vcn),
(long long)vcn,
@@ -236,8 +237,8 @@
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
dir_ni->_IDM(index_block_size)) {
- ntfs_error(sb, "Index buffer (VCN %Li) of directory inode %Li "
- "has a size (%u) differing from the directory "
- "specified size (%u). Directory inode is "
- "corrupt or driver bug.",
+ ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
+ "0x%Lx has a size (%u) differing from the "
+ "directory specified size (%u). Directory "
+ "inode is corrupt or driver bug.",
(long long)vcn,
(unsigned long long)dir_ni->mft_no,
@@ -249,7 +250,7 @@
index_end = (u8*)ia + dir_ni->_IDM(index_block_size);
if (index_end > kaddr + PAGE_CACHE_SIZE) {
- ntfs_error(sb, "Index buffer (VCN %Li) of directory inode %Li "
- "crosses page boundary. Impossible! Cannot "
- "access! This is probably a bug in the "
+ ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
+ "0x%Lx crosses page boundary. Impossible! "
+ "Cannot access! This is probably a bug in the "
"driver.", (long long)vcn,
(unsigned long long)dir_ni->mft_no);
@@ -259,6 +260,6 @@
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + dir_ni->_IDM(index_block_size)) {
- ntfs_error(sb, "Size of index buffer (VCN %Li) of directory "
- "inode %Li exceeds maximum size.",
+ ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory "
+ "inode 0x%Lx exceeds maximum size.",
(long long)vcn,
(unsigned long long)dir_ni->mft_no);
@@ -281,5 +282,5 @@
index_end) {
ntfs_error(sb, "Index entry out of bounds in "
- "directory inode %Li.",
+ "directory inode 0x%Lx.",
(unsigned long long)dir_ni->mft_no);
err = -EIO;
@@ -366,5 +367,5 @@
if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
ntfs_error(sb, "Index entry with child node found in "
- "a leaf node in directory inode %Li.",
+ "a leaf node in directory inode 0x%Lx.",
(unsigned long long)dir_ni->mft_no);
err = -EIO;
@@ -386,5 +387,5 @@
}
ntfs_error(sb, "Negative child node vcn in directory inode "
- "%Li.", (unsigned long long)dir_ni->mft_no);
+ "0x%Lx.", (unsigned long long)dir_ni->mft_no);
err = -EIO;
goto unm_unm_err_out;
@@ -420,9 +421,18 @@
} INDEX_TYPE;
-/*
+/**
+ * ntfs_filldir - ntfs specific filldir method
+ * @vol: current ntfs volume
+ * @filp: open file descriptor for the current directory
+ * @ndir: ntfs inode of current directory
+ * @index_type: specifies whether @iu is an index root or an index allocation
+ * @iu: index root or index allocation attribute to which @ie belongs
+ * @ie: current index entry
+ * @name: buffer to use for the converted name
+ * @dirent: vfs filldir callback context
+ * filldir: vfs filldir callback
+ *
* Convert the Unicode name to the loaded NLS and pass it to
* the filldir callback.
- *
- * If @is_ia is TRUE, iu is an INDEX_ALLOCATION. Otherwise it is an INDEX_ROOT.
*/
static inline int ntfs_filldir(ntfs_volume *vol, struct file *filp,
@@ -433,4 +443,6 @@
int name_len;
unsigned dt_type;
+ FILE_NAME_TYPE_FLAGS name_type;
+ READDIR_OPTIONS readdir_opts;
/* Advance the position even if going to skip the entry. */
@@ -442,12 +454,26 @@
else /* if (index_type == INDEX_TYPE_ROOT) */
filp->f_pos = (u8*)ie - (u8*)iu.ir;
- if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
- ntfs_debug("Skipping DOS only name space entry.");
+ readdir_opts = vol->readdir_opts;
+ name_type = ie->key.file_name.file_name_type;
+ if (name_type == FILE_NAME_DOS && RHideDosNames(readdir_opts)) {
+ ntfs_debug("Skipping DOS name space entry.");
return 0;
}
+ if (RHideLongNames(readdir_opts)) {
+ if (name_type == FILE_NAME_WIN32 ||
+ name_type == FILE_NAME_POSIX) {
+ ntfs_debug("Skipping WIN32/POSIX name space entry.");
+ return 0;
+ }
+ }
if (MREF_LE(ie->_IIF(indexed_file)) == FILE_root) {
ntfs_debug("Skipping root directory self reference entry.");
return 0;
}
+ if (MREF_LE(ie->_IIF(indexed_file)) < FILE_first_user &&
+ RHideSystemFiles(readdir_opts)) {
+ ntfs_debug("Skipping system file.");
+ return 0;
+ }
name_len = ntfs_ucstonls(vol, (uchar_t*)&ie->key.file_name.file_name,
ie->key.file_name.file_name_length, &name,
@@ -553,9 +579,9 @@
ctx)) {
ntfs_error(sb, "Index root attribute missing in directory "
- "inode %Li.", (unsigned long long)ndir->mft_no);
+ "inode 0x%Lx.",
+ (unsigned long long)ndir->mft_no);
err = -EIO;
goto kf_unm_err_out;
}
- /* FIXME: Clean up search context. */
/* Get to the index root value (it's been verified in read_inode). */
ir = (INDEX_ROOT*)((u8*)ctx->attr +
@@ -613,5 +639,5 @@
ctx)) {
ntfs_error(sb, "Index bitmap attribute missing in "
- "directory inode %Li.",
+ "directory inode 0x%Lx.",
(unsigned long long)ndir->mft_no);
err = -EIO;
@@ -662,5 +688,5 @@
if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
- "inode %Li or driver bug.",
+ "inode 0x%Lx or driver bug.",
(unsigned long long)ndir->mft_no);
err = -EIO;
@@ -670,8 +696,8 @@
~(s64)(ndir->_IDM(index_block_size) - 1)) >>
ndir->_IDM(index_vcn_size_bits)) {
- ntfs_error(sb, "Actual VCN (%Li) of index buffer is "
- "different from expected VCN (%Li). "
- "Directory inode %Li is corrupt or "
- "driver bug. ",
+ ntfs_error(sb, "Actual VCN (0x%Lx) of index buffer is "
+ "different from expected VCN (0x%Lx). "
+ "Directory inode 0x%Lx is corrupt or driver "
+ "bug. ",
(long long)sle64_to_cpu(ia->index_block_vcn),
(long long)ia_pos >> ndir->_IDM(index_vcn_size_bits),
@@ -682,9 +708,9 @@
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
ndir->_IDM(index_block_size)) {
- ntfs_error(sb, "Index buffer (VCN %Li) of directory inode %Li "
- "has a size (%u) differing from the directory "
- "specified size (%u). Directory inode is "
- "corrupt or driver bug.", (long long)ia_pos >>
- ndir->_IDM(index_vcn_size_bits),
+ ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
+ "0x%Lx has a size (%u) differing from the "
+ "directory specified size (%u). Directory "
+ "inode is corrupt or driver bug.",
+ (long long)ia_pos >> ndir->_IDM(index_vcn_size_bits),
(unsigned long long)ndir->mft_no,
le32_to_cpu(ia->index.allocated_size) + 0x18,
@@ -695,7 +721,7 @@
index_end = (u8*)ia + ndir->_IDM(index_block_size);
if (index_end > kaddr + PAGE_CACHE_SIZE) {
- ntfs_error(sb, "Index buffer (VCN %Li) of directory inode %Li "
- "crosses page boundary. Impossible! Cannot "
- "access! This is probably a bug in the "
+ ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode "
+ "0x%Lx crosses page boundary. Impossible! "
+ "Cannot access! This is probably a bug in the "
"driver.", (long long)ia_pos >>
ndir->_IDM(index_vcn_size_bits),
@@ -707,6 +733,6 @@
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + ndir->_IDM(index_block_size)) {
- ntfs_error(sb, "Size of index buffer (VCN %Li) of directory "
- "inode %Li exceeds maximum size.",
+ ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory "
+ "inode 0x%Lx exceeds maximum size.",
(long long)ia_pos >> ndir->_IDM(index_vcn_size_bits),
(unsigned long long)ndir->mft_no);
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -U2 -r1.69 -r1.70
--- inode.c 25 Feb 2002 04:00:58 -0000 1.69
+++ inode.c 4 Mar 2002 22:56:14 -0000 1.70
@@ -3,5 +3,4 @@
*
* Copyright (c) 2001,2002 Anton Altaparmakov.
- * Copyright (C) 2002 Richard Russon.
*
* This program/include file is free software; you can redistribute it and/or
@@ -79,11 +78,11 @@
atomic_set(&ni->count, 1);
ni->vol = NULL;
- ni->run_list = NULL;
+ INIT_RUN_LIST(&ni->run_list);
init_rwsem(&ni->mrec_lock);
atomic_set(&ni->mft_count, 0);
ni->page = NULL;
ni->attr_list = NULL;
- ni->attr_list_rl = NULL;
- ni->_IDM(bmp_rl) = NULL;
+ INIT_RUN_LIST(&ni->attr_list_rl);
+ INIT_RUN_LIST(&ni->_IDM(bmp_rl));
init_MUTEX(&ni->extent_lock);
ni->_INE(base_ntfs_ino) = NULL;
@@ -377,10 +376,13 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_AttrListNonResident;
- /* Setup the run list. */
- ni->attr_list_rl = decompress_mapping_pairs(vol,
+ /*
+ * Setup the run list. No need for locking as we have
+ * exclusive access to the inode at this time.
+ */
+ ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
ctx->attr, NULL);
- if (IS_ERR(ni->attr_list_rl)) {
- err = PTR_ERR(ni->attr_list_rl);
- ni->attr_list_rl = NULL;
+ if (IS_ERR(ni->attr_list_rl.rl)) {
+ err = PTR_ERR(ni->attr_list_rl.rl);
+ ni->attr_list_rl.rl = NULL;
ntfs_error(vi->i_sb, "Mapping pairs "
"decompression failed with "
@@ -390,6 +392,9 @@
goto ec_put_unm_err_out;
}
- /* Now load the attribute list. */
- if ((err = load_attribute_list(vol, ni->attr_list_rl,
+ /*
+ * Now load the attribute list. Again no need for
+ * locking as above.
+ */
+ if ((err = load_attribute_list(vol, ni->attr_list_rl.rl,
ni->attr_list, ni->attr_list_size))) {
ntfs_error(vi->i_sb, "Failed to load "
@@ -448,5 +453,6 @@
if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
ntfs_error(vi->i_sb, "Found encrypted and "
- "compressed data.");
+ "compressed attribute. Not "
+ "allowed.");
goto put_unm_err_out;
}
@@ -540,24 +546,17 @@
goto put_unm_err_out;
}
- if (!sle64_to_cpu(ctx->attr->_ANR(lowest_vcn))) {
- vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
- ni->initialized_size = sle64_to_cpu(
- ctx->attr->_ANR(initialized_size));
- } else
- /*
- * Just a rough guess as ->*_size are not defined for
- * attribute extents. We could just find the base
- * attribute extent but this way is faster and not too
- * much off unless the directory is ridiculously big or
- * very fragmented or sparse.
- */
- vi->i_size = ni->initialized_size =
- sle64_to_cpu(ctx->attr->_ANR(highest_vcn))
- << vol->cluster_size_bits;
- /* Setup the run list. */
- ni->run_list = decompress_mapping_pairs(vol, ctx->attr, NULL);
- if (IS_ERR(ni->run_list)) {
- err = PTR_ERR(ni->run_list);
- ni->run_list = NULL;
+ vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
+ ni->initialized_size = sle64_to_cpu(
+ ctx->attr->_ANR(initialized_size));
+ ni->allocated_size = sle64_to_cpu(ctx->attr->_ANR(allocated_size));
+ /*
+ * Setup the run list. No need for locking as we have exclusive
+ * access to the inode at this time.
+ */
+ ni->run_list.rl = decompress_mapping_pairs(vol, ctx->attr,
+ NULL);
+ if (IS_ERR(ni->run_list.rl)) {
+ err = PTR_ERR(ni->run_list.rl);
+ ni->run_list.rl = NULL;
ntfs_error(vi->i_sb, "Mapping pairs decompression "
"failed with error code %i.", -err);
@@ -580,24 +579,19 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_BmpNonResident;
- if (!sle64_to_cpu(ctx->attr->_ANR(lowest_vcn)))
- ni->_IDM(bmp_size) = sle64_to_cpu(
- ctx->attr->_ANR(data_size));
- else
- /*
- * Just a rough guess as ->*_size are not
- * defined for extents. We could just find the
- * base extent but this way is faster and not
- * too much off unless the directory is
- * ridiculously big / very fragmented or sparse.
- */
- ni->_IDM(bmp_size) = sle64_to_cpu(
- ctx->attr->_ANR(highest_vcn))
- << vol->cluster_size_bits;
- /* Setup the run list. */
- ni->_IDM(bmp_rl) = decompress_mapping_pairs(vol, ctx->attr,
+ ni->_IDM(bmp_size) = sle64_to_cpu(
+ ctx->attr->_ANR(data_size));
+ ni->_IDM(bmp_initialized_size) = sle64_to_cpu(
+ ctx->attr->_ANR(initialized_size));
+ ni->_IDM(bmp_allocated_size) = sle64_to_cpu(
+ ctx->attr->_ANR(allocated_size));
+ /*
+ * Setup the run list. No need for locking as we have
+ * exclusive access to the inode at this time.
+ */
+ ni->_IDM(bmp_rl).rl = decompress_mapping_pairs(vol, ctx->attr,
NULL);
- if (IS_ERR(ni->_IDM(bmp_rl))) {
- err = PTR_ERR(ni->_IDM(bmp_rl));
- ni->_IDM(bmp_rl) = NULL;
+ if (IS_ERR(ni->_IDM(bmp_rl).rl)) {
+ err = PTR_ERR(ni->_IDM(bmp_rl).rl);
+ ni->_IDM(bmp_rl).rl = NULL;
ntfs_error(vi->i_sb, "Mapping pairs "
"decompression failed with "
@@ -606,12 +600,14 @@
}
} else
- ni->_IDM(bmp_size) = le32_to_cpu(ctx->attr->_ARA(value_length));
+ ni->_IDM(bmp_size) = ni->_IDM(bmp_initialized_size) =
+ ni->_IDM(bmp_allocated_size) =
+ le32_to_cpu(ctx->attr->_ARA(value_length));
/* Consistency check bitmap size vs. index allocation size. */
- if (ni->_IDM(bmp_size) << 3 < ni->initialized_size >>
+ if (ni->_IDM(bmp_size) << 3 < vi->i_size >>
ni->_IDM(index_block_size_bits)) {
ntfs_error(vi->i_sb, "$I30 bitmap too small (0x%Lx) "
"for index allocation (0x%Lx).",
(long long)ni->_IDM(bmp_size) << 3,
- (long long)ni->initialized_size);
+ vi->i_size);
goto put_unm_err_out;
}
@@ -632,8 +628,9 @@
vi->i_mapping->a_ops = &ntfs_dir_aops;
} else {
- /* It is a file, find the unnamed data attribute. */
+ /* It is a file: find first extent of unnamed data attribute. */
reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_DATA, NULL, 0, 0, 0, NULL, 0, ctx)) {
- vi->i_size = ni->initialized_size = 0LL;
+ vi->i_size = ni->initialized_size =
+ ni->allocated_size = 0LL;
/*
* FILE_Secure does not have an unnamed $DATA
@@ -659,5 +656,5 @@
goto put_unm_err_out;
}
- /* Set up the state. */
+ /* Setup the state. */
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_NonResident;
@@ -708,9 +705,14 @@
/* $MFT is special as we have the run_list already. */
if (likely(vi->i_ino != FILE_MFT)) {
- ni->run_list = decompress_mapping_pairs(vol,
+ /*
+ * Setup the run list. No need for locking as
+ * we have exclusive access to the inode at
+ * this time.
+ */
+ ni->run_list.rl = decompress_mapping_pairs(vol,
ctx->attr, NULL);
- if (IS_ERR(ni->run_list)) {
- err = PTR_ERR(ni->run_list);
- ni->run_list = NULL;
+ if (IS_ERR(ni->run_list.rl)) {
+ err = PTR_ERR(ni->run_list.rl);
+ ni->run_list.rl = NULL;
ntfs_error(vi->i_sb, "Mapping pairs "
"decompression failed "
@@ -720,25 +722,22 @@
}
}
- if (sle64_to_cpu(ctx->attr->_ANR(lowest_vcn)))
- /*
- * Just a rough guess as ->*_size are not
- * ...
[truncated message content] |