patch-2.4.19 linux-2.4.19/fs/udf/file.c

Next file: linux-2.4.19/fs/udf/fsync.c
Previous file: linux-2.4.19/fs/udf/ecma_167.h
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/fs/udf/file.c linux-2.4.19/fs/udf/file.c
@@ -16,7 +16,7 @@
  *  Each contributing author retains all rights to their own work.
  *
  *  (C) 1998-1999 Dave Boynton
- *  (C) 1998-2000 Ben Fennema
+ *  (C) 1998-2001 Ben Fennema
  *  (C) 1999-2000 Stelias Computing Inc
  *
  * HISTORY
@@ -25,7 +25,7 @@
  *  10/07/98      Switched to using generic_readpage, etc., like isofs
  *                And it works!
  *  12/06/98 blf  Added udf_file_read. uses generic_file_read for all cases but
- *                ICB_FLAG_AD_IN_ICB.
+ *                ICBTAG_FLAG_AD_IN_ICB.
  *  04/06/99      64 bit file handling on 32 bit systems taken from ext2 file.c
  *  05/12/99      Preliminary file write support
  */
@@ -50,6 +50,7 @@
 	struct buffer_head *bh;
 	int block;
 	char *kaddr;
+	int err = 0;
 
 	if (!PageLocked(page))
 		PAGE_BUG(page);
@@ -58,13 +59,20 @@
 	memset(kaddr, 0, PAGE_CACHE_SIZE);
 	block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
 	bh = sb_bread(inode->i_sb, block);
+	if (!bh)
+	{
+		SetPageError(page);
+		err = -EIO;
+		goto out;
+	}
 	memcpy(kaddr, bh->b_data + udf_ext0_offset(inode), inode->i_size);
 	brelse(bh);
 	flush_dcache_page(page);
 	SetPageUptodate(page);
+out:
 	kunmap(page);
 	UnlockPage(page);
-	return 0;
+	return err;
 }
 
 static int udf_adinicb_writepage(struct page *page)
@@ -74,6 +82,7 @@
 	struct buffer_head *bh;
 	int block;
 	char *kaddr;
+	int err = 0;
 
 	if (!PageLocked(page))
 		PAGE_BUG(page);
@@ -81,13 +90,20 @@
 	kaddr = kmap(page);
 	block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
 	bh = sb_bread(inode->i_sb, block);
+	if (!bh)
+	{
+		SetPageError(page);
+		err = -EIO;
+		goto out;
+	}
 	memcpy(bh->b_data + udf_ext0_offset(inode), kaddr, inode->i_size);
 	mark_buffer_dirty(bh);
 	brelse(bh);
 	SetPageUptodate(page);
+out:
 	kunmap(page);
 	UnlockPage(page);
-	return 0;
+	return err;
 }
 
 static int udf_adinicb_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
@@ -103,19 +119,27 @@
 	struct buffer_head *bh;
 	int block;
 	char *kaddr = page_address(page);
+	int err = 0;
 
 	block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
 	bh = sb_bread(inode->i_sb, block);
+	if (!bh)
+	{
+		SetPageError(page);
+		err = -EIO;
+		goto out;
+	}
 	memcpy(bh->b_data + udf_file_entry_alloc_offset(inode) + offset,
-		kaddr + offset, to-offset);
+		kaddr + offset, to - offset);
 	mark_buffer_dirty(bh);
 	brelse(bh);
 	SetPageUptodate(page);
+out:
 	kunmap(page);
 	/* only one page here */
 	if (to > inode->i_size)
 		inode->i_size = to;
-	return 0;
+	return err;
 }
 
 struct address_space_operations udf_adinicb_aops = {
@@ -133,7 +157,7 @@
 	struct inode *inode = file->f_dentry->d_inode;
 	int err, pos;
 
-	if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
+	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
 	{
 		if (file->f_flags & O_APPEND)
 			pos = inode->i_size;
@@ -144,7 +168,7 @@
 			pos + count))
 		{
 			udf_expand_file_adinicb(inode, pos + count, &err);
-			if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
+			if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
 			{
 				udf_debug("udf_expand_adinicb: err=%d\n", err);
 				return err;
@@ -209,7 +233,7 @@
 	int result = -EINVAL;
 	struct buffer_head *bh = NULL;
 	long_ad eaicb;
-	Uint8 *ea = NULL;
+	uint8_t *ea = NULL;
 
 	if ( permission(inode, MAY_READ) != 0 )
 	{
@@ -256,18 +280,18 @@
 
 	if (UDF_I_EXTENDED_FE(inode) == 0)
 	{
-		struct FileEntry *fe;
+		struct fileEntry *fe;
 
-		fe = (struct FileEntry *)bh->b_data;
+		fe = (struct fileEntry *)bh->b_data;
 		eaicb = lela_to_cpu(fe->extendedAttrICB);
 		if (UDF_I_LENEATTR(inode))
 			ea = fe->extendedAttr;
 	}
 	else
 	{
-		struct ExtendedFileEntry *efe;
+		struct extendedFileEntry *efe;
 
-		efe = (struct ExtendedFileEntry *)bh->b_data;
+		efe = (struct extendedFileEntry *)bh->b_data;
 		eaicb = lela_to_cpu(efe->extendedAttrICB);
 		if (UDF_I_LENEATTR(inode))
 			ea = efe->extendedAttr;

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