Changes by: antona
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv4205/linux/fs/ntfs
Modified Files:
Tag: pre-95
aops.c attrib.c attrib.h compress.c debug.c debug.h dir.c
inode.c inode.h mft.c ntfs.h super.c types.h volume.h
Log Message:
vacation is over. here is the results. read the changelog for details.
Index: aops.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/aops.c,v
retrieving revision 1.53
retrieving revision 1.53.4.1
diff -U2 -r1.53 -r1.53.4.1
--- aops.c 14 Feb 2002 06:07:14 -0000 1.53
+++ aops.c 4 Mar 2002 19:04:02 -0000 1.53.4.1
@@ -100,5 +100,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) {
@@ -295,5 +297,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.65
retrieving revision 1.65.4.1
diff -U2 -r1.65 -r1.65.4.1
--- attrib.c 18 Feb 2002 01:53:00 -0000 1.65
+++ attrib.c 4 Mar 2002 19:04:02 -0000 1.65.4.1
@@ -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);
@@ -120,4 +130,6 @@
* 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,8 +137,8 @@
* -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;
@@ -164,4 +176,6 @@
* 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
*
@@ -169,8 +183,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 */
@@ -244,4 +258,6 @@
* the inserted run_list, if necesary.
*
+ * It is up to the caller to serialize access to the run lists @orig and @new.
+ *
* Return: Pointer, The new, combined, run_list
*
@@ -249,8 +265,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;
@@ -292,4 +308,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
*
@@ -297,8 +315,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);
@@ -327,4 +345,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.
@@ -347,7 +367,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. */
@@ -516,4 +536,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
@@ -533,12 +555,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. */
@@ -759,5 +781,4 @@
attr_search_context *ctx;
MFT_RECORD *mrec;
- run_list *rl;
const uchar_t *name;
u32 name_len;
@@ -796,7 +817,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);
@@ -805,12 +844,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:
@@ -828,4 +861,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:
*
@@ -838,5 +873,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;
@@ -875,5 +910,4 @@
}
-
/**
* find_attr - find (next) attribute in mft record
@@ -1044,7 +1078,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.15
retrieving revision 1.15.6.1
diff -U2 -r1.15 -r1.15.6.1
--- attrib.h 10 Feb 2002 02:22:58 -0000 1.15
+++ attrib.h 4 Mar 2002 19:04:02 -0000 1.15.6.1
@@ -66,10 +66,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,
@@ -81,5 +81,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.32
retrieving revision 1.32.4.1
diff -U2 -r1.32 -r1.32.4.1
--- compress.c 14 Feb 2002 06:07:14 -0000 1.32
+++ compress.c 4 Mar 2002 19:04:02 -0000 1.32.4.1
@@ -118,4 +118,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
@@ -135,6 +138,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,
@@ -185,4 +188,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++) {
@@ -564,5 +569,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);
@@ -623,8 +630,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()];
@@ -662,5 +668,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--;
@@ -743,5 +750,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];
@@ -770,5 +779,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: debug.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/debug.c,v
retrieving revision 1.20
retrieving revision 1.20.6.1
diff -U2 -r1.20 -r1.20.6.1
--- debug.c 13 Feb 2002 03:54:13 -0000 1.20
+++ debug.c 4 Mar 2002 19:04:02 -0000 1.20.6.1
@@ -134,5 +134,5 @@
/* Dump a run list. */
-void ntfs_debug_dump_runlist(const run_list *rl)
+void ntfs_debug_dump_runlist(run_list_element *rl)
{
int i;
Index: debug.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/debug.h,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -U2 -r1.4 -r1.4.8.1
--- debug.h 3 Feb 2002 19:31:17 -0000 1.4
+++ debug.h 4 Mar 2002 19:04:02 -0000 1.4.8.1
@@ -52,5 +52,5 @@
__ntfs_debug(__FILE__, __LINE__, __FUNCTION__, f, ##a)
-extern void ntfs_debug_dump_runlist(const run_list *rl);
+extern void ntfs_debug_dump_runlist(run_list_element *rl);
#else /* !DEBUG */
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/dir.c,v
retrieving revision 1.46
retrieving revision 1.46.4.1
diff -U2 -r1.46 -r1.46.4.1
--- dir.c 14 Feb 2002 01:08:46 -0000 1.46
+++ dir.c 4 Mar 2002 19:04:02 -0000 1.46.4.1
@@ -81,5 +81,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;
@@ -188,6 +188,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;
@@ -218,5 +218,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;
@@ -224,7 +224,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,
@@ -235,8 +236,8 @@
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
dir_ni->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,
@@ -248,7 +249,7 @@
index_end = (u8*)ia + dir_ni->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);
@@ -258,6 +259,6 @@
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + dir_ni->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);
@@ -280,5 +281,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;
@@ -365,5 +366,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;
@@ -385,5 +386,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;
@@ -419,9 +420,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,
@@ -432,4 +442,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. */
@@ -441,12 +453,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->indexed_file) == FILE_root) {
ntfs_debug("Skipping root directory self reference entry.");
return 0;
}
+ if (MREF_LE(ie->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,
@@ -552,9 +578,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 +
@@ -612,5 +638,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;
@@ -661,5 +687,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;
@@ -669,8 +695,8 @@
~(s64)(ndir->index_block_size - 1)) >>
ndir->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->index_vcn_size_bits,
@@ -681,9 +707,9 @@
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
ndir->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->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->index_vcn_size_bits,
(unsigned long long)ndir->mft_no,
le32_to_cpu(ia->index.allocated_size) + 0x18,
@@ -694,7 +720,7 @@
index_end = (u8*)ia + ndir->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->index_vcn_size_bits,
@@ -706,6 +732,6 @@
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + ndir->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->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.68
retrieving revision 1.68.4.1
diff -U2 -r1.68 -r1.68.4.1
--- inode.c 14 Feb 2002 06:07:14 -0000 1.68
+++ inode.c 4 Mar 2002 19:04:02 -0000 1.68.4.1
@@ -78,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->bmp_rl = NULL;
+ INIT_RUN_LIST(&ni->attr_list_rl);
+ INIT_RUN_LIST(&ni->bmp_rl);
init_MUTEX(&ni->extent_lock);
ni->base_ntfs_ino = NULL;
@@ -376,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 "
@@ -389,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 "
@@ -447,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;
}
@@ -539,24 +546,17 @@
goto put_unm_err_out;
}
- if (!sle64_to_cpu(ctx->attr->lowest_vcn)) {
- vi->i_size = sle64_to_cpu(ctx->attr->data_size);
- ni->initialized_size = sle64_to_cpu(
- ctx->attr->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->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->data_size);
+ ni->initialized_size = sle64_to_cpu(
+ ctx->attr->initialized_size);
+ ni->allocated_size = sle64_to_cpu(ctx->attr->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);
@@ -579,24 +579,19 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_BmpNonResident;
- if (!sle64_to_cpu(ctx->attr->lowest_vcn))
- ni->bmp_size = sle64_to_cpu(
- ctx->attr->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->bmp_size = sle64_to_cpu(
- ctx->attr->highest_vcn)
- << vol->cluster_size_bits;
- /* Setup the run list. */
- ni->bmp_rl = decompress_mapping_pairs(vol, ctx->attr,
+ ni->bmp_size = sle64_to_cpu(
+ ctx->attr->data_size);
+ ni->bmp_initialized_size = sle64_to_cpu(
+ ctx->attr->initialized_size);
+ ni->bmp_allocated_size = sle64_to_cpu(
+ ctx->attr->allocated_size);
+ /*
+ * Setup the run list. No need for locking as we have
+ * exclusive access to the inode at this time.
+ */
+ ni->bmp_rl.rl = decompress_mapping_pairs(vol, ctx->attr,
NULL);
- if (IS_ERR(ni->bmp_rl)) {
- err = PTR_ERR(ni->bmp_rl);
- ni->bmp_rl = NULL;
+ if (IS_ERR(ni->bmp_rl.rl)) {
+ err = PTR_ERR(ni->bmp_rl.rl);
+ ni->bmp_rl.rl = NULL;
ntfs_error(vi->i_sb, "Mapping pairs "
"decompression failed with "
@@ -605,12 +600,14 @@
}
} else
- ni->bmp_size = le32_to_cpu(ctx->attr->value_length);
+ ni->bmp_size = ni->bmp_initialized_size =
+ ni->bmp_allocated_size =
+ le32_to_cpu(ctx->attr->value_length);
/* Consistency check bitmap size vs. index allocation size. */
- if (ni->bmp_size << 3 < ni->initialized_size >>
+ if (ni->bmp_size << 3 < vi->i_size >>
ni->index_block_size_bits) {
ntfs_error(vi->i_sb, "$I30 bitmap too small (0x%Lx) "
"for index allocation (0x%Lx).",
(long long)ni->bmp_size << 3,
- (long long)ni->initialized_size);
+ vi->i_size);
goto put_unm_err_out;
}
@@ -631,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
@@ -658,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;
@@ -707,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 "
@@ -719,25 +722,22 @@
}
}
- if (sle64_to_cpu(ctx->attr->lowest_vcn))
- /*
- * Just a rough guess as ->*_size are not
- * defined for attribute extents. We could
- * ...
[truncated message content] |