patch-2.4.0-prerelease linux/fs/fat/inode.c

Next file: linux/fs/hfs/Makefile
Previous file: linux/fs/fat/cache.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test12/linux/fs/fat/inode.c linux/fs/fat/inode.c
@@ -746,7 +746,7 @@
 static int fat_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
 {
 	return cont_prepare_write(page,from,to,fat_get_block,
-		&MSDOS_I((struct inode*)page->mapping->host)->mmu_private);
+		&MSDOS_I(page->mapping->host)->mmu_private);
 }
 static int _fat_bmap(struct address_space *mapping, long block)
 {
@@ -903,6 +903,12 @@
 	struct super_block *sb = dentry->d_sb;
 	struct inode *inode = dentry->d_inode;
 	int error;
+
+	/* FAT cannot truncate to a longer file */
+	if (attr->ia_valid & ATTR_SIZE) {
+		if (attr->ia_size > inode->i_size)
+			return -EPERM;
+	}
 
 	error = inode_change_ok(inode, attr);
 	if (error)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)