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

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

diff -urN linux-2.4.18/fs/udf/truncate.c linux-2.4.19/fs/udf/truncate.c
@@ -15,7 +15,7 @@
  *		ftp://prep.ai.mit.edu/pub/gnu/GPL
  *	Each contributing author retains all rights to their own work.
  *
- *  (C) 1999-2000 Ben Fennema
+ *  (C) 1999-2001 Ben Fennema
  *  (C) 1999 Stelias Computing Inc
  *
  * HISTORY
@@ -33,7 +33,7 @@
 #include "udf_sb.h"
 
 static void extent_trunc(struct inode * inode, lb_addr bloc, int extoffset,
-	lb_addr eloc, Sint8 etype, Uint32 elen, struct buffer_head *bh, Uint32 nelen)
+	lb_addr eloc, int8_t etype, uint32_t elen, struct buffer_head *bh, uint32_t nelen)
 {
 	lb_addr neloc = { 0, 0 };
 	int last_block = (elen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
@@ -41,7 +41,13 @@
 
 	if (nelen)
 	{
-		neloc = eloc;
+		if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30))
+		{
+			udf_free_blocks(inode->i_sb, inode, eloc, 0, last_block);
+			etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30);
+		}
+		else
+			neloc = eloc;
 		nelen = (etype << 30) | nelen;
 	}
 
@@ -50,10 +56,10 @@
 		udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 0);
 		if (last_block - first_block > 0)
 		{
-			if (etype == EXTENT_RECORDED_ALLOCATED)
+			if (etype == (EXT_RECORDED_ALLOCATED >> 30))
 				mark_inode_dirty(inode);
 
-			if (etype != EXTENT_NOT_RECORDED_NOT_ALLOCATED)
+			if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
 				udf_free_blocks(inode->i_sb, inode, eloc, first_block, last_block - first_block);
 		}
 	}
@@ -62,15 +68,15 @@
 void udf_truncate_extents(struct inode * inode)
 {
 	lb_addr bloc, eloc, neloc = { 0, 0 };
-	Uint32 extoffset, elen, offset, nelen = 0, lelen = 0, lenalloc;
-	Sint8 etype;
+	uint32_t extoffset, elen, offset, nelen = 0, lelen = 0, lenalloc;
+	int8_t etype;
 	int first_block = inode->i_size >> inode->i_sb->s_blocksize_bits;
 	struct buffer_head *bh = NULL;
 	int adsize;
 
-	if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_SHORT)
+	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT)
 		adsize = sizeof(short_ad);
-	else if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_LONG)
+	else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG)
 		adsize = sizeof(long_ad);
 	else
 		adsize = 0;
@@ -91,11 +97,11 @@
 		if (!memcmp(&UDF_I_LOCATION(inode), &bloc, sizeof(lb_addr)))
 			lenalloc -= udf_file_entry_alloc_offset(inode);
 		else
-			lenalloc -= sizeof(struct AllocExtDesc);
+			lenalloc -= sizeof(struct allocExtDesc);
 
 		while ((etype = udf_current_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 0)) != -1)
 		{
-			if (etype == EXTENT_NEXT_EXTENT_ALLOCDECS)
+			if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30))
 			{
 				udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 0);
 				extoffset = 0;
@@ -104,7 +110,7 @@
 					if (!memcmp(&UDF_I_LOCATION(inode), &bloc, sizeof(lb_addr)))
 						memset(bh->b_data, 0x00, udf_file_entry_alloc_offset(inode));
 					else
-						memset(bh->b_data, 0x00, sizeof(struct AllocExtDesc));
+						memset(bh->b_data, 0x00, sizeof(struct allocExtDesc));
 					udf_free_blocks(inode->i_sb, inode, bloc, 0, lelen);
 				}
 				else
@@ -116,13 +122,13 @@
 					}
 					else
 					{
-						struct AllocExtDesc *aed = (struct AllocExtDesc *)(bh->b_data);
+						struct allocExtDesc *aed = (struct allocExtDesc *)(bh->b_data);
 						aed->lengthAllocDescs = cpu_to_le32(lenalloc);
 						if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
 							udf_update_tag(bh->b_data, lenalloc +
-								sizeof(struct AllocExtDesc));
+								sizeof(struct allocExtDesc));
 						else
-							udf_update_tag(bh->b_data, sizeof(struct AllocExtDesc));
+							udf_update_tag(bh->b_data, sizeof(struct allocExtDesc));
 						mark_buffer_dirty_inode(bh, inode);
 					}
 				}
@@ -149,7 +155,7 @@
 			if (!memcmp(&UDF_I_LOCATION(inode), &bloc, sizeof(lb_addr)))
 				memset(bh->b_data, 0x00, udf_file_entry_alloc_offset(inode));
 			else
-				memset(bh->b_data, 0x00, sizeof(struct AllocExtDesc));
+				memset(bh->b_data, 0x00, sizeof(struct allocExtDesc));
 			udf_free_blocks(inode->i_sb, inode, bloc, 0, lelen);
 		}
 		else
@@ -161,13 +167,13 @@
 			}
 			else
 			{
-				struct AllocExtDesc *aed = (struct AllocExtDesc *)(bh->b_data);
+				struct allocExtDesc *aed = (struct allocExtDesc *)(bh->b_data);
 				aed->lengthAllocDescs = cpu_to_le32(lenalloc);
 				if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
 					udf_update_tag(bh->b_data, lenalloc +
-						sizeof(struct AllocExtDesc));
+						sizeof(struct allocExtDesc));
 				else
-					udf_update_tag(bh->b_data, sizeof(struct AllocExtDesc));
+					udf_update_tag(bh->b_data, sizeof(struct allocExtDesc));
 				mark_buffer_dirty_inode(bh, inode);
 			}
 		}
@@ -178,17 +184,17 @@
 		{
 			extoffset -= adsize;
 			etype = udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 1);
-			if (etype == EXTENT_NOT_RECORDED_NOT_ALLOCATED)
+			if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
 			{
 				extoffset -= adsize;
-				elen = (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30) | (elen + offset);
+				elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + offset);
 				udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 0);
 			}
-			else if (etype == EXTENT_NOT_RECORDED_ALLOCATED)
+			else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30))
 			{
 				lb_addr neloc = { 0, 0 };
 				extoffset -= adsize;
-				nelen = (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30) |
+				nelen = EXT_NOT_RECORDED_NOT_ALLOCATED |
 					((elen + offset + inode->i_sb->s_blocksize - 1) &
 					~(inode->i_sb->s_blocksize - 1));
 				udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1);
@@ -199,13 +205,13 @@
 				if (elen & (inode->i_sb->s_blocksize - 1))
 				{
 					extoffset -= adsize;
-					elen = (EXTENT_RECORDED_ALLOCATED << 30) |
+					elen = EXT_RECORDED_ALLOCATED |
 						((elen + inode->i_sb->s_blocksize - 1) &
 						~(inode->i_sb->s_blocksize - 1));
 					udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 1);
 				}
 				memset(&eloc, 0x00, sizeof(lb_addr));
-				elen = (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30) | offset;
+				elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset;
 				udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1);
 			}
 		}

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