summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-02-08 04:20:51 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 09:22:36 -0800
commit05343c4f2ee1a4f81f287d95b28c80ee565817c4 (patch)
tree09077c4f6d970e5af6c9da36910fd4fc056fa33f
parentaf793295bf9ee92660f5e77d337b0493cea3f9b9 (diff)
downloadlinux-05343c4f2ee1a4f81f287d95b28c80ee565817c4.tar.bz2
udf: fix adding entry to a directory
When adding directory entry to a directory, we have to properly increase length of the last extent. Handle this similarly as extending regular files - make extents always have size multiple of block size (it will be truncated down to proper size in udf_clear_inode()). Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/udf/inode.c2
-rw-r--r--fs/udf/namei.c19
2 files changed, 11 insertions, 10 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index f792681f2f73..24cfa55d0fdc 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -289,7 +289,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
eloc.logicalBlockNum = *block;
eloc.partitionReferenceNum =
iinfo->i_location.partitionReferenceNum;
- elen = inode->i_size;
+ elen = inode->i_sb->s_blocksize;
iinfo->i_lenExtents = elen;
epos.bh = NULL;
epos.block = iinfo->i_location;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index dacd8f4cea8a..112a5fb0b27b 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -395,7 +395,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
}
block = dinfo->i_location.logicalBlockNum;
-
} else {
block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0);
fibh->sbh = fibh->ebh = NULL;
@@ -474,6 +473,14 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
}
add:
+ if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
+ elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
+ if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
+ epos.offset -= sizeof(short_ad);
+ else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
+ epos.offset -= sizeof(long_ad);
+ udf_write_aext(dir, &epos, eloc, elen, 1);
+ }
f_pos += nfidlen;
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
@@ -491,15 +498,9 @@ add:
if (!fibh->sbh)
return NULL;
epos.block = dinfo->i_location;
- eloc.logicalBlockNum = block;
- eloc.partitionReferenceNum =
- dinfo->i_location.partitionReferenceNum;
- elen = dir->i_sb->s_blocksize;
epos.offset = udf_file_entry_alloc_offset(dir);
- if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
- epos.offset += sizeof(short_ad);
- else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
- epos.offset += sizeof(long_ad);
+ /* Load extent udf_expand_dir_adinicb() has created */
+ udf_current_aext(dir, &epos, &eloc, &elen, 1);
}
if (sb->s_blocksize - fibh->eoffset >= nfidlen) {