UDF: coding style conversion - lindent
This patch converts UDF coding style to kernel coding style using Lindent. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
				
					committed by
					
						
						Linus Torvalds
					
				
			
			
				
	
			
			
			
						parent
						
							95a631e2d9
						
					
				
				
					commit
					cb00ea3528
				
			
							
								
								
									
										705
									
								
								fs/udf/balloc.c
									
									
									
									
									
								
							
							
						
						
									
										705
									
								
								fs/udf/balloc.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										19
									
								
								fs/udf/crc.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								fs/udf/crc.c
									
									
									
									
									
								
							@@ -79,8 +79,7 @@ static uint16_t crc_table[256] = {
 | 
			
		||||
 *	July 21, 1997 - Andrew E. Mileski
 | 
			
		||||
 *	Adapted from OSTA-UDF(tm) 1.50 standard.
 | 
			
		||||
 */
 | 
			
		||||
uint16_t
 | 
			
		||||
udf_crc(uint8_t *data, uint32_t size, uint16_t crc)
 | 
			
		||||
uint16_t udf_crc(uint8_t * data, uint32_t size, uint16_t crc)
 | 
			
		||||
{
 | 
			
		||||
	while (size--)
 | 
			
		||||
		crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8);
 | 
			
		||||
@@ -112,7 +111,7 @@ int main(void)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* defined(TEST) */
 | 
			
		||||
#endif				/* defined(TEST) */
 | 
			
		||||
 | 
			
		||||
/****************************************************************************/
 | 
			
		||||
#if defined(GENERATE)
 | 
			
		||||
@@ -138,7 +137,7 @@ int main(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
	/* Get the polynomial */
 | 
			
		||||
	sscanf(argv[1], "%lo", &poly);
 | 
			
		||||
	if (poly & 0xffff0000U){
 | 
			
		||||
	if (poly & 0xffff0000U) {
 | 
			
		||||
		fprintf(stderr, "polynomial is too large\en");
 | 
			
		||||
		exit(1);
 | 
			
		||||
	}
 | 
			
		||||
@@ -147,22 +146,22 @@ int main(int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
	/* Create a table */
 | 
			
		||||
	printf("static unsigned short crc_table[256] = {\n");
 | 
			
		||||
	for (n = 0; n < 256; n++){
 | 
			
		||||
	for (n = 0; n < 256; n++) {
 | 
			
		||||
		if (n % 8 == 0)
 | 
			
		||||
			printf("\t");
 | 
			
		||||
		crc = n << 8;
 | 
			
		||||
		for (i = 0; i < 8; i++){
 | 
			
		||||
			if(crc & 0x8000U)
 | 
			
		||||
		for (i = 0; i < 8; i++) {
 | 
			
		||||
			if (crc & 0x8000U)
 | 
			
		||||
				crc = (crc << 1) ^ poly;
 | 
			
		||||
			else
 | 
			
		||||
				crc <<= 1;
 | 
			
		||||
		crc &= 0xFFFFU;
 | 
			
		||||
			crc &= 0xFFFFU;
 | 
			
		||||
		}
 | 
			
		||||
		if (n == 255)
 | 
			
		||||
			printf("0x%04xU ", crc);
 | 
			
		||||
		else
 | 
			
		||||
			printf("0x%04xU, ", crc);
 | 
			
		||||
		if(n % 8 == 7)
 | 
			
		||||
		if (n % 8 == 7)
 | 
			
		||||
			printf("\n");
 | 
			
		||||
	}
 | 
			
		||||
	printf("};\n");
 | 
			
		||||
@@ -170,4 +169,4 @@ int main(int argc, char **argv)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* defined(GENERATE) */
 | 
			
		||||
#endif				/* defined(GENERATE) */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										136
									
								
								fs/udf/dir.c
									
									
									
									
									
								
							
							
						
						
									
										136
									
								
								fs/udf/dir.c
									
									
									
									
									
								
							@@ -43,10 +43,10 @@ static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *);
 | 
			
		||||
/* readdir and lookup functions */
 | 
			
		||||
 | 
			
		||||
const struct file_operations udf_dir_operations = {
 | 
			
		||||
	.read			= generic_read_dir,
 | 
			
		||||
	.readdir		= udf_readdir,
 | 
			
		||||
	.ioctl			= udf_ioctl,
 | 
			
		||||
	.fsync			= udf_fsync_file,
 | 
			
		||||
	.read = generic_read_dir,
 | 
			
		||||
	.readdir = udf_readdir,
 | 
			
		||||
	.ioctl = udf_ioctl,
 | 
			
		||||
	.fsync = udf_fsync_file,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -82,26 +82,26 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
 | 
			
		||||
 | 
			
		||||
	lock_kernel();
 | 
			
		||||
 | 
			
		||||
	if ( filp->f_pos == 0 ) 
 | 
			
		||||
	{
 | 
			
		||||
		if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0)
 | 
			
		||||
		{
 | 
			
		||||
	if (filp->f_pos == 0) {
 | 
			
		||||
		if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) <
 | 
			
		||||
		    0) {
 | 
			
		||||
			unlock_kernel();
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		filp->f_pos ++;
 | 
			
		||||
		filp->f_pos++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	result = do_udf_readdir(dir, filp, filldir, dirent);
 | 
			
		||||
	unlock_kernel();
 | 
			
		||||
 	return result;
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int 
 | 
			
		||||
do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *dirent)
 | 
			
		||||
static int
 | 
			
		||||
do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
 | 
			
		||||
	       void *dirent)
 | 
			
		||||
{
 | 
			
		||||
	struct udf_fileident_bh fibh;
 | 
			
		||||
	struct fileIdentDesc *fi=NULL;
 | 
			
		||||
	struct fileIdentDesc *fi = NULL;
 | 
			
		||||
	struct fileIdentDesc cfi;
 | 
			
		||||
	int block, iblock;
 | 
			
		||||
	loff_t nf_pos = filp->f_pos - 1;
 | 
			
		||||
@@ -117,7 +117,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
 | 
			
		||||
	sector_t offset;
 | 
			
		||||
	int i, num;
 | 
			
		||||
	unsigned int dt_type;
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0}};
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0} };
 | 
			
		||||
 | 
			
		||||
	if (nf_pos >= size)
 | 
			
		||||
		return 0;
 | 
			
		||||
@@ -125,65 +125,61 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
 | 
			
		||||
	if (nf_pos == 0)
 | 
			
		||||
		nf_pos = (udf_ext0_offset(dir) >> 2);
 | 
			
		||||
 | 
			
		||||
	fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
 | 
			
		||||
	fibh.soffset = fibh.eoffset =
 | 
			
		||||
	    (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
 | 
			
		||||
		fibh.sbh = fibh.ebh = NULL;
 | 
			
		||||
	else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
 | 
			
		||||
		&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
	{
 | 
			
		||||
			    &epos, &eloc, &elen,
 | 
			
		||||
			    &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
 | 
			
		||||
		block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
 | 
			
		||||
		if ((++offset << dir->i_sb->s_blocksize_bits) < elen)
 | 
			
		||||
		{
 | 
			
		||||
		if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
 | 
			
		||||
			if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
 | 
			
		||||
				epos.offset -= sizeof(short_ad);
 | 
			
		||||
			else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
 | 
			
		||||
				epos.offset -= sizeof(long_ad);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		} else
 | 
			
		||||
			offset = 0;
 | 
			
		||||
 | 
			
		||||
		if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block)))
 | 
			
		||||
		{
 | 
			
		||||
		if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
 | 
			
		||||
			brelse(epos.bh);
 | 
			
		||||
			return -EIO;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
		if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9))-1)))
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
 | 
			
		||||
			i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
 | 
			
		||||
			if (i+offset > (elen >> dir->i_sb->s_blocksize_bits))
 | 
			
		||||
				i = (elen >> dir->i_sb->s_blocksize_bits)-offset;
 | 
			
		||||
			for (num=0; i>0; i--)
 | 
			
		||||
			{
 | 
			
		||||
				block = udf_get_lb_pblock(dir->i_sb, eloc, offset+i);
 | 
			
		||||
			if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
 | 
			
		||||
				i = (elen >> dir->i_sb->s_blocksize_bits) -
 | 
			
		||||
				    offset;
 | 
			
		||||
			for (num = 0; i > 0; i--) {
 | 
			
		||||
				block =
 | 
			
		||||
				    udf_get_lb_pblock(dir->i_sb, eloc,
 | 
			
		||||
						      offset + i);
 | 
			
		||||
				tmp = udf_tgetblk(dir->i_sb, block);
 | 
			
		||||
				if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
 | 
			
		||||
				if (tmp && !buffer_uptodate(tmp)
 | 
			
		||||
				    && !buffer_locked(tmp))
 | 
			
		||||
					bha[num++] = tmp;
 | 
			
		||||
				else
 | 
			
		||||
					brelse(tmp);
 | 
			
		||||
			}
 | 
			
		||||
			if (num)
 | 
			
		||||
			{
 | 
			
		||||
			if (num) {
 | 
			
		||||
				ll_rw_block(READA, num, bha);
 | 
			
		||||
				for (i=0; i<num; i++)
 | 
			
		||||
				for (i = 0; i < num; i++)
 | 
			
		||||
					brelse(bha[i]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
	} else {
 | 
			
		||||
		brelse(epos.bh);
 | 
			
		||||
		return -ENOENT;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while ( nf_pos < size )
 | 
			
		||||
	{
 | 
			
		||||
	while (nf_pos < size) {
 | 
			
		||||
		filp->f_pos = nf_pos + 1;
 | 
			
		||||
 | 
			
		||||
		fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, &elen, &offset);
 | 
			
		||||
		fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
 | 
			
		||||
					&elen, &offset);
 | 
			
		||||
 | 
			
		||||
		if (!fi)
 | 
			
		||||
		{
 | 
			
		||||
		if (!fi) {
 | 
			
		||||
			if (fibh.sbh != fibh.ebh)
 | 
			
		||||
				brelse(fibh.ebh);
 | 
			
		||||
			brelse(fibh.sbh);
 | 
			
		||||
@@ -196,43 +192,41 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
 | 
			
		||||
 | 
			
		||||
		if (fibh.sbh == fibh.ebh)
 | 
			
		||||
			nameptr = fi->fileIdent + liu;
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
		else {
 | 
			
		||||
			int poffset;	/* Unpaded ending offset */
 | 
			
		||||
 | 
			
		||||
			poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi;
 | 
			
		||||
			poffset =
 | 
			
		||||
			    fibh.soffset + sizeof(struct fileIdentDesc) + liu +
 | 
			
		||||
			    lfi;
 | 
			
		||||
 | 
			
		||||
			if (poffset >= lfi)
 | 
			
		||||
				nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				nameptr =
 | 
			
		||||
				    (char *)(fibh.ebh->b_data + poffset - lfi);
 | 
			
		||||
			else {
 | 
			
		||||
				nameptr = fname;
 | 
			
		||||
				memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
 | 
			
		||||
				memcpy(nameptr + lfi - poffset, fibh.ebh->b_data, poffset);
 | 
			
		||||
				memcpy(nameptr, fi->fileIdent + liu,
 | 
			
		||||
				       lfi - poffset);
 | 
			
		||||
				memcpy(nameptr + lfi - poffset,
 | 
			
		||||
				       fibh.ebh->b_data, poffset);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0 )
 | 
			
		||||
		{
 | 
			
		||||
			if ( !UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE) )
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if ( (cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0 )
 | 
			
		||||
		{
 | 
			
		||||
			if ( !UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE) )
 | 
			
		||||
		if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
 | 
			
		||||
			if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE))
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( cfi.fileCharacteristics & FID_FILE_CHAR_PARENT )
 | 
			
		||||
		{
 | 
			
		||||
		if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
 | 
			
		||||
			if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE))
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (cfi.fileCharacteristics & FID_FILE_CHAR_PARENT) {
 | 
			
		||||
			iblock = parent_ino(filp->f_path.dentry);
 | 
			
		||||
			flen = 2;
 | 
			
		||||
			memcpy(fname, "..", flen);
 | 
			
		||||
			dt_type = DT_DIR;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
		} else {
 | 
			
		||||
			kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);
 | 
			
		||||
 | 
			
		||||
			iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0);
 | 
			
		||||
@@ -240,18 +234,18 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
 | 
			
		||||
			dt_type = DT_UNKNOWN;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (flen)
 | 
			
		||||
		{
 | 
			
		||||
			if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0)
 | 
			
		||||
			{
 | 
			
		||||
		if (flen) {
 | 
			
		||||
			if (filldir
 | 
			
		||||
			    (dirent, fname, flen, filp->f_pos, iblock,
 | 
			
		||||
			     dt_type) < 0) {
 | 
			
		||||
				if (fibh.sbh != fibh.ebh)
 | 
			
		||||
					brelse(fibh.ebh);
 | 
			
		||||
				brelse(fibh.sbh);
 | 
			
		||||
				brelse(epos.bh);
 | 
			
		||||
	 			return 0;
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} /* end while */
 | 
			
		||||
	}			/* end while */
 | 
			
		||||
 | 
			
		||||
	filp->f_pos = nf_pos + 1;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,10 +19,10 @@
 | 
			
		||||
#include <linux/buffer_head.h>
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
static uint8_t *
 | 
			
		||||
udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
 | 
			
		||||
		kernel_lb_addr fe_loc, int *pos, int *offset,
 | 
			
		||||
		struct buffer_head **bh, int *error)
 | 
			
		||||
static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
 | 
			
		||||
				uint8_t ad_size, kernel_lb_addr fe_loc,
 | 
			
		||||
				int *pos, int *offset, struct buffer_head **bh,
 | 
			
		||||
				int *error)
 | 
			
		||||
{
 | 
			
		||||
	int loffset = *offset;
 | 
			
		||||
	int block;
 | 
			
		||||
@@ -31,31 +31,27 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
 | 
			
		||||
 | 
			
		||||
	*error = 0;
 | 
			
		||||
 | 
			
		||||
	ad = (uint8_t *)(*bh)->b_data + *offset;
 | 
			
		||||
	ad = (uint8_t *) (*bh)->b_data + *offset;
 | 
			
		||||
	*offset += ad_size;
 | 
			
		||||
 | 
			
		||||
	if (!ad)
 | 
			
		||||
	{
 | 
			
		||||
	if (!ad) {
 | 
			
		||||
		brelse(*bh);
 | 
			
		||||
		*error = 1;
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (*offset == dir->i_sb->s_blocksize)
 | 
			
		||||
	{
 | 
			
		||||
	if (*offset == dir->i_sb->s_blocksize) {
 | 
			
		||||
		brelse(*bh);
 | 
			
		||||
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
 | 
			
		||||
		if (!block)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (!(*bh = udf_tread(dir->i_sb, block)))
 | 
			
		||||
			return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	else if (*offset > dir->i_sb->s_blocksize)
 | 
			
		||||
	{
 | 
			
		||||
	} else if (*offset > dir->i_sb->s_blocksize) {
 | 
			
		||||
		ad = tmpad;
 | 
			
		||||
 | 
			
		||||
		remainder = dir->i_sb->s_blocksize - loffset;
 | 
			
		||||
		memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
 | 
			
		||||
		memcpy((uint8_t *) ad, (*bh)->b_data + loffset, remainder);
 | 
			
		||||
 | 
			
		||||
		brelse(*bh);
 | 
			
		||||
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
 | 
			
		||||
@@ -64,56 +60,56 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
 | 
			
		||||
		if (!((*bh) = udf_tread(dir->i_sb, block)))
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
		memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
 | 
			
		||||
		memcpy((uint8_t *) ad + remainder, (*bh)->b_data,
 | 
			
		||||
		       ad_size - remainder);
 | 
			
		||||
		*offset = ad_size - remainder;
 | 
			
		||||
	}
 | 
			
		||||
	return ad;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct fileIdentDesc *
 | 
			
		||||
udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 | 
			
		||||
	struct udf_fileident_bh *fibh,
 | 
			
		||||
	struct fileIdentDesc *cfi,
 | 
			
		||||
	struct extent_position *epos,
 | 
			
		||||
	kernel_lb_addr *eloc, uint32_t *elen,
 | 
			
		||||
	sector_t *offset)
 | 
			
		||||
struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
 | 
			
		||||
					 struct udf_fileident_bh *fibh,
 | 
			
		||||
					 struct fileIdentDesc *cfi,
 | 
			
		||||
					 struct extent_position *epos,
 | 
			
		||||
					 kernel_lb_addr * eloc, uint32_t * elen,
 | 
			
		||||
					 sector_t * offset)
 | 
			
		||||
{
 | 
			
		||||
	struct fileIdentDesc *fi;
 | 
			
		||||
	int i, num, block;
 | 
			
		||||
	struct buffer_head * tmp, * bha[16];
 | 
			
		||||
	struct buffer_head *tmp, *bha[16];
 | 
			
		||||
 | 
			
		||||
	fibh->soffset = fibh->eoffset;
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
 | 
			
		||||
		fi = udf_get_fileident(UDF_I_DATA(dir) -
 | 
			
		||||
			(UDF_I_EFE(dir) ?
 | 
			
		||||
				sizeof(struct extendedFileEntry) :
 | 
			
		||||
				sizeof(struct fileEntry)),
 | 
			
		||||
			dir->i_sb->s_blocksize, &(fibh->eoffset));
 | 
			
		||||
				       (UDF_I_EFE(dir) ?
 | 
			
		||||
					sizeof(struct extendedFileEntry) :
 | 
			
		||||
					sizeof(struct fileEntry)),
 | 
			
		||||
				       dir->i_sb->s_blocksize,
 | 
			
		||||
				       &(fibh->eoffset));
 | 
			
		||||
 | 
			
		||||
		if (!fi)
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
		*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
 | 
			
		||||
 | 
			
		||||
		memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
 | 
			
		||||
		memcpy((uint8_t *) cfi, (uint8_t *) fi,
 | 
			
		||||
		       sizeof(struct fileIdentDesc));
 | 
			
		||||
 | 
			
		||||
		return fi;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (fibh->eoffset == dir->i_sb->s_blocksize)
 | 
			
		||||
	{
 | 
			
		||||
	if (fibh->eoffset == dir->i_sb->s_blocksize) {
 | 
			
		||||
		int lextoffset = epos->offset;
 | 
			
		||||
 | 
			
		||||
		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
 | 
			
		||||
			(EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
		    (EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
		block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
 | 
			
		||||
 | 
			
		||||
		(*offset) ++;
 | 
			
		||||
		(*offset)++;
 | 
			
		||||
 | 
			
		||||
		if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
 | 
			
		||||
			*offset = 0;
 | 
			
		||||
@@ -125,57 +121,57 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 | 
			
		||||
			return NULL;
 | 
			
		||||
		fibh->soffset = fibh->eoffset = 0;
 | 
			
		||||
 | 
			
		||||
		if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9))-1)))
 | 
			
		||||
		if (!
 | 
			
		||||
		    (*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
 | 
			
		||||
		{
 | 
			
		||||
			i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
 | 
			
		||||
			if (i+*offset > (*elen >> dir->i_sb->s_blocksize_bits))
 | 
			
		||||
				i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset;
 | 
			
		||||
			for (num=0; i>0; i--)
 | 
			
		||||
			{
 | 
			
		||||
				block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset+i);
 | 
			
		||||
			if (i + *offset >
 | 
			
		||||
			    (*elen >> dir->i_sb->s_blocksize_bits))
 | 
			
		||||
				i = (*elen >> dir->i_sb->s_blocksize_bits) -
 | 
			
		||||
				    *offset;
 | 
			
		||||
			for (num = 0; i > 0; i--) {
 | 
			
		||||
				block =
 | 
			
		||||
				    udf_get_lb_pblock(dir->i_sb, *eloc,
 | 
			
		||||
						      *offset + i);
 | 
			
		||||
				tmp = udf_tgetblk(dir->i_sb, block);
 | 
			
		||||
				if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
 | 
			
		||||
				if (tmp && !buffer_uptodate(tmp)
 | 
			
		||||
				    && !buffer_locked(tmp))
 | 
			
		||||
					bha[num++] = tmp;
 | 
			
		||||
				else
 | 
			
		||||
					brelse(tmp);
 | 
			
		||||
			}
 | 
			
		||||
			if (num)
 | 
			
		||||
			{
 | 
			
		||||
			if (num) {
 | 
			
		||||
				ll_rw_block(READA, num, bha);
 | 
			
		||||
				for (i=0; i<num; i++)
 | 
			
		||||
				for (i = 0; i < num; i++)
 | 
			
		||||
					brelse(bha[i]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (fibh->sbh != fibh->ebh)
 | 
			
		||||
	{
 | 
			
		||||
	} else if (fibh->sbh != fibh->ebh) {
 | 
			
		||||
		brelse(fibh->sbh);
 | 
			
		||||
		fibh->sbh = fibh->ebh;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize,
 | 
			
		||||
		&(fibh->eoffset));
 | 
			
		||||
			       &(fibh->eoffset));
 | 
			
		||||
 | 
			
		||||
	if (!fi)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
 | 
			
		||||
 | 
			
		||||
	if (fibh->eoffset <= dir->i_sb->s_blocksize)
 | 
			
		||||
	{
 | 
			
		||||
		memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
 | 
			
		||||
	}
 | 
			
		||||
	else if (fibh->eoffset > dir->i_sb->s_blocksize)
 | 
			
		||||
	{
 | 
			
		||||
	if (fibh->eoffset <= dir->i_sb->s_blocksize) {
 | 
			
		||||
		memcpy((uint8_t *) cfi, (uint8_t *) fi,
 | 
			
		||||
		       sizeof(struct fileIdentDesc));
 | 
			
		||||
	} else if (fibh->eoffset > dir->i_sb->s_blocksize) {
 | 
			
		||||
		int lextoffset = epos->offset;
 | 
			
		||||
 | 
			
		||||
		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
 | 
			
		||||
			(EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
		    (EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
		block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
 | 
			
		||||
 | 
			
		||||
		(*offset) ++;
 | 
			
		||||
		(*offset)++;
 | 
			
		||||
 | 
			
		||||
		if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
 | 
			
		||||
			*offset = 0;
 | 
			
		||||
@@ -188,62 +184,62 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 | 
			
		||||
		if (!(fibh->ebh = udf_tread(dir->i_sb, block)))
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
		if (sizeof(struct fileIdentDesc) > - fibh->soffset)
 | 
			
		||||
		{
 | 
			
		||||
		if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
 | 
			
		||||
			int fi_len;
 | 
			
		||||
 | 
			
		||||
			memcpy((uint8_t *)cfi, (uint8_t *)fi, - fibh->soffset);
 | 
			
		||||
			memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
 | 
			
		||||
				sizeof(struct fileIdentDesc) + fibh->soffset);
 | 
			
		||||
			memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset);
 | 
			
		||||
			memcpy((uint8_t *) cfi - fibh->soffset,
 | 
			
		||||
			       fibh->ebh->b_data,
 | 
			
		||||
			       sizeof(struct fileIdentDesc) + fibh->soffset);
 | 
			
		||||
 | 
			
		||||
			fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
 | 
			
		||||
				le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
 | 
			
		||||
			fi_len =
 | 
			
		||||
			    (sizeof(struct fileIdentDesc) +
 | 
			
		||||
			     cfi->lengthFileIdent +
 | 
			
		||||
			     le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
 | 
			
		||||
 | 
			
		||||
			*nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
 | 
			
		||||
			*nf_pos +=
 | 
			
		||||
			    ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
 | 
			
		||||
			fibh->eoffset = fibh->soffset + fi_len;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
 | 
			
		||||
		} else {
 | 
			
		||||
			memcpy((uint8_t *) cfi, (uint8_t *) fi,
 | 
			
		||||
			       sizeof(struct fileIdentDesc));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fi;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct fileIdentDesc * 
 | 
			
		||||
udf_get_fileident(void * buffer, int bufsize, int * offset)
 | 
			
		||||
struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 | 
			
		||||
{
 | 
			
		||||
	struct fileIdentDesc *fi;
 | 
			
		||||
	int lengthThisIdent;
 | 
			
		||||
	uint8_t * ptr;
 | 
			
		||||
	uint8_t *ptr;
 | 
			
		||||
	int padlen;
 | 
			
		||||
 | 
			
		||||
	if ( (!buffer) || (!offset) ) {
 | 
			
		||||
		udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer, offset);
 | 
			
		||||
	if ((!buffer) || (!offset)) {
 | 
			
		||||
		udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
 | 
			
		||||
			  offset);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ptr = buffer;
 | 
			
		||||
 | 
			
		||||
	if ( (*offset > 0) && (*offset < bufsize) ) {
 | 
			
		||||
	if ((*offset > 0) && (*offset < bufsize)) {
 | 
			
		||||
		ptr += *offset;
 | 
			
		||||
	}
 | 
			
		||||
	fi=(struct fileIdentDesc *)ptr;
 | 
			
		||||
	if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID)
 | 
			
		||||
	{
 | 
			
		||||
	fi = (struct fileIdentDesc *)ptr;
 | 
			
		||||
	if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) {
 | 
			
		||||
		udf_debug("0x%x != TAG_IDENT_FID\n",
 | 
			
		||||
			le16_to_cpu(fi->descTag.tagIdent));
 | 
			
		||||
			  le16_to_cpu(fi->descTag.tagIdent));
 | 
			
		||||
		udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
 | 
			
		||||
			*offset, (unsigned long)sizeof(struct fileIdentDesc), bufsize);
 | 
			
		||||
			  *offset, (unsigned long)sizeof(struct fileIdentDesc),
 | 
			
		||||
			  bufsize);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if ( (*offset + sizeof(struct fileIdentDesc)) > bufsize )
 | 
			
		||||
	{
 | 
			
		||||
	if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
 | 
			
		||||
		lengthThisIdent = sizeof(struct fileIdentDesc);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	} else
 | 
			
		||||
		lengthThisIdent = sizeof(struct fileIdentDesc) +
 | 
			
		||||
			fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
 | 
			
		||||
		    fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
 | 
			
		||||
 | 
			
		||||
	/* we need to figure padding, too! */
 | 
			
		||||
	padlen = lengthThisIdent % UDF_NAME_PAD;
 | 
			
		||||
@@ -255,56 +251,53 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
static extent_ad *
 | 
			
		||||
udf_get_fileextent(void * buffer, int bufsize, int * offset)
 | 
			
		||||
static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
 | 
			
		||||
{
 | 
			
		||||
	extent_ad * ext;
 | 
			
		||||
	extent_ad *ext;
 | 
			
		||||
	struct fileEntry *fe;
 | 
			
		||||
	uint8_t * ptr;
 | 
			
		||||
	uint8_t *ptr;
 | 
			
		||||
 | 
			
		||||
	if ( (!buffer) || (!offset) )
 | 
			
		||||
	{
 | 
			
		||||
	if ((!buffer) || (!offset)) {
 | 
			
		||||
		printk(KERN_ERR "udf: udf_get_fileextent() invalidparms\n");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fe = (struct fileEntry *)buffer;
 | 
			
		||||
 | 
			
		||||
	if ( le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE )
 | 
			
		||||
	{
 | 
			
		||||
	if (le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE) {
 | 
			
		||||
		udf_debug("0x%x != TAG_IDENT_FE\n",
 | 
			
		||||
			le16_to_cpu(fe->descTag.tagIdent));
 | 
			
		||||
			  le16_to_cpu(fe->descTag.tagIdent));
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ptr=(uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
 | 
			
		||||
	ptr =
 | 
			
		||||
	    (uint8_t *) (fe->extendedAttr) +
 | 
			
		||||
	    le32_to_cpu(fe->lengthExtendedAttr);
 | 
			
		||||
 | 
			
		||||
	if ( (*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)) )
 | 
			
		||||
	{
 | 
			
		||||
	if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) {
 | 
			
		||||
		ptr += *offset;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ext = (extent_ad *)ptr;
 | 
			
		||||
	ext = (extent_ad *) ptr;
 | 
			
		||||
 | 
			
		||||
	*offset = *offset + sizeof(extent_ad);
 | 
			
		||||
	return ext;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
short_ad *
 | 
			
		||||
udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc)
 | 
			
		||||
short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
 | 
			
		||||
			      int inc)
 | 
			
		||||
{
 | 
			
		||||
	short_ad *sa;
 | 
			
		||||
 | 
			
		||||
	if ( (!ptr) || (!offset) )
 | 
			
		||||
	{
 | 
			
		||||
	if ((!ptr) || (!offset)) {
 | 
			
		||||
		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( (*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset) )
 | 
			
		||||
	if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset))
 | 
			
		||||
		return NULL;
 | 
			
		||||
	else if ((sa = (short_ad *)ptr)->extLength == 0)
 | 
			
		||||
	else if ((sa = (short_ad *) ptr)->extLength == 0)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	if (inc)
 | 
			
		||||
@@ -312,20 +305,18 @@ udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc)
 | 
			
		||||
	return sa;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
long_ad *
 | 
			
		||||
udf_get_filelongad(uint8_t *ptr, int maxoffset, int * offset, int inc)
 | 
			
		||||
long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
 | 
			
		||||
{
 | 
			
		||||
	long_ad *la;
 | 
			
		||||
 | 
			
		||||
	if ( (!ptr) || (!offset) ) 
 | 
			
		||||
	{
 | 
			
		||||
	if ((!ptr) || (!offset)) {
 | 
			
		||||
		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( (*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset) )
 | 
			
		||||
	if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset))
 | 
			
		||||
		return NULL;
 | 
			
		||||
	else if ((la = (long_ad *)ptr)->extLength == 0)
 | 
			
		||||
	else if ((la = (long_ad *) ptr)->extLength == 0)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	if (inc)
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										114
									
								
								fs/udf/file.c
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								fs/udf/file.c
									
									
									
									
									
								
							@@ -30,7 +30,7 @@
 | 
			
		||||
#include <linux/udf_fs.h>
 | 
			
		||||
#include <asm/uaccess.h>
 | 
			
		||||
#include <linux/kernel.h>
 | 
			
		||||
#include <linux/string.h> /* memset */
 | 
			
		||||
#include <linux/string.h>	/* memset */
 | 
			
		||||
#include <linux/capability.h>
 | 
			
		||||
#include <linux/errno.h>
 | 
			
		||||
#include <linux/smp_lock.h>
 | 
			
		||||
@@ -41,7 +41,7 @@
 | 
			
		||||
#include "udf_i.h"
 | 
			
		||||
#include "udf_sb.h"
 | 
			
		||||
 | 
			
		||||
static int udf_adinicb_readpage(struct file *file, struct page * page)
 | 
			
		||||
static int udf_adinicb_readpage(struct file *file, struct page *page)
 | 
			
		||||
{
 | 
			
		||||
	struct inode *inode = page->mapping->host;
 | 
			
		||||
	char *kaddr;
 | 
			
		||||
@@ -58,7 +58,8 @@ static int udf_adinicb_readpage(struct file *file, struct page * page)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
 | 
			
		||||
static int udf_adinicb_writepage(struct page *page,
 | 
			
		||||
				 struct writeback_control *wbc)
 | 
			
		||||
{
 | 
			
		||||
	struct inode *inode = page->mapping->host;
 | 
			
		||||
	char *kaddr;
 | 
			
		||||
@@ -74,19 +75,21 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int udf_adinicb_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
 | 
			
		||||
static int udf_adinicb_prepare_write(struct file *file, struct page *page,
 | 
			
		||||
				     unsigned offset, unsigned to)
 | 
			
		||||
{
 | 
			
		||||
	kmap(page);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int udf_adinicb_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
 | 
			
		||||
static int udf_adinicb_commit_write(struct file *file, struct page *page,
 | 
			
		||||
				    unsigned offset, unsigned to)
 | 
			
		||||
{
 | 
			
		||||
	struct inode *inode = page->mapping->host;
 | 
			
		||||
	char *kaddr = page_address(page);
 | 
			
		||||
 | 
			
		||||
	memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset,
 | 
			
		||||
		kaddr + offset, to - offset);
 | 
			
		||||
	       kaddr + offset, to - offset);
 | 
			
		||||
	mark_inode_dirty(inode);
 | 
			
		||||
	SetPageUptodate(page);
 | 
			
		||||
	kunmap(page);
 | 
			
		||||
@@ -97,15 +100,15 @@ static int udf_adinicb_commit_write(struct file *file, struct page *page, unsign
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct address_space_operations udf_adinicb_aops = {
 | 
			
		||||
	.readpage		= udf_adinicb_readpage,
 | 
			
		||||
	.writepage		= udf_adinicb_writepage,
 | 
			
		||||
	.sync_page		= block_sync_page,
 | 
			
		||||
	.prepare_write		= udf_adinicb_prepare_write,
 | 
			
		||||
	.commit_write		= udf_adinicb_commit_write,
 | 
			
		||||
	.readpage = udf_adinicb_readpage,
 | 
			
		||||
	.writepage = udf_adinicb_writepage,
 | 
			
		||||
	.sync_page = block_sync_page,
 | 
			
		||||
	.prepare_write = udf_adinicb_prepare_write,
 | 
			
		||||
	.commit_write = udf_adinicb_commit_write,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 | 
			
		||||
			      unsigned long nr_segs, loff_t ppos)
 | 
			
		||||
				  unsigned long nr_segs, loff_t ppos)
 | 
			
		||||
{
 | 
			
		||||
	ssize_t retval;
 | 
			
		||||
	struct file *file = iocb->ki_filp;
 | 
			
		||||
@@ -113,25 +116,20 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 | 
			
		||||
	int err, pos;
 | 
			
		||||
	size_t count = iocb->ki_left;
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
 | 
			
		||||
		if (file->f_flags & O_APPEND)
 | 
			
		||||
			pos = inode->i_size;
 | 
			
		||||
		else
 | 
			
		||||
			pos = ppos;
 | 
			
		||||
 | 
			
		||||
		if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
 | 
			
		||||
			pos + count))
 | 
			
		||||
		{
 | 
			
		||||
		if (inode->i_sb->s_blocksize <
 | 
			
		||||
		    (udf_file_entry_alloc_offset(inode) + pos + count)) {
 | 
			
		||||
			udf_expand_file_adinicb(inode, pos + count, &err);
 | 
			
		||||
			if (UDF_I_ALLOCTYPE(inode) == ICBTAG_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;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
		} else {
 | 
			
		||||
			if (pos + count > inode->i_size)
 | 
			
		||||
				UDF_I_LENALLOC(inode) = pos + count;
 | 
			
		||||
			else
 | 
			
		||||
@@ -181,48 +179,47 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 | 
			
		||||
 *	Written, tested, and released.
 | 
			
		||||
 */
 | 
			
		||||
int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 | 
			
		||||
	unsigned long arg)
 | 
			
		||||
	      unsigned long arg)
 | 
			
		||||
{
 | 
			
		||||
	int result = -EINVAL;
 | 
			
		||||
 | 
			
		||||
	if ( file_permission(filp, MAY_READ) != 0 )
 | 
			
		||||
	{
 | 
			
		||||
		udf_debug("no permission to access inode %lu\n",
 | 
			
		||||
						inode->i_ino);
 | 
			
		||||
	if (file_permission(filp, MAY_READ) != 0) {
 | 
			
		||||
		udf_debug("no permission to access inode %lu\n", inode->i_ino);
 | 
			
		||||
		return -EPERM;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( !arg )
 | 
			
		||||
	{
 | 
			
		||||
	if (!arg) {
 | 
			
		||||
		udf_debug("invalid argument to udf_ioctl\n");
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch (cmd)
 | 
			
		||||
	{
 | 
			
		||||
		case UDF_GETVOLIDENT:
 | 
			
		||||
			return copy_to_user((char __user *)arg,
 | 
			
		||||
				UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
 | 
			
		||||
		case UDF_RELOCATE_BLOCKS:
 | 
			
		||||
	switch (cmd) {
 | 
			
		||||
	case UDF_GETVOLIDENT:
 | 
			
		||||
		return copy_to_user((char __user *)arg,
 | 
			
		||||
				    UDF_SB_VOLIDENT(inode->i_sb),
 | 
			
		||||
				    32) ? -EFAULT : 0;
 | 
			
		||||
	case UDF_RELOCATE_BLOCKS:
 | 
			
		||||
		{
 | 
			
		||||
			long old, new;
 | 
			
		||||
 | 
			
		||||
			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
 | 
			
		||||
			if (get_user(old, (long __user *)arg)) return -EFAULT;
 | 
			
		||||
			if (!capable(CAP_SYS_ADMIN))
 | 
			
		||||
				return -EACCES;
 | 
			
		||||
			if (get_user(old, (long __user *)arg))
 | 
			
		||||
				return -EFAULT;
 | 
			
		||||
			if ((result = udf_relocate_blocks(inode->i_sb,
 | 
			
		||||
					old, &new)) == 0)
 | 
			
		||||
							  old, &new)) == 0)
 | 
			
		||||
				result = put_user(new, (long __user *)arg);
 | 
			
		||||
 | 
			
		||||
			return result;
 | 
			
		||||
		}
 | 
			
		||||
		case UDF_GETEASIZE:
 | 
			
		||||
			result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
 | 
			
		||||
			break;
 | 
			
		||||
	case UDF_GETEASIZE:
 | 
			
		||||
		result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		case UDF_GETEABLOCK:
 | 
			
		||||
			result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
 | 
			
		||||
				UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
 | 
			
		||||
			break;
 | 
			
		||||
	case UDF_GETEABLOCK:
 | 
			
		||||
		result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
 | 
			
		||||
				      UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return result;
 | 
			
		||||
@@ -240,10 +237,9 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 | 
			
		||||
 * HISTORY
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
static int udf_release_file(struct inode * inode, struct file * filp)
 | 
			
		||||
static int udf_release_file(struct inode *inode, struct file *filp)
 | 
			
		||||
{
 | 
			
		||||
	if (filp->f_mode & FMODE_WRITE)
 | 
			
		||||
	{
 | 
			
		||||
	if (filp->f_mode & FMODE_WRITE) {
 | 
			
		||||
		lock_kernel();
 | 
			
		||||
		udf_discard_prealloc(inode);
 | 
			
		||||
		unlock_kernel();
 | 
			
		||||
@@ -252,18 +248,18 @@ static int udf_release_file(struct inode * inode, struct file * filp)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct file_operations udf_file_operations = {
 | 
			
		||||
	.read			= do_sync_read,
 | 
			
		||||
	.aio_read		= generic_file_aio_read,
 | 
			
		||||
	.ioctl			= udf_ioctl,
 | 
			
		||||
	.open			= generic_file_open,
 | 
			
		||||
	.mmap			= generic_file_mmap,
 | 
			
		||||
	.write			= do_sync_write,
 | 
			
		||||
	.aio_write		= udf_file_aio_write,
 | 
			
		||||
	.release		= udf_release_file,
 | 
			
		||||
	.fsync			= udf_fsync_file,
 | 
			
		||||
	.splice_read		= generic_file_splice_read,
 | 
			
		||||
	.read = do_sync_read,
 | 
			
		||||
	.aio_read = generic_file_aio_read,
 | 
			
		||||
	.ioctl = udf_ioctl,
 | 
			
		||||
	.open = generic_file_open,
 | 
			
		||||
	.mmap = generic_file_mmap,
 | 
			
		||||
	.write = do_sync_write,
 | 
			
		||||
	.aio_write = udf_file_aio_write,
 | 
			
		||||
	.release = udf_release_file,
 | 
			
		||||
	.fsync = udf_fsync_file,
 | 
			
		||||
	.splice_read = generic_file_splice_read,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const struct inode_operations udf_file_inode_operations = {
 | 
			
		||||
	.truncate		= udf_truncate,
 | 
			
		||||
	.truncate = udf_truncate,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ static int udf_fsync_inode(struct inode *, int);
 | 
			
		||||
 *	even pass file to fsync ?
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int udf_fsync_file(struct file * file, struct dentry *dentry, int datasync)
 | 
			
		||||
int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
 | 
			
		||||
{
 | 
			
		||||
	struct inode *inode = dentry->d_inode;
 | 
			
		||||
	return udf_fsync_inode(inode, datasync);
 | 
			
		||||
@@ -45,6 +45,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync)
 | 
			
		||||
	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
 | 
			
		||||
		return err;
 | 
			
		||||
 | 
			
		||||
	err |= udf_sync_inode (inode);
 | 
			
		||||
	err |= udf_sync_inode(inode);
 | 
			
		||||
	return err ? -EIO : 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@
 | 
			
		||||
#include "udf_i.h"
 | 
			
		||||
#include "udf_sb.h"
 | 
			
		||||
 | 
			
		||||
void udf_free_inode(struct inode * inode)
 | 
			
		||||
void udf_free_inode(struct inode *inode)
 | 
			
		||||
{
 | 
			
		||||
	struct super_block *sb = inode->i_sb;
 | 
			
		||||
	struct udf_sb_info *sbi = UDF_SB(sb);
 | 
			
		||||
@@ -46,10 +46,12 @@ void udf_free_inode(struct inode * inode)
 | 
			
		||||
	if (sbi->s_lvidbh) {
 | 
			
		||||
		if (S_ISDIR(inode->i_mode))
 | 
			
		||||
			UDF_SB_LVIDIU(sb)->numDirs =
 | 
			
		||||
				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
 | 
			
		||||
			    cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
 | 
			
		||||
					- 1);
 | 
			
		||||
		else
 | 
			
		||||
			UDF_SB_LVIDIU(sb)->numFiles =
 | 
			
		||||
				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
 | 
			
		||||
			    cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
 | 
			
		||||
					- 1);
 | 
			
		||||
 | 
			
		||||
		mark_buffer_dirty(sbi->s_lvidbh);
 | 
			
		||||
	}
 | 
			
		||||
@@ -58,18 +60,17 @@ void udf_free_inode(struct inode * inode)
 | 
			
		||||
	udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 | 
			
		||||
struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 | 
			
		||||
{
 | 
			
		||||
	struct super_block *sb = dir->i_sb;
 | 
			
		||||
	struct udf_sb_info *sbi = UDF_SB(sb);
 | 
			
		||||
	struct inode * inode;
 | 
			
		||||
	struct inode *inode;
 | 
			
		||||
	int block;
 | 
			
		||||
	uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum;
 | 
			
		||||
 | 
			
		||||
	inode = new_inode(sb);
 | 
			
		||||
 | 
			
		||||
	if (!inode)
 | 
			
		||||
	{
 | 
			
		||||
	if (!inode) {
 | 
			
		||||
		*err = -ENOMEM;
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
@@ -81,26 +82,30 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 | 
			
		||||
	UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
 | 
			
		||||
	UDF_I_STRAT4096(inode) = 0;
 | 
			
		||||
 | 
			
		||||
	block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
 | 
			
		||||
		start, err);
 | 
			
		||||
	if (*err)
 | 
			
		||||
	{
 | 
			
		||||
	block =
 | 
			
		||||
	    udf_new_block(dir->i_sb, NULL,
 | 
			
		||||
			  UDF_I_LOCATION(dir).partitionReferenceNum, start,
 | 
			
		||||
			  err);
 | 
			
		||||
	if (*err) {
 | 
			
		||||
		iput(inode);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mutex_lock(&sbi->s_alloc_mutex);
 | 
			
		||||
	if (UDF_SB_LVIDBH(sb))
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_SB_LVIDBH(sb)) {
 | 
			
		||||
		struct logicalVolHeaderDesc *lvhd;
 | 
			
		||||
		uint64_t uniqueID;
 | 
			
		||||
		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
 | 
			
		||||
		lvhd =
 | 
			
		||||
		    (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
 | 
			
		||||
						    logicalVolContentsUse);
 | 
			
		||||
		if (S_ISDIR(mode))
 | 
			
		||||
			UDF_SB_LVIDIU(sb)->numDirs =
 | 
			
		||||
				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
 | 
			
		||||
			    cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
 | 
			
		||||
					+ 1);
 | 
			
		||||
		else
 | 
			
		||||
			UDF_SB_LVIDIU(sb)->numFiles =
 | 
			
		||||
				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
 | 
			
		||||
			    cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
 | 
			
		||||
					+ 1);
 | 
			
		||||
		UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
 | 
			
		||||
		if (!(++uniqueID & 0x00000000FFFFFFFFUL))
 | 
			
		||||
			uniqueID += 16;
 | 
			
		||||
@@ -109,35 +114,34 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 | 
			
		||||
	}
 | 
			
		||||
	inode->i_mode = mode;
 | 
			
		||||
	inode->i_uid = current->fsuid;
 | 
			
		||||
	if (dir->i_mode & S_ISGID)
 | 
			
		||||
	{
 | 
			
		||||
	if (dir->i_mode & S_ISGID) {
 | 
			
		||||
		inode->i_gid = dir->i_gid;
 | 
			
		||||
		if (S_ISDIR(mode))
 | 
			
		||||
			mode |= S_ISGID;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	} else
 | 
			
		||||
		inode->i_gid = current->fsgid;
 | 
			
		||||
 | 
			
		||||
	UDF_I_LOCATION(inode).logicalBlockNum = block;
 | 
			
		||||
	UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
 | 
			
		||||
	UDF_I_LOCATION(inode).partitionReferenceNum =
 | 
			
		||||
	    UDF_I_LOCATION(dir).partitionReferenceNum;
 | 
			
		||||
	inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
 | 
			
		||||
	inode->i_blocks = 0;
 | 
			
		||||
	UDF_I_LENEATTR(inode) = 0;
 | 
			
		||||
	UDF_I_LENALLOC(inode) = 0;
 | 
			
		||||
	UDF_I_USE(inode) = 0;
 | 
			
		||||
	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE))
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
 | 
			
		||||
		UDF_I_EFE(inode) = 1;
 | 
			
		||||
		UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
 | 
			
		||||
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		UDF_I_DATA(inode) =
 | 
			
		||||
		    kzalloc(inode->i_sb->s_blocksize -
 | 
			
		||||
			    sizeof(struct extendedFileEntry), GFP_KERNEL);
 | 
			
		||||
	} else {
 | 
			
		||||
		UDF_I_EFE(inode) = 0;
 | 
			
		||||
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
 | 
			
		||||
		UDF_I_DATA(inode) =
 | 
			
		||||
		    kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
 | 
			
		||||
			    GFP_KERNEL);
 | 
			
		||||
	}
 | 
			
		||||
	if (!UDF_I_DATA(inode))
 | 
			
		||||
	{
 | 
			
		||||
	if (!UDF_I_DATA(inode)) {
 | 
			
		||||
		iput(inode);
 | 
			
		||||
		*err = -ENOMEM;
 | 
			
		||||
		mutex_unlock(&sbi->s_alloc_mutex);
 | 
			
		||||
@@ -150,13 +154,12 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
 | 
			
		||||
	else
 | 
			
		||||
		UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG;
 | 
			
		||||
	inode->i_mtime = inode->i_atime = inode->i_ctime =
 | 
			
		||||
		UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
 | 
			
		||||
	    UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
 | 
			
		||||
	insert_inode_hash(inode);
 | 
			
		||||
	mark_inode_dirty(inode);
 | 
			
		||||
	mutex_unlock(&sbi->s_alloc_mutex);
 | 
			
		||||
 | 
			
		||||
	if (DQUOT_ALLOC_INODE(inode))
 | 
			
		||||
	{
 | 
			
		||||
	if (DQUOT_ALLOC_INODE(inode)) {
 | 
			
		||||
		DQUOT_DROP(inode);
 | 
			
		||||
		inode->i_flags |= S_NOQUOTA;
 | 
			
		||||
		inode->i_nlink = 0;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1488
									
								
								fs/udf/inode.c
									
									
									
									
									
								
							
							
						
						
									
										1488
									
								
								fs/udf/inode.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -26,43 +26,38 @@
 | 
			
		||||
#include <linux/udf_fs.h>
 | 
			
		||||
#include "udf_sb.h"
 | 
			
		||||
 | 
			
		||||
unsigned int 
 | 
			
		||||
udf_get_last_session(struct super_block *sb)
 | 
			
		||||
unsigned int udf_get_last_session(struct super_block *sb)
 | 
			
		||||
{
 | 
			
		||||
	struct cdrom_multisession ms_info;
 | 
			
		||||
	unsigned int vol_desc_start;
 | 
			
		||||
	struct block_device *bdev = sb->s_bdev;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	vol_desc_start=0;
 | 
			
		||||
	ms_info.addr_format=CDROM_LBA;
 | 
			
		||||
	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
 | 
			
		||||
	vol_desc_start = 0;
 | 
			
		||||
	ms_info.addr_format = CDROM_LBA;
 | 
			
		||||
	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info);
 | 
			
		||||
 | 
			
		||||
#define WE_OBEY_THE_WRITTEN_STANDARDS 1
 | 
			
		||||
 | 
			
		||||
	if (i == 0)
 | 
			
		||||
	{
 | 
			
		||||
	if (i == 0) {
 | 
			
		||||
		udf_debug("XA disk: %s, vol_desc_start=%d\n",
 | 
			
		||||
			(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
 | 
			
		||||
			  (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
 | 
			
		||||
#if WE_OBEY_THE_WRITTEN_STANDARDS
 | 
			
		||||
		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
 | 
			
		||||
		if (ms_info.xa_flag)	/* necessary for a valid ms_info.addr */
 | 
			
		||||
#endif
 | 
			
		||||
			vol_desc_start = ms_info.addr.lba;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
	} else {
 | 
			
		||||
		udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
 | 
			
		||||
	}
 | 
			
		||||
	return vol_desc_start;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned long
 | 
			
		||||
udf_get_last_block(struct super_block *sb)
 | 
			
		||||
unsigned long udf_get_last_block(struct super_block *sb)
 | 
			
		||||
{
 | 
			
		||||
	struct block_device *bdev = sb->s_bdev;
 | 
			
		||||
	unsigned long lblock = 0;
 | 
			
		||||
 | 
			
		||||
	if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
 | 
			
		||||
	if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long)&lblock))
 | 
			
		||||
		lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
 | 
			
		||||
 | 
			
		||||
	if (lblock)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										172
									
								
								fs/udf/misc.c
									
									
									
									
									
								
							
							
						
						
									
										172
									
								
								fs/udf/misc.c
									
									
									
									
									
								
							@@ -29,8 +29,7 @@
 | 
			
		||||
#include "udf_i.h"
 | 
			
		||||
#include "udf_sb.h"
 | 
			
		||||
 | 
			
		||||
struct buffer_head *
 | 
			
		||||
udf_tgetblk(struct super_block *sb, int block)
 | 
			
		||||
struct buffer_head *udf_tgetblk(struct super_block *sb, int block)
 | 
			
		||||
{
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV))
 | 
			
		||||
		return sb_getblk(sb, udf_fixed_to_variable(block));
 | 
			
		||||
@@ -38,8 +37,7 @@ udf_tgetblk(struct super_block *sb, int block)
 | 
			
		||||
		return sb_getblk(sb, block);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct buffer_head *
 | 
			
		||||
udf_tread(struct super_block *sb, int block)
 | 
			
		||||
struct buffer_head *udf_tread(struct super_block *sb, int block)
 | 
			
		||||
{
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV))
 | 
			
		||||
		return sb_bread(sb, udf_fixed_to_variable(block));
 | 
			
		||||
@@ -47,9 +45,8 @@ udf_tread(struct super_block *sb, int block)
 | 
			
		||||
		return sb_bread(sb, block);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct genericFormat *
 | 
			
		||||
udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
 | 
			
		||||
	uint8_t loc)
 | 
			
		||||
struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 | 
			
		||||
					   uint32_t type, uint8_t loc)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *ea = NULL, *ad = NULL;
 | 
			
		||||
	int offset;
 | 
			
		||||
@@ -59,78 +56,76 @@ udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
 | 
			
		||||
	ea = UDF_I_DATA(inode);
 | 
			
		||||
	if (UDF_I_LENEATTR(inode))
 | 
			
		||||
		ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
	else {
 | 
			
		||||
		ad = ea;
 | 
			
		||||
		size += sizeof(struct extendedAttrHeaderDesc);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
 | 
			
		||||
		UDF_I_LENALLOC(inode);
 | 
			
		||||
	    UDF_I_LENALLOC(inode);
 | 
			
		||||
 | 
			
		||||
	/* TODO - Check for FreeEASpace */
 | 
			
		||||
 | 
			
		||||
	if (loc & 0x01 && offset >= size)
 | 
			
		||||
	{
 | 
			
		||||
	if (loc & 0x01 && offset >= size) {
 | 
			
		||||
		struct extendedAttrHeaderDesc *eahd;
 | 
			
		||||
		eahd = (struct extendedAttrHeaderDesc *)ea;
 | 
			
		||||
 | 
			
		||||
		if (UDF_I_LENALLOC(inode))
 | 
			
		||||
		{
 | 
			
		||||
		if (UDF_I_LENALLOC(inode)) {
 | 
			
		||||
			memmove(&ad[size], ad, UDF_I_LENALLOC(inode));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (UDF_I_LENEATTR(inode))
 | 
			
		||||
		{
 | 
			
		||||
		if (UDF_I_LENEATTR(inode)) {
 | 
			
		||||
			/* check checksum/crc */
 | 
			
		||||
			if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
 | 
			
		||||
				le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum)
 | 
			
		||||
			{
 | 
			
		||||
			if (le16_to_cpu(eahd->descTag.tagIdent) !=
 | 
			
		||||
			    TAG_IDENT_EAHD
 | 
			
		||||
			    || le32_to_cpu(eahd->descTag.tagLocation) !=
 | 
			
		||||
			    UDF_I_LOCATION(inode).logicalBlockNum) {
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
		} else {
 | 
			
		||||
			size -= sizeof(struct extendedAttrHeaderDesc);
 | 
			
		||||
			UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
 | 
			
		||||
			UDF_I_LENEATTR(inode) +=
 | 
			
		||||
			    sizeof(struct extendedAttrHeaderDesc);
 | 
			
		||||
			eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
 | 
			
		||||
			if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
 | 
			
		||||
				eahd->descTag.descVersion = cpu_to_le16(3);
 | 
			
		||||
			else
 | 
			
		||||
				eahd->descTag.descVersion = cpu_to_le16(2);
 | 
			
		||||
			eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
 | 
			
		||||
			eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
 | 
			
		||||
			eahd->descTag.tagSerialNum =
 | 
			
		||||
			    cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
 | 
			
		||||
			eahd->descTag.tagLocation =
 | 
			
		||||
			    cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
 | 
			
		||||
			eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
 | 
			
		||||
			eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		offset = UDF_I_LENEATTR(inode);
 | 
			
		||||
		if (type < 2048)
 | 
			
		||||
		{
 | 
			
		||||
			if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode))
 | 
			
		||||
			{
 | 
			
		||||
				uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - aal + size],
 | 
			
		||||
					&ea[aal], offset - aal);
 | 
			
		||||
		if (type < 2048) {
 | 
			
		||||
			if (le32_to_cpu(eahd->appAttrLocation) <
 | 
			
		||||
			    UDF_I_LENEATTR(inode)) {
 | 
			
		||||
				uint32_t aal =
 | 
			
		||||
				    le32_to_cpu(eahd->appAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - aal + size], &ea[aal],
 | 
			
		||||
					offset - aal);
 | 
			
		||||
				offset -= aal;
 | 
			
		||||
				eahd->appAttrLocation = cpu_to_le32(aal + size);
 | 
			
		||||
			}
 | 
			
		||||
			if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode))
 | 
			
		||||
			{
 | 
			
		||||
				uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - ial + size],
 | 
			
		||||
					&ea[ial], offset - ial);
 | 
			
		||||
			if (le32_to_cpu(eahd->impAttrLocation) <
 | 
			
		||||
			    UDF_I_LENEATTR(inode)) {
 | 
			
		||||
				uint32_t ial =
 | 
			
		||||
				    le32_to_cpu(eahd->impAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - ial + size], &ea[ial],
 | 
			
		||||
					offset - ial);
 | 
			
		||||
				offset -= ial;
 | 
			
		||||
				eahd->impAttrLocation = cpu_to_le32(ial + size);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if (type < 65536)
 | 
			
		||||
		{
 | 
			
		||||
			if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode))
 | 
			
		||||
			{
 | 
			
		||||
				uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - aal + size],
 | 
			
		||||
					&ea[aal], offset - aal);
 | 
			
		||||
		} else if (type < 65536) {
 | 
			
		||||
			if (le32_to_cpu(eahd->appAttrLocation) <
 | 
			
		||||
			    UDF_I_LENEATTR(inode)) {
 | 
			
		||||
				uint32_t aal =
 | 
			
		||||
				    le32_to_cpu(eahd->appAttrLocation);
 | 
			
		||||
				memmove(&ea[offset - aal + size], &ea[aal],
 | 
			
		||||
					offset - aal);
 | 
			
		||||
				offset -= aal;
 | 
			
		||||
				eahd->appAttrLocation = cpu_to_le32(aal + size);
 | 
			
		||||
			}
 | 
			
		||||
@@ -138,22 +133,23 @@ udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
 | 
			
		||||
		/* rewrite CRC + checksum of eahd */
 | 
			
		||||
		crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
 | 
			
		||||
		eahd->descTag.descCRCLength = cpu_to_le16(crclen);
 | 
			
		||||
		eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0));
 | 
			
		||||
		eahd->descTag.descCRC =
 | 
			
		||||
		    cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0));
 | 
			
		||||
		eahd->descTag.tagChecksum = 0;
 | 
			
		||||
		for (i=0; i<16; i++)
 | 
			
		||||
		for (i = 0; i < 16; i++)
 | 
			
		||||
			if (i != 4)
 | 
			
		||||
				eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
 | 
			
		||||
				eahd->descTag.tagChecksum +=
 | 
			
		||||
				    ((uint8_t *) & (eahd->descTag))[i];
 | 
			
		||||
		UDF_I_LENEATTR(inode) += size;
 | 
			
		||||
		return (struct genericFormat *)&ea[offset];
 | 
			
		||||
	}
 | 
			
		||||
	if (loc & 0x02)
 | 
			
		||||
	{
 | 
			
		||||
	if (loc & 0x02) {
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct genericFormat *
 | 
			
		||||
udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
 | 
			
		||||
struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
 | 
			
		||||
					   uint8_t subtype)
 | 
			
		||||
{
 | 
			
		||||
	struct genericFormat *gaf;
 | 
			
		||||
	uint8_t *ea = NULL;
 | 
			
		||||
@@ -161,18 +157,17 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
 | 
			
		||||
 | 
			
		||||
	ea = UDF_I_DATA(inode);
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_LENEATTR(inode))
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_I_LENEATTR(inode)) {
 | 
			
		||||
		struct extendedAttrHeaderDesc *eahd;
 | 
			
		||||
		eahd = (struct extendedAttrHeaderDesc *)ea;
 | 
			
		||||
 | 
			
		||||
		/* check checksum/crc */
 | 
			
		||||
		if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
 | 
			
		||||
			le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum)
 | 
			
		||||
		{
 | 
			
		||||
		    le32_to_cpu(eahd->descTag.tagLocation) !=
 | 
			
		||||
		    UDF_I_LOCATION(inode).logicalBlockNum) {
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
		if (type < 2048)
 | 
			
		||||
			offset = sizeof(struct extendedAttrHeaderDesc);
 | 
			
		||||
		else if (type < 65536)
 | 
			
		||||
@@ -180,10 +175,10 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
 | 
			
		||||
		else
 | 
			
		||||
			offset = le32_to_cpu(eahd->appAttrLocation);
 | 
			
		||||
 | 
			
		||||
		while (offset < UDF_I_LENEATTR(inode))
 | 
			
		||||
		{
 | 
			
		||||
		while (offset < UDF_I_LENEATTR(inode)) {
 | 
			
		||||
			gaf = (struct genericFormat *)&ea[offset];
 | 
			
		||||
			if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
 | 
			
		||||
			if (le32_to_cpu(gaf->attrType) == type
 | 
			
		||||
			    && gaf->attrSubtype == subtype)
 | 
			
		||||
				return gaf;
 | 
			
		||||
			else
 | 
			
		||||
				offset += le32_to_cpu(gaf->attrLength);
 | 
			
		||||
@@ -202,8 +197,8 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
 | 
			
		||||
 *	July 1, 1997 - Andrew E. Mileski
 | 
			
		||||
 *	Written, tested, and released.
 | 
			
		||||
 */
 | 
			
		||||
struct buffer_head *
 | 
			
		||||
udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint16_t *ident)
 | 
			
		||||
struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 | 
			
		||||
				    uint32_t location, uint16_t * ident)
 | 
			
		||||
{
 | 
			
		||||
	tag *tag_p;
 | 
			
		||||
	struct buffer_head *bh = NULL;
 | 
			
		||||
@@ -215,29 +210,29 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	bh = udf_tread(sb, block + UDF_SB_SESSION(sb));
 | 
			
		||||
	if (!bh)
 | 
			
		||||
	{
 | 
			
		||||
		udf_debug("block=%d, location=%d: read failed\n", block + UDF_SB_SESSION(sb), location);
 | 
			
		||||
	if (!bh) {
 | 
			
		||||
		udf_debug("block=%d, location=%d: read failed\n",
 | 
			
		||||
			  block + UDF_SB_SESSION(sb), location);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tag_p = (tag *)(bh->b_data);
 | 
			
		||||
	tag_p = (tag *) (bh->b_data);
 | 
			
		||||
 | 
			
		||||
	*ident = le16_to_cpu(tag_p->tagIdent);
 | 
			
		||||
 | 
			
		||||
	if ( location != le32_to_cpu(tag_p->tagLocation) )
 | 
			
		||||
	{
 | 
			
		||||
	if (location != le32_to_cpu(tag_p->tagLocation)) {
 | 
			
		||||
		udf_debug("location mismatch block %u, tag %u != %u\n",
 | 
			
		||||
			block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
 | 
			
		||||
			  block + UDF_SB_SESSION(sb),
 | 
			
		||||
			  le32_to_cpu(tag_p->tagLocation), location);
 | 
			
		||||
		goto error_out;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/* Verify the tag checksum */
 | 
			
		||||
	checksum = 0U;
 | 
			
		||||
	for (i = 0; i < 4; i++)
 | 
			
		||||
		checksum += (uint8_t)(bh->b_data[i]);
 | 
			
		||||
		checksum += (uint8_t) (bh->b_data[i]);
 | 
			
		||||
	for (i = 5; i < 16; i++)
 | 
			
		||||
		checksum += (uint8_t)(bh->b_data[i]);
 | 
			
		||||
		checksum += (uint8_t) (bh->b_data[i]);
 | 
			
		||||
	if (checksum != tag_p->tagChecksum) {
 | 
			
		||||
		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
 | 
			
		||||
		goto error_out;
 | 
			
		||||
@@ -245,38 +240,39 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
 | 
			
		||||
 | 
			
		||||
	/* Verify the tag version */
 | 
			
		||||
	if (le16_to_cpu(tag_p->descVersion) != 0x0002U &&
 | 
			
		||||
		le16_to_cpu(tag_p->descVersion) != 0x0003U)
 | 
			
		||||
	{
 | 
			
		||||
	    le16_to_cpu(tag_p->descVersion) != 0x0003U) {
 | 
			
		||||
		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
 | 
			
		||||
			le16_to_cpu(tag_p->descVersion), block);
 | 
			
		||||
			  le16_to_cpu(tag_p->descVersion), block);
 | 
			
		||||
		goto error_out;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Verify the descriptor CRC */
 | 
			
		||||
	if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
 | 
			
		||||
		le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
 | 
			
		||||
			le16_to_cpu(tag_p->descCRCLength), 0))
 | 
			
		||||
	{
 | 
			
		||||
	    le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
 | 
			
		||||
						   le16_to_cpu(tag_p->
 | 
			
		||||
							       descCRCLength),
 | 
			
		||||
						   0)) {
 | 
			
		||||
		return bh;
 | 
			
		||||
	}
 | 
			
		||||
	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
 | 
			
		||||
		block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
 | 
			
		||||
		  block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
 | 
			
		||||
		  le16_to_cpu(tag_p->descCRCLength));
 | 
			
		||||
 | 
			
		||||
error_out:
 | 
			
		||||
      error_out:
 | 
			
		||||
	brelse(bh);
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct buffer_head *
 | 
			
		||||
udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, uint32_t offset, uint16_t *ident)
 | 
			
		||||
struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
 | 
			
		||||
				     uint32_t offset, uint16_t * ident)
 | 
			
		||||
{
 | 
			
		||||
	return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset),
 | 
			
		||||
		loc.logicalBlockNum + offset, ident);
 | 
			
		||||
			       loc.logicalBlockNum + offset, ident);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void udf_update_tag(char *data, int length)
 | 
			
		||||
{
 | 
			
		||||
	tag *tptr = (tag *)data;
 | 
			
		||||
	tag *tptr = (tag *) data;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	length -= sizeof(tag);
 | 
			
		||||
@@ -285,15 +281,15 @@ void udf_update_tag(char *data, int length)
 | 
			
		||||
	tptr->descCRCLength = cpu_to_le16(length);
 | 
			
		||||
	tptr->descCRC = cpu_to_le16(udf_crc(data + sizeof(tag), length, 0));
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<16; i++)
 | 
			
		||||
	for (i = 0; i < 16; i++)
 | 
			
		||||
		if (i != 4)
 | 
			
		||||
			tptr->tagChecksum += (uint8_t)(data[i]);
 | 
			
		||||
			tptr->tagChecksum += (uint8_t) (data[i]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
 | 
			
		||||
	uint32_t loc, int length)
 | 
			
		||||
		 uint32_t loc, int length)
 | 
			
		||||
{
 | 
			
		||||
	tag *tptr = (tag *)data;
 | 
			
		||||
	tag *tptr = (tag *) data;
 | 
			
		||||
	tptr->tagIdent = cpu_to_le16(ident);
 | 
			
		||||
	tptr->descVersion = cpu_to_le16(version);
 | 
			
		||||
	tptr->tagSerialNum = cpu_to_le16(snum);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										720
									
								
								fs/udf/namei.c
									
									
									
									
									
								
							
							
						
						
									
										720
									
								
								fs/udf/namei.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -65,153 +65,140 @@
 | 
			
		||||
#define IS_DF_HARD_WRITE_PROTECT	0x01
 | 
			
		||||
#define IS_DF_SOFT_WRITE_PROTECT	0x02
 | 
			
		||||
 | 
			
		||||
struct UDFIdentSuffix
 | 
			
		||||
{
 | 
			
		||||
	__le16		UDFRevision;
 | 
			
		||||
	uint8_t		OSClass;
 | 
			
		||||
	uint8_t		OSIdentifier;
 | 
			
		||||
	uint8_t		reserved[4];
 | 
			
		||||
struct UDFIdentSuffix {
 | 
			
		||||
	__le16 UDFRevision;
 | 
			
		||||
	uint8_t OSClass;
 | 
			
		||||
	uint8_t OSIdentifier;
 | 
			
		||||
	uint8_t reserved[4];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
struct impIdentSuffix
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		OSClass;
 | 
			
		||||
	uint8_t		OSIdentifier;
 | 
			
		||||
	uint8_t		reserved[6];
 | 
			
		||||
struct impIdentSuffix {
 | 
			
		||||
	uint8_t OSClass;
 | 
			
		||||
	uint8_t OSIdentifier;
 | 
			
		||||
	uint8_t reserved[6];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
struct appIdentSuffix
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		impUse[8];
 | 
			
		||||
struct appIdentSuffix {
 | 
			
		||||
	uint8_t impUse[8];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
 | 
			
		||||
/* Implementation Use (UDF 2.50 2.2.6.4) */
 | 
			
		||||
struct logicalVolIntegrityDescImpUse
 | 
			
		||||
{
 | 
			
		||||
	regid		impIdent;
 | 
			
		||||
	__le32		numFiles;
 | 
			
		||||
	__le32		numDirs;
 | 
			
		||||
	__le16		minUDFReadRev;
 | 
			
		||||
	__le16		minUDFWriteRev;
 | 
			
		||||
	__le16		maxUDFWriteRev;
 | 
			
		||||
	uint8_t		impUse[0];
 | 
			
		||||
struct logicalVolIntegrityDescImpUse {
 | 
			
		||||
	regid impIdent;
 | 
			
		||||
	__le32 numFiles;
 | 
			
		||||
	__le32 numDirs;
 | 
			
		||||
	__le16 minUDFReadRev;
 | 
			
		||||
	__le16 minUDFWriteRev;
 | 
			
		||||
	__le16 maxUDFWriteRev;
 | 
			
		||||
	uint8_t impUse[0];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
 | 
			
		||||
/* Implementation Use (UDF 2.50 2.2.7.2) */
 | 
			
		||||
struct impUseVolDescImpUse
 | 
			
		||||
{
 | 
			
		||||
	charspec	LVICharset;
 | 
			
		||||
	dstring		logicalVolIdent[128];
 | 
			
		||||
	dstring		LVInfo1[36];
 | 
			
		||||
	dstring		LVInfo2[36];
 | 
			
		||||
	dstring		LVInfo3[36];
 | 
			
		||||
	regid		impIdent;
 | 
			
		||||
	uint8_t		impUse[128];
 | 
			
		||||
struct impUseVolDescImpUse {
 | 
			
		||||
	charspec LVICharset;
 | 
			
		||||
	dstring logicalVolIdent[128];
 | 
			
		||||
	dstring LVInfo1[36];
 | 
			
		||||
	dstring LVInfo2[36];
 | 
			
		||||
	dstring LVInfo3[36];
 | 
			
		||||
	regid impIdent;
 | 
			
		||||
	uint8_t impUse[128];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
struct udfPartitionMap2
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		partitionMapType;
 | 
			
		||||
	uint8_t		partitionMapLength;
 | 
			
		||||
	uint8_t		reserved1[2];
 | 
			
		||||
	regid		partIdent;
 | 
			
		||||
	__le16		volSeqNum;
 | 
			
		||||
	__le16		partitionNum;
 | 
			
		||||
struct udfPartitionMap2 {
 | 
			
		||||
	uint8_t partitionMapType;
 | 
			
		||||
	uint8_t partitionMapLength;
 | 
			
		||||
	uint8_t reserved1[2];
 | 
			
		||||
	regid partIdent;
 | 
			
		||||
	__le16 volSeqNum;
 | 
			
		||||
	__le16 partitionNum;
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Virtual Partition Map (UDF 2.50 2.2.8) */
 | 
			
		||||
struct virtualPartitionMap
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		partitionMapType;
 | 
			
		||||
	uint8_t		partitionMapLength;
 | 
			
		||||
	uint8_t		reserved1[2];
 | 
			
		||||
	regid		partIdent;
 | 
			
		||||
	__le16		volSeqNum;
 | 
			
		||||
	__le16		partitionNum;
 | 
			
		||||
	uint8_t		reserved2[24];
 | 
			
		||||
struct virtualPartitionMap {
 | 
			
		||||
	uint8_t partitionMapType;
 | 
			
		||||
	uint8_t partitionMapLength;
 | 
			
		||||
	uint8_t reserved1[2];
 | 
			
		||||
	regid partIdent;
 | 
			
		||||
	__le16 volSeqNum;
 | 
			
		||||
	__le16 partitionNum;
 | 
			
		||||
	uint8_t reserved2[24];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Sparable Partition Map (UDF 2.50 2.2.9) */
 | 
			
		||||
struct sparablePartitionMap
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		partitionMapType;
 | 
			
		||||
	uint8_t		partitionMapLength;
 | 
			
		||||
	uint8_t		reserved1[2];
 | 
			
		||||
	regid		partIdent;
 | 
			
		||||
	__le16		volSeqNum;
 | 
			
		||||
	__le16		partitionNum;
 | 
			
		||||
	__le16		packetLength;
 | 
			
		||||
	uint8_t		numSparingTables;
 | 
			
		||||
	uint8_t		reserved2[1];
 | 
			
		||||
	__le32		sizeSparingTable;
 | 
			
		||||
	__le32		locSparingTable[4];
 | 
			
		||||
struct sparablePartitionMap {
 | 
			
		||||
	uint8_t partitionMapType;
 | 
			
		||||
	uint8_t partitionMapLength;
 | 
			
		||||
	uint8_t reserved1[2];
 | 
			
		||||
	regid partIdent;
 | 
			
		||||
	__le16 volSeqNum;
 | 
			
		||||
	__le16 partitionNum;
 | 
			
		||||
	__le16 packetLength;
 | 
			
		||||
	uint8_t numSparingTables;
 | 
			
		||||
	uint8_t reserved2[1];
 | 
			
		||||
	__le32 sizeSparingTable;
 | 
			
		||||
	__le32 locSparingTable[4];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
 | 
			
		||||
struct metadataPartitionMap
 | 
			
		||||
{
 | 
			
		||||
	uint8_t		partitionMapType;
 | 
			
		||||
	uint8_t		partitionMapLength;
 | 
			
		||||
	uint8_t		reserved1[2];
 | 
			
		||||
	regid		partIdent;
 | 
			
		||||
	__le16		volSeqNum;
 | 
			
		||||
	__le16		partitionNum;
 | 
			
		||||
	__le32		metadataFileLoc;
 | 
			
		||||
	__le32		metadataMirrorFileLoc;
 | 
			
		||||
	__le32		metadataBitmapFileLoc;
 | 
			
		||||
	__le32		allocUnitSize;
 | 
			
		||||
	__le16		alignUnitSize;
 | 
			
		||||
	uint8_t		flags;
 | 
			
		||||
	uint8_t		reserved2[5];
 | 
			
		||||
struct metadataPartitionMap {
 | 
			
		||||
	uint8_t partitionMapType;
 | 
			
		||||
	uint8_t partitionMapLength;
 | 
			
		||||
	uint8_t reserved1[2];
 | 
			
		||||
	regid partIdent;
 | 
			
		||||
	__le16 volSeqNum;
 | 
			
		||||
	__le16 partitionNum;
 | 
			
		||||
	__le32 metadataFileLoc;
 | 
			
		||||
	__le32 metadataMirrorFileLoc;
 | 
			
		||||
	__le32 metadataBitmapFileLoc;
 | 
			
		||||
	__le32 allocUnitSize;
 | 
			
		||||
	__le16 alignUnitSize;
 | 
			
		||||
	uint8_t flags;
 | 
			
		||||
	uint8_t reserved2[5];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Virtual Allocation Table (UDF 1.5 2.2.10) */
 | 
			
		||||
struct virtualAllocationTable15
 | 
			
		||||
{
 | 
			
		||||
	__le32		VirtualSector[0];
 | 
			
		||||
	regid		vatIdent;
 | 
			
		||||
	__le32		previousVATICBLoc;
 | 
			
		||||
} __attribute__ ((packed));  
 | 
			
		||||
struct virtualAllocationTable15 {
 | 
			
		||||
	__le32 VirtualSector[0];
 | 
			
		||||
	regid vatIdent;
 | 
			
		||||
	__le32 previousVATICBLoc;
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
#define ICBTAG_FILE_TYPE_VAT15		0x00U
 | 
			
		||||
 | 
			
		||||
/* Virtual Allocation Table (UDF 2.50 2.2.11) */
 | 
			
		||||
struct virtualAllocationTable20
 | 
			
		||||
{
 | 
			
		||||
	__le16		lengthHeader;
 | 
			
		||||
	__le16		lengthImpUse;
 | 
			
		||||
	dstring		logicalVolIdent[128];
 | 
			
		||||
	__le32		previousVATICBLoc;
 | 
			
		||||
	__le32		numFiles;
 | 
			
		||||
	__le32		numDirs;
 | 
			
		||||
	__le16		minReadRevision;
 | 
			
		||||
	__le16		minWriteRevision;
 | 
			
		||||
	__le16		maxWriteRevision;
 | 
			
		||||
	__le16		reserved;
 | 
			
		||||
	uint8_t		impUse[0];
 | 
			
		||||
	__le32		vatEntry[0];
 | 
			
		||||
struct virtualAllocationTable20 {
 | 
			
		||||
	__le16 lengthHeader;
 | 
			
		||||
	__le16 lengthImpUse;
 | 
			
		||||
	dstring logicalVolIdent[128];
 | 
			
		||||
	__le32 previousVATICBLoc;
 | 
			
		||||
	__le32 numFiles;
 | 
			
		||||
	__le32 numDirs;
 | 
			
		||||
	__le16 minReadRevision;
 | 
			
		||||
	__le16 minWriteRevision;
 | 
			
		||||
	__le16 maxWriteRevision;
 | 
			
		||||
	__le16 reserved;
 | 
			
		||||
	uint8_t impUse[0];
 | 
			
		||||
	__le32 vatEntry[0];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
#define ICBTAG_FILE_TYPE_VAT20		0xF8U
 | 
			
		||||
 | 
			
		||||
/* Sparing Table (UDF 2.50 2.2.12) */
 | 
			
		||||
struct sparingEntry
 | 
			
		||||
{
 | 
			
		||||
	__le32		origLocation;
 | 
			
		||||
	__le32		mappedLocation;
 | 
			
		||||
struct sparingEntry {
 | 
			
		||||
	__le32 origLocation;
 | 
			
		||||
	__le32 mappedLocation;
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
struct sparingTable
 | 
			
		||||
{
 | 
			
		||||
	tag 		descTag;
 | 
			
		||||
	regid		sparingIdent;
 | 
			
		||||
	__le16		reallocationTableLen;
 | 
			
		||||
	__le16		reserved;
 | 
			
		||||
	__le32		sequenceNum;
 | 
			
		||||
struct sparingTable {
 | 
			
		||||
	tag descTag;
 | 
			
		||||
	regid sparingIdent;
 | 
			
		||||
	__le16 reallocationTableLen;
 | 
			
		||||
	__le16 reserved;
 | 
			
		||||
	__le32 sequenceNum;
 | 
			
		||||
	struct sparingEntry
 | 
			
		||||
			mapEntry[0];
 | 
			
		||||
	 mapEntry[0];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
 | 
			
		||||
@@ -220,10 +207,9 @@ struct sparingTable
 | 
			
		||||
#define ICBTAG_FILE_TYPE_BITMAP		0xFC
 | 
			
		||||
 | 
			
		||||
/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
 | 
			
		||||
struct allocDescImpUse
 | 
			
		||||
{
 | 
			
		||||
	__le16		flags;
 | 
			
		||||
	uint8_t		impUse[4];
 | 
			
		||||
struct allocDescImpUse {
 | 
			
		||||
	__le16 flags;
 | 
			
		||||
	uint8_t impUse[4];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
#define AD_IU_EXT_ERASED		0x0001
 | 
			
		||||
@@ -233,27 +219,24 @@ struct allocDescImpUse
 | 
			
		||||
 | 
			
		||||
/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
 | 
			
		||||
/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
 | 
			
		||||
struct freeEaSpace
 | 
			
		||||
{
 | 
			
		||||
	__le16		headerChecksum;
 | 
			
		||||
	uint8_t		freeEASpace[0];
 | 
			
		||||
struct freeEaSpace {
 | 
			
		||||
	__le16 headerChecksum;
 | 
			
		||||
	uint8_t freeEASpace[0];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
 | 
			
		||||
struct DVDCopyrightImpUse 
 | 
			
		||||
{
 | 
			
		||||
	__le16		headerChecksum;
 | 
			
		||||
	uint8_t		CGMSInfo;
 | 
			
		||||
	uint8_t		dataType;
 | 
			
		||||
	uint8_t		protectionSystemInfo[4];
 | 
			
		||||
struct DVDCopyrightImpUse {
 | 
			
		||||
	__le16 headerChecksum;
 | 
			
		||||
	uint8_t CGMSInfo;
 | 
			
		||||
	uint8_t dataType;
 | 
			
		||||
	uint8_t protectionSystemInfo[4];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
 | 
			
		||||
/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
 | 
			
		||||
struct freeAppEASpace
 | 
			
		||||
{
 | 
			
		||||
	__le16		headerChecksum;
 | 
			
		||||
	uint8_t		freeEASpace[0];
 | 
			
		||||
struct freeAppEASpace {
 | 
			
		||||
	__le16 headerChecksum;
 | 
			
		||||
	uint8_t freeEASpace[0];
 | 
			
		||||
} __attribute__ ((packed));
 | 
			
		||||
 | 
			
		||||
/* UDF Defined System Stream (UDF 2.50 3.3.7) */
 | 
			
		||||
@@ -293,4 +276,4 @@ struct freeAppEASpace
 | 
			
		||||
#define UDF_OS_ID_BEOS			0x00U
 | 
			
		||||
#define UDF_OS_ID_WINCE			0x00U
 | 
			
		||||
 | 
			
		||||
#endif /* _OSTA_UDF_H */
 | 
			
		||||
#endif				/* _OSTA_UDF_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -28,106 +28,120 @@
 | 
			
		||||
#include <linux/slab.h>
 | 
			
		||||
#include <linux/buffer_head.h>
 | 
			
		||||
 | 
			
		||||
inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset)
 | 
			
		||||
inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 | 
			
		||||
			       uint16_t partition, uint32_t offset)
 | 
			
		||||
{
 | 
			
		||||
	if (partition >= UDF_SB_NUMPARTS(sb))
 | 
			
		||||
	{
 | 
			
		||||
		udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
 | 
			
		||||
			block, partition, offset);
 | 
			
		||||
	if (partition >= UDF_SB_NUMPARTS(sb)) {
 | 
			
		||||
		udf_debug
 | 
			
		||||
		    ("block=%d, partition=%d, offset=%d: invalid partition\n",
 | 
			
		||||
		     block, partition, offset);
 | 
			
		||||
		return 0xFFFFFFFF;
 | 
			
		||||
	}
 | 
			
		||||
	if (UDF_SB_PARTFUNC(sb, partition))
 | 
			
		||||
		return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
 | 
			
		||||
		return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition,
 | 
			
		||||
						       offset);
 | 
			
		||||
	else
 | 
			
		||||
		return UDF_SB_PARTROOT(sb, partition) + block + offset;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset)
 | 
			
		||||
uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
 | 
			
		||||
			       uint16_t partition, uint32_t offset)
 | 
			
		||||
{
 | 
			
		||||
	struct buffer_head *bh = NULL;
 | 
			
		||||
	uint32_t newblock;
 | 
			
		||||
	uint32_t index;
 | 
			
		||||
	uint32_t loc;
 | 
			
		||||
 | 
			
		||||
	index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
 | 
			
		||||
	index =
 | 
			
		||||
	    (sb->s_blocksize -
 | 
			
		||||
	     UDF_SB_TYPEVIRT(sb, partition).s_start_offset) / sizeof(uint32_t);
 | 
			
		||||
 | 
			
		||||
	if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries)
 | 
			
		||||
	{
 | 
			
		||||
		udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
 | 
			
		||||
			block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
 | 
			
		||||
	if (block > UDF_SB_TYPEVIRT(sb, partition).s_num_entries) {
 | 
			
		||||
		udf_debug
 | 
			
		||||
		    ("Trying to access block beyond end of VAT (%d max %d)\n",
 | 
			
		||||
		     block, UDF_SB_TYPEVIRT(sb, partition).s_num_entries);
 | 
			
		||||
		return 0xFFFFFFFF;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (block >= index)
 | 
			
		||||
	{
 | 
			
		||||
	if (block >= index) {
 | 
			
		||||
		block -= index;
 | 
			
		||||
		newblock = 1 + (block / (sb->s_blocksize / sizeof(uint32_t)));
 | 
			
		||||
		index = block % (sb->s_blocksize / sizeof(uint32_t));
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
	} else {
 | 
			
		||||
		newblock = 0;
 | 
			
		||||
		index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
 | 
			
		||||
		index =
 | 
			
		||||
		    UDF_SB_TYPEVIRT(sb,
 | 
			
		||||
				    partition).s_start_offset /
 | 
			
		||||
		    sizeof(uint32_t) + block;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	loc = udf_block_map(UDF_SB_VAT(sb), newblock);
 | 
			
		||||
 | 
			
		||||
	if (!(bh = sb_bread(sb, loc)))
 | 
			
		||||
	{
 | 
			
		||||
	if (!(bh = sb_bread(sb, loc))) {
 | 
			
		||||
		udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
 | 
			
		||||
			sb, block, partition, loc, index);
 | 
			
		||||
			  sb, block, partition, loc, index);
 | 
			
		||||
		return 0xFFFFFFFF;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	loc = le32_to_cpu(((__le32 *)bh->b_data)[index]);
 | 
			
		||||
	loc = le32_to_cpu(((__le32 *) bh->b_data)[index]);
 | 
			
		||||
 | 
			
		||||
	brelse(bh);
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition)
 | 
			
		||||
	{
 | 
			
		||||
	if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) {
 | 
			
		||||
		udf_debug("recursive call to udf_get_pblock!\n");
 | 
			
		||||
		return 0xFFFFFFFF;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return udf_get_pblock(sb, loc, UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, offset);
 | 
			
		||||
	return udf_get_pblock(sb, loc,
 | 
			
		||||
			      UDF_I_LOCATION(UDF_SB_VAT(sb)).
 | 
			
		||||
			      partitionReferenceNum, offset);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline uint32_t udf_get_pblock_virt20(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset)
 | 
			
		||||
inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
 | 
			
		||||
				      uint16_t partition, uint32_t offset)
 | 
			
		||||
{
 | 
			
		||||
	return udf_get_pblock_virt15(sb, block, partition, offset);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t udf_get_pblock_spar15(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset)
 | 
			
		||||
uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
 | 
			
		||||
			       uint16_t partition, uint32_t offset)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	struct sparingTable *st = NULL;
 | 
			
		||||
	uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
 | 
			
		||||
	uint32_t packet =
 | 
			
		||||
	    (block + offset) & ~(UDF_SB_TYPESPAR(sb, partition).s_packet_len -
 | 
			
		||||
				 1);
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<4; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL)
 | 
			
		||||
		{
 | 
			
		||||
			st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
 | 
			
		||||
	for (i = 0; i < 4; i++) {
 | 
			
		||||
		if (UDF_SB_TYPESPAR(sb, partition).s_spar_map[i] != NULL) {
 | 
			
		||||
			st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,
 | 
			
		||||
								    partition).
 | 
			
		||||
			    s_spar_map[i]->b_data;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (st)
 | 
			
		||||
	{
 | 
			
		||||
		for (i=0; i<le16_to_cpu(st->reallocationTableLen); i++)
 | 
			
		||||
		{
 | 
			
		||||
			if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0)
 | 
			
		||||
	if (st) {
 | 
			
		||||
		for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) {
 | 
			
		||||
			if (le32_to_cpu(st->mapEntry[i].origLocation) >=
 | 
			
		||||
			    0xFFFFFFF0)
 | 
			
		||||
				break;
 | 
			
		||||
			else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet)
 | 
			
		||||
			{
 | 
			
		||||
				return le32_to_cpu(st->mapEntry[i].mappedLocation) +
 | 
			
		||||
					((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
 | 
			
		||||
			}
 | 
			
		||||
			else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet)
 | 
			
		||||
			else if (le32_to_cpu(st->mapEntry[i].origLocation) ==
 | 
			
		||||
				 packet) {
 | 
			
		||||
				return le32_to_cpu(st->mapEntry[i].
 | 
			
		||||
						   mappedLocation) + ((block +
 | 
			
		||||
								       offset) &
 | 
			
		||||
								      (UDF_SB_TYPESPAR
 | 
			
		||||
								       (sb,
 | 
			
		||||
									partition).
 | 
			
		||||
								       s_packet_len
 | 
			
		||||
								       - 1));
 | 
			
		||||
			} else if (le32_to_cpu(st->mapEntry[i].origLocation) >
 | 
			
		||||
				   packet)
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return UDF_SB_PARTROOT(sb,partition) + block + offset;
 | 
			
		||||
	return UDF_SB_PARTROOT(sb, partition) + block + offset;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 | 
			
		||||
@@ -138,19 +152,21 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 | 
			
		||||
	uint32_t packet;
 | 
			
		||||
	int i, j, k, l;
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (old_block > UDF_SB_PARTROOT(sb,i) &&
 | 
			
		||||
		    old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i))
 | 
			
		||||
	for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
 | 
			
		||||
		if (old_block > UDF_SB_PARTROOT(sb, i) &&
 | 
			
		||||
		    old_block < UDF_SB_PARTROOT(sb, i) + UDF_SB_PARTLEN(sb, i))
 | 
			
		||||
		{
 | 
			
		||||
			sdata = &UDF_SB_TYPESPAR(sb,i);
 | 
			
		||||
			packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
 | 
			
		||||
			sdata = &UDF_SB_TYPESPAR(sb, i);
 | 
			
		||||
			packet =
 | 
			
		||||
			    (old_block -
 | 
			
		||||
			     UDF_SB_PARTROOT(sb,
 | 
			
		||||
					     i)) & ~(sdata->s_packet_len - 1);
 | 
			
		||||
 | 
			
		||||
			for (j=0; j<4; j++)
 | 
			
		||||
			{
 | 
			
		||||
				if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL)
 | 
			
		||||
				{
 | 
			
		||||
					st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
 | 
			
		||||
			for (j = 0; j < 4; j++) {
 | 
			
		||||
				if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] !=
 | 
			
		||||
				    NULL) {
 | 
			
		||||
					st = (struct sparingTable *)sdata->
 | 
			
		||||
					    s_spar_map[j]->b_data;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@@ -158,60 +174,123 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 | 
			
		||||
			if (!st)
 | 
			
		||||
				return 1;
 | 
			
		||||
 | 
			
		||||
			for (k=0; k<le16_to_cpu(st->reallocationTableLen); k++)
 | 
			
		||||
			{
 | 
			
		||||
				if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF)
 | 
			
		||||
				{
 | 
			
		||||
					for (; j<4; j++)
 | 
			
		||||
					{
 | 
			
		||||
						if (sdata->s_spar_map[j])
 | 
			
		||||
						{
 | 
			
		||||
							st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
 | 
			
		||||
							st->mapEntry[k].origLocation = cpu_to_le32(packet);
 | 
			
		||||
							udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
 | 
			
		||||
							mark_buffer_dirty(sdata->s_spar_map[j]);
 | 
			
		||||
			for (k = 0; k < le16_to_cpu(st->reallocationTableLen);
 | 
			
		||||
			     k++) {
 | 
			
		||||
				if (le32_to_cpu(st->mapEntry[k].origLocation) ==
 | 
			
		||||
				    0xFFFFFFFF) {
 | 
			
		||||
					for (; j < 4; j++) {
 | 
			
		||||
						if (sdata->s_spar_map[j]) {
 | 
			
		||||
							st = (struct
 | 
			
		||||
							      sparingTable *)
 | 
			
		||||
							    sdata->
 | 
			
		||||
							    s_spar_map[j]->
 | 
			
		||||
							    b_data;
 | 
			
		||||
							st->mapEntry[k].
 | 
			
		||||
							    origLocation =
 | 
			
		||||
							    cpu_to_le32(packet);
 | 
			
		||||
							udf_update_tag((char *)
 | 
			
		||||
								       st,
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									sparingTable)
 | 
			
		||||
								       +
 | 
			
		||||
								       le16_to_cpu
 | 
			
		||||
								       (st->
 | 
			
		||||
									reallocationTableLen)
 | 
			
		||||
								       *
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									sparingEntry));
 | 
			
		||||
							mark_buffer_dirty
 | 
			
		||||
							    (sdata->
 | 
			
		||||
							     s_spar_map[j]);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
 | 
			
		||||
						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
 | 
			
		||||
					*new_block =
 | 
			
		||||
					    le32_to_cpu(st->mapEntry[k].
 | 
			
		||||
							mappedLocation) +
 | 
			
		||||
					    ((old_block -
 | 
			
		||||
					      UDF_SB_PARTROOT(sb,
 | 
			
		||||
							      i)) & (sdata->
 | 
			
		||||
								     s_packet_len
 | 
			
		||||
								     - 1));
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
				else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet)
 | 
			
		||||
				{
 | 
			
		||||
					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
 | 
			
		||||
						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
 | 
			
		||||
				} else
 | 
			
		||||
				    if (le32_to_cpu
 | 
			
		||||
					(st->mapEntry[k].origLocation) ==
 | 
			
		||||
					packet) {
 | 
			
		||||
					*new_block =
 | 
			
		||||
					    le32_to_cpu(st->mapEntry[k].
 | 
			
		||||
							mappedLocation) +
 | 
			
		||||
					    ((old_block -
 | 
			
		||||
					      UDF_SB_PARTROOT(sb,
 | 
			
		||||
							      i)) & (sdata->
 | 
			
		||||
								     s_packet_len
 | 
			
		||||
								     - 1));
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
				else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet)
 | 
			
		||||
				} else
 | 
			
		||||
				    if (le32_to_cpu
 | 
			
		||||
					(st->mapEntry[k].origLocation) > packet)
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
			for (l=k; l<le16_to_cpu(st->reallocationTableLen); l++)
 | 
			
		||||
			{
 | 
			
		||||
				if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF)
 | 
			
		||||
				{
 | 
			
		||||
					for (; j<4; j++)
 | 
			
		||||
					{
 | 
			
		||||
						if (sdata->s_spar_map[j])
 | 
			
		||||
						{
 | 
			
		||||
							st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
 | 
			
		||||
							mapEntry = st->mapEntry[l];
 | 
			
		||||
							mapEntry.origLocation = cpu_to_le32(packet);
 | 
			
		||||
							memmove(&st->mapEntry[k+1], &st->mapEntry[k], (l-k)*sizeof(struct sparingEntry));
 | 
			
		||||
							st->mapEntry[k] = mapEntry;
 | 
			
		||||
							udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
 | 
			
		||||
							mark_buffer_dirty(sdata->s_spar_map[j]);
 | 
			
		||||
			for (l = k; l < le16_to_cpu(st->reallocationTableLen);
 | 
			
		||||
			     l++) {
 | 
			
		||||
				if (le32_to_cpu(st->mapEntry[l].origLocation) ==
 | 
			
		||||
				    0xFFFFFFFF) {
 | 
			
		||||
					for (; j < 4; j++) {
 | 
			
		||||
						if (sdata->s_spar_map[j]) {
 | 
			
		||||
							st = (struct
 | 
			
		||||
							      sparingTable *)
 | 
			
		||||
							    sdata->
 | 
			
		||||
							    s_spar_map[j]->
 | 
			
		||||
							    b_data;
 | 
			
		||||
							mapEntry =
 | 
			
		||||
							    st->mapEntry[l];
 | 
			
		||||
							mapEntry.origLocation =
 | 
			
		||||
							    cpu_to_le32(packet);
 | 
			
		||||
							memmove(&st->
 | 
			
		||||
								mapEntry[k + 1],
 | 
			
		||||
								&st->
 | 
			
		||||
								mapEntry[k],
 | 
			
		||||
								(l -
 | 
			
		||||
								 k) *
 | 
			
		||||
								sizeof(struct
 | 
			
		||||
								       sparingEntry));
 | 
			
		||||
							st->mapEntry[k] =
 | 
			
		||||
							    mapEntry;
 | 
			
		||||
							udf_update_tag((char *)
 | 
			
		||||
								       st,
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									sparingTable)
 | 
			
		||||
								       +
 | 
			
		||||
								       le16_to_cpu
 | 
			
		||||
								       (st->
 | 
			
		||||
									reallocationTableLen)
 | 
			
		||||
								       *
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									sparingEntry));
 | 
			
		||||
							mark_buffer_dirty
 | 
			
		||||
							    (sdata->
 | 
			
		||||
							     s_spar_map[j]);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
 | 
			
		||||
						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
 | 
			
		||||
					*new_block =
 | 
			
		||||
					    le32_to_cpu(st->mapEntry[k].
 | 
			
		||||
							mappedLocation) +
 | 
			
		||||
					    ((old_block -
 | 
			
		||||
					      UDF_SB_PARTROOT(sb,
 | 
			
		||||
							      i)) & (sdata->
 | 
			
		||||
								     s_packet_len
 | 
			
		||||
								     - 1));
 | 
			
		||||
					return 0;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (i == UDF_SB_NUMPARTS(sb))
 | 
			
		||||
	{
 | 
			
		||||
	if (i == UDF_SB_NUMPARTS(sb)) {
 | 
			
		||||
		/* outside of partitions */
 | 
			
		||||
		/* for now, fail =) */
 | 
			
		||||
		return 1;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1615
									
								
								fs/udf/super.c
									
									
									
									
									
								
							
							
						
						
									
										1615
									
								
								fs/udf/super.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -33,41 +33,40 @@
 | 
			
		||||
#include <linux/buffer_head.h>
 | 
			
		||||
#include "udf_i.h"
 | 
			
		||||
 | 
			
		||||
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to)
 | 
			
		||||
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen,
 | 
			
		||||
			   char *to)
 | 
			
		||||
{
 | 
			
		||||
	struct pathComponent *pc;
 | 
			
		||||
	int elen = 0;
 | 
			
		||||
	char *p = to;
 | 
			
		||||
 | 
			
		||||
	while (elen < fromlen)
 | 
			
		||||
	{
 | 
			
		||||
	while (elen < fromlen) {
 | 
			
		||||
		pc = (struct pathComponent *)(from + elen);
 | 
			
		||||
		switch (pc->componentType)
 | 
			
		||||
		{
 | 
			
		||||
			case 1:
 | 
			
		||||
				if (pc->lengthComponentIdent == 0)
 | 
			
		||||
				{
 | 
			
		||||
					p = to;
 | 
			
		||||
					*p++ = '/';
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case 3:
 | 
			
		||||
				memcpy(p, "../", 3);
 | 
			
		||||
				p += 3;
 | 
			
		||||
				break;
 | 
			
		||||
			case 4:
 | 
			
		||||
				memcpy(p, "./", 2);
 | 
			
		||||
				p += 2;
 | 
			
		||||
				/* that would be . - just ignore */
 | 
			
		||||
				break;
 | 
			
		||||
			case 5:
 | 
			
		||||
				p += udf_get_filename(sb, pc->componentIdent, p, pc->lengthComponentIdent);
 | 
			
		||||
		switch (pc->componentType) {
 | 
			
		||||
		case 1:
 | 
			
		||||
			if (pc->lengthComponentIdent == 0) {
 | 
			
		||||
				p = to;
 | 
			
		||||
				*p++ = '/';
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 3:
 | 
			
		||||
			memcpy(p, "../", 3);
 | 
			
		||||
			p += 3;
 | 
			
		||||
			break;
 | 
			
		||||
		case 4:
 | 
			
		||||
			memcpy(p, "./", 2);
 | 
			
		||||
			p += 2;
 | 
			
		||||
			/* that would be . - just ignore */
 | 
			
		||||
			break;
 | 
			
		||||
		case 5:
 | 
			
		||||
			p += udf_get_filename(sb, pc->componentIdent, p,
 | 
			
		||||
					      pc->lengthComponentIdent);
 | 
			
		||||
			*p++ = '/';
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
 | 
			
		||||
	}
 | 
			
		||||
	if (p > to+1)
 | 
			
		||||
	if (p > to + 1)
 | 
			
		||||
		p[-1] = '\0';
 | 
			
		||||
	else
 | 
			
		||||
		p[0] = '\0';
 | 
			
		||||
@@ -84,8 +83,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 | 
			
		||||
	lock_kernel();
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
 | 
			
		||||
		symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
	else {
 | 
			
		||||
		bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
 | 
			
		||||
 | 
			
		||||
		if (!bh)
 | 
			
		||||
@@ -102,7 +100,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 | 
			
		||||
	kunmap(page);
 | 
			
		||||
	unlock_page(page);
 | 
			
		||||
	return 0;
 | 
			
		||||
out:
 | 
			
		||||
      out:
 | 
			
		||||
	unlock_kernel();
 | 
			
		||||
	SetPageError(page);
 | 
			
		||||
	kunmap(page);
 | 
			
		||||
@@ -114,5 +112,5 @@ out:
 | 
			
		||||
 * symlinks can't do much...
 | 
			
		||||
 */
 | 
			
		||||
const struct address_space_operations udf_symlink_aops = {
 | 
			
		||||
	.readpage		= udf_symlink_filler,
 | 
			
		||||
	.readpage = udf_symlink_filler,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -28,35 +28,38 @@
 | 
			
		||||
#include "udf_i.h"
 | 
			
		||||
#include "udf_sb.h"
 | 
			
		||||
 | 
			
		||||
static void extent_trunc(struct inode * inode, struct extent_position *epos,
 | 
			
		||||
	kernel_lb_addr eloc, int8_t etype, uint32_t elen, uint32_t nelen)
 | 
			
		||||
static void extent_trunc(struct inode *inode, struct extent_position *epos,
 | 
			
		||||
			 kernel_lb_addr eloc, int8_t etype, uint32_t elen,
 | 
			
		||||
			 uint32_t nelen)
 | 
			
		||||
{
 | 
			
		||||
	kernel_lb_addr neloc = { 0, 0 };
 | 
			
		||||
	int last_block = (elen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
 | 
			
		||||
	int first_block = (nelen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
 | 
			
		||||
	int last_block =
 | 
			
		||||
	    (elen + inode->i_sb->s_blocksize -
 | 
			
		||||
	     1) >> inode->i_sb->s_blocksize_bits;
 | 
			
		||||
	int first_block =
 | 
			
		||||
	    (nelen + inode->i_sb->s_blocksize -
 | 
			
		||||
	     1) >> inode->i_sb->s_blocksize_bits;
 | 
			
		||||
 | 
			
		||||
	if (nelen)
 | 
			
		||||
	{
 | 
			
		||||
		if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
		{
 | 
			
		||||
			udf_free_blocks(inode->i_sb, inode, eloc, 0, last_block);
 | 
			
		||||
	if (nelen) {
 | 
			
		||||
		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
 | 
			
		||||
		} else
 | 
			
		||||
			neloc = eloc;
 | 
			
		||||
		nelen = (etype << 30) | nelen;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (elen != nelen)
 | 
			
		||||
	{
 | 
			
		||||
	if (elen != nelen) {
 | 
			
		||||
		udf_write_aext(inode, epos, neloc, nelen, 0);
 | 
			
		||||
		if (last_block - first_block > 0)
 | 
			
		||||
		{
 | 
			
		||||
		if (last_block - first_block > 0) {
 | 
			
		||||
			if (etype == (EXT_RECORDED_ALLOCATED >> 30))
 | 
			
		||||
				mark_inode_dirty(inode);
 | 
			
		||||
 | 
			
		||||
			if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
 | 
			
		||||
				udf_free_blocks(inode->i_sb, inode, eloc, first_block, last_block - first_block);
 | 
			
		||||
				udf_free_blocks(inode->i_sb, inode, eloc,
 | 
			
		||||
						first_block,
 | 
			
		||||
						last_block - first_block);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -67,7 +70,7 @@ static void extent_trunc(struct inode * inode, struct extent_position *epos,
 | 
			
		||||
 */
 | 
			
		||||
void udf_truncate_tail_extent(struct inode *inode)
 | 
			
		||||
{
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0}};
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0} };
 | 
			
		||||
	kernel_lb_addr eloc;
 | 
			
		||||
	uint32_t elen, nelen;
 | 
			
		||||
	uint64_t lbcount = 0;
 | 
			
		||||
@@ -89,8 +92,7 @@ void udf_truncate_tail_extent(struct inode *inode)
 | 
			
		||||
		BUG();
 | 
			
		||||
 | 
			
		||||
	/* Find the last extent in the file */
 | 
			
		||||
	while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1)
 | 
			
		||||
	{
 | 
			
		||||
	while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) {
 | 
			
		||||
		etype = netype;
 | 
			
		||||
		lbcount += elen;
 | 
			
		||||
		if (lbcount > inode->i_size) {
 | 
			
		||||
@@ -123,7 +125,7 @@ void udf_truncate_tail_extent(struct inode *inode)
 | 
			
		||||
 | 
			
		||||
void udf_discard_prealloc(struct inode *inode)
 | 
			
		||||
{
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0}};
 | 
			
		||||
	struct extent_position epos = { NULL, 0, {0, 0} };
 | 
			
		||||
	kernel_lb_addr eloc;
 | 
			
		||||
	uint32_t elen;
 | 
			
		||||
	uint64_t lbcount = 0;
 | 
			
		||||
@@ -131,7 +133,7 @@ void udf_discard_prealloc(struct inode *inode)
 | 
			
		||||
	int adsize;
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB ||
 | 
			
		||||
		inode->i_size == UDF_I_LENEXTENTS(inode))
 | 
			
		||||
	    inode->i_size == UDF_I_LENEXTENTS(inode))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT)
 | 
			
		||||
@@ -153,15 +155,21 @@ void udf_discard_prealloc(struct inode *inode)
 | 
			
		||||
		lbcount -= elen;
 | 
			
		||||
		extent_trunc(inode, &epos, eloc, etype, elen, 0);
 | 
			
		||||
		if (!epos.bh) {
 | 
			
		||||
			UDF_I_LENALLOC(inode) = epos.offset - udf_file_entry_alloc_offset(inode);
 | 
			
		||||
			UDF_I_LENALLOC(inode) =
 | 
			
		||||
			    epos.offset - udf_file_entry_alloc_offset(inode);
 | 
			
		||||
			mark_inode_dirty(inode);
 | 
			
		||||
		} else {
 | 
			
		||||
			struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data);
 | 
			
		||||
			aed->lengthAllocDescs = cpu_to_le32(epos.offset - sizeof(struct allocExtDesc));
 | 
			
		||||
			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
 | 
			
		||||
			struct allocExtDesc *aed =
 | 
			
		||||
			    (struct allocExtDesc *)(epos.bh->b_data);
 | 
			
		||||
			aed->lengthAllocDescs =
 | 
			
		||||
			    cpu_to_le32(epos.offset -
 | 
			
		||||
					sizeof(struct allocExtDesc));
 | 
			
		||||
			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)
 | 
			
		||||
			    || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
 | 
			
		||||
				udf_update_tag(epos.bh->b_data, epos.offset);
 | 
			
		||||
			else
 | 
			
		||||
				udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc));
 | 
			
		||||
				udf_update_tag(epos.bh->b_data,
 | 
			
		||||
					       sizeof(struct allocExtDesc));
 | 
			
		||||
			mark_buffer_dirty_inode(epos.bh, inode);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -171,7 +179,7 @@ void udf_discard_prealloc(struct inode *inode)
 | 
			
		||||
	brelse(epos.bh);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void udf_truncate_extents(struct inode * inode)
 | 
			
		||||
void udf_truncate_extents(struct inode *inode)
 | 
			
		||||
{
 | 
			
		||||
	struct extent_position epos;
 | 
			
		||||
	kernel_lb_addr eloc, neloc = { 0, 0 };
 | 
			
		||||
@@ -190,9 +198,10 @@ void udf_truncate_extents(struct inode * inode)
 | 
			
		||||
		BUG();
 | 
			
		||||
 | 
			
		||||
	etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
 | 
			
		||||
	byte_offset = (offset << sb->s_blocksize_bits) + (inode->i_size & (sb->s_blocksize-1));
 | 
			
		||||
	if (etype != -1)
 | 
			
		||||
	{
 | 
			
		||||
	byte_offset =
 | 
			
		||||
	    (offset << sb->s_blocksize_bits) +
 | 
			
		||||
	    (inode->i_size & (sb->s_blocksize - 1));
 | 
			
		||||
	if (etype != -1) {
 | 
			
		||||
		epos.offset -= adsize;
 | 
			
		||||
		extent_trunc(inode, &epos, eloc, etype, elen, byte_offset);
 | 
			
		||||
		epos.offset += adsize;
 | 
			
		||||
@@ -206,86 +215,98 @@ void udf_truncate_extents(struct inode * inode)
 | 
			
		||||
		else
 | 
			
		||||
			lenalloc -= sizeof(struct allocExtDesc);
 | 
			
		||||
 | 
			
		||||
		while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1)
 | 
			
		||||
		{
 | 
			
		||||
			if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30))
 | 
			
		||||
			{
 | 
			
		||||
		while ((etype =
 | 
			
		||||
			udf_current_aext(inode, &epos, &eloc, &elen,
 | 
			
		||||
					 0)) != -1) {
 | 
			
		||||
			if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
 | 
			
		||||
				udf_write_aext(inode, &epos, neloc, nelen, 0);
 | 
			
		||||
				if (indirect_ext_len)
 | 
			
		||||
				{
 | 
			
		||||
				if (indirect_ext_len) {
 | 
			
		||||
					/* We managed to free all extents in the
 | 
			
		||||
					 * indirect extent - free it too */
 | 
			
		||||
					if (!epos.bh)
 | 
			
		||||
						BUG();
 | 
			
		||||
					udf_free_blocks(sb, inode, epos.block, 0, indirect_ext_len);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					if (!epos.bh)
 | 
			
		||||
					{
 | 
			
		||||
						UDF_I_LENALLOC(inode) = lenalloc;
 | 
			
		||||
					udf_free_blocks(sb, inode, epos.block,
 | 
			
		||||
							0, indirect_ext_len);
 | 
			
		||||
				} else {
 | 
			
		||||
					if (!epos.bh) {
 | 
			
		||||
						UDF_I_LENALLOC(inode) =
 | 
			
		||||
						    lenalloc;
 | 
			
		||||
						mark_inode_dirty(inode);
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data);
 | 
			
		||||
						aed->lengthAllocDescs = cpu_to_le32(lenalloc);
 | 
			
		||||
						if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(sb) >= 0x0201)
 | 
			
		||||
							udf_update_tag(epos.bh->b_data, lenalloc +
 | 
			
		||||
								sizeof(struct allocExtDesc));
 | 
			
		||||
					} else {
 | 
			
		||||
						struct allocExtDesc *aed =
 | 
			
		||||
						    (struct allocExtDesc
 | 
			
		||||
						     *)(epos.bh->b_data);
 | 
			
		||||
						aed->lengthAllocDescs =
 | 
			
		||||
						    cpu_to_le32(lenalloc);
 | 
			
		||||
						if (!UDF_QUERY_FLAG
 | 
			
		||||
						    (sb, UDF_FLAG_STRICT)
 | 
			
		||||
						    || UDF_SB_UDFREV(sb) >=
 | 
			
		||||
						    0x0201)
 | 
			
		||||
							udf_update_tag(epos.bh->
 | 
			
		||||
								       b_data,
 | 
			
		||||
								       lenalloc
 | 
			
		||||
								       +
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									allocExtDesc));
 | 
			
		||||
						else
 | 
			
		||||
							udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc));
 | 
			
		||||
						mark_buffer_dirty_inode(epos.bh, inode);
 | 
			
		||||
							udf_update_tag(epos.bh->
 | 
			
		||||
								       b_data,
 | 
			
		||||
								       sizeof
 | 
			
		||||
								       (struct
 | 
			
		||||
									allocExtDesc));
 | 
			
		||||
						mark_buffer_dirty_inode(epos.bh,
 | 
			
		||||
									inode);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				brelse(epos.bh);
 | 
			
		||||
				epos.offset = sizeof(struct allocExtDesc);
 | 
			
		||||
				epos.block = eloc;
 | 
			
		||||
				epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0));
 | 
			
		||||
				epos.bh =
 | 
			
		||||
				    udf_tread(sb,
 | 
			
		||||
					      udf_get_lb_pblock(sb, eloc, 0));
 | 
			
		||||
				if (elen)
 | 
			
		||||
					indirect_ext_len = (elen +
 | 
			
		||||
						sb->s_blocksize - 1) >>
 | 
			
		||||
						sb->s_blocksize_bits;
 | 
			
		||||
							    sb->s_blocksize -
 | 
			
		||||
							    1) >> sb->
 | 
			
		||||
					    s_blocksize_bits;
 | 
			
		||||
				else
 | 
			
		||||
					indirect_ext_len = 1;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				extent_trunc(inode, &epos, eloc, etype, elen, 0);
 | 
			
		||||
			} else {
 | 
			
		||||
				extent_trunc(inode, &epos, eloc, etype, elen,
 | 
			
		||||
					     0);
 | 
			
		||||
				epos.offset += adsize;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (indirect_ext_len)
 | 
			
		||||
		{
 | 
			
		||||
		if (indirect_ext_len) {
 | 
			
		||||
			if (!epos.bh)
 | 
			
		||||
				BUG();
 | 
			
		||||
			udf_free_blocks(sb, inode, epos.block, 0, indirect_ext_len);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			if (!epos.bh)
 | 
			
		||||
			{
 | 
			
		||||
			udf_free_blocks(sb, inode, epos.block, 0,
 | 
			
		||||
					indirect_ext_len);
 | 
			
		||||
		} else {
 | 
			
		||||
			if (!epos.bh) {
 | 
			
		||||
				UDF_I_LENALLOC(inode) = lenalloc;
 | 
			
		||||
				mark_inode_dirty(inode);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data);
 | 
			
		||||
			} else {
 | 
			
		||||
				struct allocExtDesc *aed =
 | 
			
		||||
				    (struct allocExtDesc *)(epos.bh->b_data);
 | 
			
		||||
				aed->lengthAllocDescs = cpu_to_le32(lenalloc);
 | 
			
		||||
				if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(sb) >= 0x0201)
 | 
			
		||||
					udf_update_tag(epos.bh->b_data, lenalloc +
 | 
			
		||||
						sizeof(struct allocExtDesc));
 | 
			
		||||
				if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)
 | 
			
		||||
				    || UDF_SB_UDFREV(sb) >= 0x0201)
 | 
			
		||||
					udf_update_tag(epos.bh->b_data,
 | 
			
		||||
						       lenalloc +
 | 
			
		||||
						       sizeof(struct
 | 
			
		||||
							      allocExtDesc));
 | 
			
		||||
				else
 | 
			
		||||
					udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc));
 | 
			
		||||
					udf_update_tag(epos.bh->b_data,
 | 
			
		||||
						       sizeof(struct
 | 
			
		||||
							      allocExtDesc));
 | 
			
		||||
				mark_buffer_dirty_inode(epos.bh, inode);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (inode->i_size)
 | 
			
		||||
	{
 | 
			
		||||
		if (byte_offset)
 | 
			
		||||
		{
 | 
			
		||||
	} else if (inode->i_size) {
 | 
			
		||||
		if (byte_offset) {
 | 
			
		||||
			kernel_long_ad extent;
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
@@ -293,21 +314,33 @@ void udf_truncate_extents(struct inode * inode)
 | 
			
		||||
			 *  no extent above inode->i_size => truncate is
 | 
			
		||||
			 *  extending the file by 'offset' blocks.
 | 
			
		||||
			 */
 | 
			
		||||
			if ((!epos.bh && epos.offset == udf_file_entry_alloc_offset(inode)) ||
 | 
			
		||||
			    (epos.bh && epos.offset == sizeof(struct allocExtDesc))) {
 | 
			
		||||
			if ((!epos.bh
 | 
			
		||||
			     && epos.offset ==
 | 
			
		||||
			     udf_file_entry_alloc_offset(inode)) || (epos.bh
 | 
			
		||||
								     && epos.
 | 
			
		||||
								     offset ==
 | 
			
		||||
								     sizeof
 | 
			
		||||
								     (struct
 | 
			
		||||
								      allocExtDesc)))
 | 
			
		||||
			{
 | 
			
		||||
				/* File has no extents at all or has empty last
 | 
			
		||||
				 * indirect extent! Create a fake extent... */
 | 
			
		||||
				extent.extLocation.logicalBlockNum = 0;
 | 
			
		||||
				extent.extLocation.partitionReferenceNum = 0;
 | 
			
		||||
				extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				extent.extLength =
 | 
			
		||||
				    EXT_NOT_RECORDED_NOT_ALLOCATED;
 | 
			
		||||
			} else {
 | 
			
		||||
				epos.offset -= adsize;
 | 
			
		||||
				etype = udf_next_aext(inode, &epos,
 | 
			
		||||
					&extent.extLocation, &extent.extLength, 0);
 | 
			
		||||
						      &extent.extLocation,
 | 
			
		||||
						      &extent.extLength, 0);
 | 
			
		||||
				extent.extLength |= etype << 30;
 | 
			
		||||
			}
 | 
			
		||||
			udf_extend_file(inode, &epos, &extent, offset+((inode->i_size & (sb->s_blocksize-1)) != 0));
 | 
			
		||||
			udf_extend_file(inode, &epos, &extent,
 | 
			
		||||
					offset +
 | 
			
		||||
					((inode->
 | 
			
		||||
					  i_size & (sb->s_blocksize - 1)) !=
 | 
			
		||||
					 0));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	UDF_I_LENEXTENTS(inode) = inode->i_size;
 | 
			
		||||
 
 | 
			
		||||
@@ -23,4 +23,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode)
 | 
			
		||||
#define UDF_I_LAD(X)		( UDF_I(X)->i_ext.i_lad )
 | 
			
		||||
#define UDF_I_DATA(X)		( UDF_I(X)->i_ext.i_data )
 | 
			
		||||
 | 
			
		||||
#endif /* !defined(_LINUX_UDF_I_H) */
 | 
			
		||||
#endif				/* !defined(_LINUX_UDF_I_H) */
 | 
			
		||||
 
 | 
			
		||||
@@ -20,8 +20,8 @@
 | 
			
		||||
#define UDF_FLAG_VARCONV		8
 | 
			
		||||
#define UDF_FLAG_NLS_MAP		9
 | 
			
		||||
#define UDF_FLAG_UTF8			10
 | 
			
		||||
#define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
 | 
			
		||||
#define UDF_FLAG_UID_IGNORE     12    /* use sb uid instead of on disk uid */
 | 
			
		||||
#define UDF_FLAG_UID_FORGET     11	/* save -1 for uid to disk */
 | 
			
		||||
#define UDF_FLAG_UID_IGNORE     12	/* use sb uid instead of on disk uid */
 | 
			
		||||
#define UDF_FLAG_GID_FORGET     13
 | 
			
		||||
#define UDF_FLAG_GID_IGNORE     14
 | 
			
		||||
 | 
			
		||||
@@ -139,4 +139,4 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
 | 
			
		||||
#define UDF_SB_FLAGS(X)				( UDF_SB(X)->s_flags )
 | 
			
		||||
#define UDF_SB_VAT(X)				( UDF_SB(X)->s_vat )
 | 
			
		||||
 | 
			
		||||
#endif /* __LINUX_UDF_SB_H */
 | 
			
		||||
#endif				/* __LINUX_UDF_SB_H */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										106
									
								
								fs/udf/udfdecl.h
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								fs/udf/udfdecl.h
									
									
									
									
									
								
							@@ -50,30 +50,26 @@ extern const struct address_space_operations udf_aops;
 | 
			
		||||
extern const struct address_space_operations udf_adinicb_aops;
 | 
			
		||||
extern const struct address_space_operations udf_symlink_aops;
 | 
			
		||||
 | 
			
		||||
struct udf_fileident_bh
 | 
			
		||||
{
 | 
			
		||||
struct udf_fileident_bh {
 | 
			
		||||
	struct buffer_head *sbh;
 | 
			
		||||
	struct buffer_head *ebh;
 | 
			
		||||
	int soffset;
 | 
			
		||||
	int eoffset;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct udf_vds_record
 | 
			
		||||
{
 | 
			
		||||
struct udf_vds_record {
 | 
			
		||||
	uint32_t block;
 | 
			
		||||
	uint32_t volDescSeqNum;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct generic_desc
 | 
			
		||||
{
 | 
			
		||||
	tag		descTag;
 | 
			
		||||
	__le32		volDescSeqNum;
 | 
			
		||||
struct generic_desc {
 | 
			
		||||
	tag descTag;
 | 
			
		||||
	__le32 volDescSeqNum;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct ustr
 | 
			
		||||
{
 | 
			
		||||
struct ustr {
 | 
			
		||||
	uint8_t u_cmpID;
 | 
			
		||||
	uint8_t u_name[UDF_NAME_LEN-2];
 | 
			
		||||
	uint8_t u_name[UDF_NAME_LEN - 2];
 | 
			
		||||
	uint8_t u_len;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -83,44 +79,58 @@ struct extent_position {
 | 
			
		||||
	kernel_lb_addr block;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* super.c */
 | 
			
		||||
extern void udf_error(struct super_block *, const char *, const char *, ...);
 | 
			
		||||
extern void udf_warning(struct super_block *, const char *, const char *, ...);
 | 
			
		||||
 | 
			
		||||
/* namei.c */
 | 
			
		||||
extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, struct fileIdentDesc *, struct udf_fileident_bh *, uint8_t *, uint8_t *);
 | 
			
		||||
extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
 | 
			
		||||
			struct fileIdentDesc *, struct udf_fileident_bh *,
 | 
			
		||||
			uint8_t *, uint8_t *);
 | 
			
		||||
 | 
			
		||||
/* file.c */
 | 
			
		||||
extern int udf_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
 | 
			
		||||
extern int udf_ioctl(struct inode *, struct file *, unsigned int,
 | 
			
		||||
		     unsigned long);
 | 
			
		||||
 | 
			
		||||
/* inode.c */
 | 
			
		||||
extern struct inode *udf_iget(struct super_block *, kernel_lb_addr);
 | 
			
		||||
extern int udf_sync_inode(struct inode *);
 | 
			
		||||
extern void udf_expand_file_adinicb(struct inode *, int, int *);
 | 
			
		||||
extern struct buffer_head * udf_expand_dir_adinicb(struct inode *, int *, int *);
 | 
			
		||||
extern struct buffer_head * udf_bread(struct inode *, int, int, int *);
 | 
			
		||||
extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *);
 | 
			
		||||
extern struct buffer_head *udf_bread(struct inode *, int, int, int *);
 | 
			
		||||
extern void udf_truncate(struct inode *);
 | 
			
		||||
extern void udf_read_inode(struct inode *);
 | 
			
		||||
extern void udf_delete_inode(struct inode *);
 | 
			
		||||
extern void udf_clear_inode(struct inode *);
 | 
			
		||||
extern int udf_write_inode(struct inode *, int);
 | 
			
		||||
extern long udf_block_map(struct inode *, sector_t);
 | 
			
		||||
extern int udf_extend_file(struct inode *, struct extent_position *, kernel_long_ad *, sector_t);
 | 
			
		||||
extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, kernel_lb_addr *, uint32_t *, sector_t *);
 | 
			
		||||
extern int8_t udf_add_aext(struct inode *, struct extent_position *, kernel_lb_addr, uint32_t, int);
 | 
			
		||||
extern int8_t udf_write_aext(struct inode *, struct extent_position *, kernel_lb_addr, uint32_t, int);
 | 
			
		||||
extern int8_t udf_delete_aext(struct inode *, struct extent_position, kernel_lb_addr, uint32_t);
 | 
			
		||||
extern int8_t udf_next_aext(struct inode *, struct extent_position *, kernel_lb_addr *, uint32_t *, int);
 | 
			
		||||
extern int8_t udf_current_aext(struct inode *, struct extent_position *, kernel_lb_addr *, uint32_t *, int);
 | 
			
		||||
extern int udf_extend_file(struct inode *, struct extent_position *,
 | 
			
		||||
			   kernel_long_ad *, sector_t);
 | 
			
		||||
extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *,
 | 
			
		||||
			 kernel_lb_addr *, uint32_t *, sector_t *);
 | 
			
		||||
extern int8_t udf_add_aext(struct inode *, struct extent_position *,
 | 
			
		||||
			   kernel_lb_addr, uint32_t, int);
 | 
			
		||||
extern int8_t udf_write_aext(struct inode *, struct extent_position *,
 | 
			
		||||
			     kernel_lb_addr, uint32_t, int);
 | 
			
		||||
extern int8_t udf_delete_aext(struct inode *, struct extent_position,
 | 
			
		||||
			      kernel_lb_addr, uint32_t);
 | 
			
		||||
extern int8_t udf_next_aext(struct inode *, struct extent_position *,
 | 
			
		||||
			    kernel_lb_addr *, uint32_t *, int);
 | 
			
		||||
extern int8_t udf_current_aext(struct inode *, struct extent_position *,
 | 
			
		||||
			       kernel_lb_addr *, uint32_t *, int);
 | 
			
		||||
 | 
			
		||||
/* misc.c */
 | 
			
		||||
extern struct buffer_head *udf_tgetblk(struct super_block *, int);
 | 
			
		||||
extern struct buffer_head *udf_tread(struct super_block *, int);
 | 
			
		||||
extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t, uint32_t, uint8_t);
 | 
			
		||||
extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t, uint8_t);
 | 
			
		||||
extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t, uint32_t, uint16_t *);
 | 
			
		||||
extern struct buffer_head *udf_read_ptagged(struct super_block *, kernel_lb_addr, uint32_t, uint16_t *);
 | 
			
		||||
extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t,
 | 
			
		||||
						  uint32_t, uint8_t);
 | 
			
		||||
extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t,
 | 
			
		||||
						  uint8_t);
 | 
			
		||||
extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t,
 | 
			
		||||
					   uint32_t, uint16_t *);
 | 
			
		||||
extern struct buffer_head *udf_read_ptagged(struct super_block *,
 | 
			
		||||
					    kernel_lb_addr, uint32_t,
 | 
			
		||||
					    uint16_t *);
 | 
			
		||||
extern void udf_update_tag(char *, int);
 | 
			
		||||
extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int);
 | 
			
		||||
 | 
			
		||||
@@ -129,21 +139,26 @@ extern unsigned int udf_get_last_session(struct super_block *);
 | 
			
		||||
extern unsigned long udf_get_last_block(struct super_block *);
 | 
			
		||||
 | 
			
		||||
/* partition.c */
 | 
			
		||||
extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t, uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t, uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t, uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t, uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t,
 | 
			
		||||
			       uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t,
 | 
			
		||||
				      uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t,
 | 
			
		||||
				      uint32_t);
 | 
			
		||||
extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t,
 | 
			
		||||
				      uint32_t);
 | 
			
		||||
extern int udf_relocate_blocks(struct super_block *, long, long *);
 | 
			
		||||
 | 
			
		||||
/* unicode.c */
 | 
			
		||||
extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
 | 
			
		||||
extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, int);
 | 
			
		||||
extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
 | 
			
		||||
			    int);
 | 
			
		||||
extern int udf_build_ustr(struct ustr *, dstring *, int);
 | 
			
		||||
extern int udf_CS0toUTF8(struct ustr *, struct ustr *);
 | 
			
		||||
 | 
			
		||||
/* ialloc.c */
 | 
			
		||||
extern void udf_free_inode(struct inode *);
 | 
			
		||||
extern struct inode * udf_new_inode (struct inode *, int, int *);
 | 
			
		||||
extern struct inode *udf_new_inode(struct inode *, int, int *);
 | 
			
		||||
 | 
			
		||||
/* truncate.c */
 | 
			
		||||
extern void udf_truncate_tail_extent(struct inode *);
 | 
			
		||||
@@ -151,18 +166,27 @@ extern void udf_discard_prealloc(struct inode *);
 | 
			
		||||
extern void udf_truncate_extents(struct inode *);
 | 
			
		||||
 | 
			
		||||
/* balloc.c */
 | 
			
		||||
extern void udf_free_blocks(struct super_block *, struct inode *, kernel_lb_addr, uint32_t, uint32_t);
 | 
			
		||||
extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t, uint32_t, uint32_t);
 | 
			
		||||
extern int udf_new_block(struct super_block *, struct inode *, uint16_t, uint32_t, int *);
 | 
			
		||||
extern void udf_free_blocks(struct super_block *, struct inode *,
 | 
			
		||||
			    kernel_lb_addr, uint32_t, uint32_t);
 | 
			
		||||
extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t,
 | 
			
		||||
			       uint32_t, uint32_t);
 | 
			
		||||
extern int udf_new_block(struct super_block *, struct inode *, uint16_t,
 | 
			
		||||
			 uint32_t, int *);
 | 
			
		||||
 | 
			
		||||
/* fsync.c */
 | 
			
		||||
extern int udf_fsync_file(struct file *, struct dentry *, int);
 | 
			
		||||
 | 
			
		||||
/* directory.c */
 | 
			
		||||
extern struct fileIdentDesc * udf_fileident_read(struct inode *, loff_t *, struct udf_fileident_bh *, struct fileIdentDesc *, struct extent_position *, kernel_lb_addr *, uint32_t *, sector_t *);
 | 
			
		||||
extern struct fileIdentDesc * udf_get_fileident(void * buffer, int bufsize, int * offset);
 | 
			
		||||
extern long_ad * udf_get_filelongad(uint8_t *, int, int *, int);
 | 
			
		||||
extern short_ad * udf_get_fileshortad(uint8_t *, int, int *, int);
 | 
			
		||||
extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
 | 
			
		||||
						struct udf_fileident_bh *,
 | 
			
		||||
						struct fileIdentDesc *,
 | 
			
		||||
						struct extent_position *,
 | 
			
		||||
						kernel_lb_addr *, uint32_t *,
 | 
			
		||||
						sector_t *);
 | 
			
		||||
extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
 | 
			
		||||
					       int *offset);
 | 
			
		||||
extern long_ad *udf_get_filelongad(uint8_t *, int, int *, int);
 | 
			
		||||
extern short_ad *udf_get_fileshortad(uint8_t *, int, int *, int);
 | 
			
		||||
 | 
			
		||||
/* crc.c */
 | 
			
		||||
extern uint16_t udf_crc(uint8_t *, uint32_t, uint16_t);
 | 
			
		||||
@@ -171,4 +195,4 @@ extern uint16_t udf_crc(uint8_t *, uint32_t, uint16_t);
 | 
			
		||||
extern time_t *udf_stamp_to_time(time_t *, long *, kernel_timestamp);
 | 
			
		||||
extern kernel_timestamp *udf_time_to_stamp(kernel_timestamp *, struct timespec);
 | 
			
		||||
 | 
			
		||||
#endif /* __UDF_DECL_H */
 | 
			
		||||
#endif				/* __UDF_DECL_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -78,4 +78,4 @@ static inline timestamp cpu_to_lets(kernel_timestamp in)
 | 
			
		||||
	return out;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* __UDF_ENDIAN_H */
 | 
			
		||||
#endif				/* __UDF_ENDIAN_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -46,37 +46,36 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* How many days come before each month (0-12).  */
 | 
			
		||||
static const unsigned short int __mon_yday[2][13] =
 | 
			
		||||
{
 | 
			
		||||
static const unsigned short int __mon_yday[2][13] = {
 | 
			
		||||
	/* Normal years.  */
 | 
			
		||||
	{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
 | 
			
		||||
	{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
 | 
			
		||||
	/* Leap years.  */
 | 
			
		||||
	{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
 | 
			
		||||
	{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define MAX_YEAR_SECONDS	69
 | 
			
		||||
#define SPD 0x15180 /*3600*24*/
 | 
			
		||||
#define SPD 0x15180		/*3600*24 */
 | 
			
		||||
#define SPY(y,l,s) (SPD * (365*y+l)+s)
 | 
			
		||||
 | 
			
		||||
static time_t year_seconds[MAX_YEAR_SECONDS]= {
 | 
			
		||||
/*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0), 
 | 
			
		||||
/*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0), 
 | 
			
		||||
/*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0), 
 | 
			
		||||
/*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0), 
 | 
			
		||||
/*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0), 
 | 
			
		||||
/*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0), 
 | 
			
		||||
/*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0), 
 | 
			
		||||
/*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0), 
 | 
			
		||||
/*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0), 
 | 
			
		||||
/*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0), 
 | 
			
		||||
/*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0), 
 | 
			
		||||
/*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0), 
 | 
			
		||||
/*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0), 
 | 
			
		||||
/*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0), 
 | 
			
		||||
/*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0), 
 | 
			
		||||
/*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0), 
 | 
			
		||||
/*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0), 
 | 
			
		||||
/*2038*/ SPY(68,17,0)
 | 
			
		||||
static time_t year_seconds[MAX_YEAR_SECONDS] = {
 | 
			
		||||
/*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0),
 | 
			
		||||
/*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0),
 | 
			
		||||
/*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0),
 | 
			
		||||
/*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0),
 | 
			
		||||
/*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0),
 | 
			
		||||
/*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0),
 | 
			
		||||
/*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0),
 | 
			
		||||
/*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0),
 | 
			
		||||
/*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0),
 | 
			
		||||
/*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0),
 | 
			
		||||
/*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0),
 | 
			
		||||
/*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0),
 | 
			
		||||
/*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0),
 | 
			
		||||
/*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0),
 | 
			
		||||
/*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0),
 | 
			
		||||
/*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0),
 | 
			
		||||
/*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0),
 | 
			
		||||
/*2038*/ SPY(68, 17, 0)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern struct timezone sys_tz;
 | 
			
		||||
@@ -84,27 +83,23 @@ extern struct timezone sys_tz;
 | 
			
		||||
#define SECS_PER_HOUR	(60 * 60)
 | 
			
		||||
#define SECS_PER_DAY	(SECS_PER_HOUR * 24)
 | 
			
		||||
 | 
			
		||||
time_t *
 | 
			
		||||
udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
 | 
			
		||||
time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
 | 
			
		||||
{
 | 
			
		||||
	int yday;
 | 
			
		||||
	uint8_t type = src.typeAndTimezone >> 12;
 | 
			
		||||
	int16_t offset;
 | 
			
		||||
 | 
			
		||||
	if (type == 1)
 | 
			
		||||
	{
 | 
			
		||||
	if (type == 1) {
 | 
			
		||||
		offset = src.typeAndTimezone << 4;
 | 
			
		||||
		/* sign extent offset */
 | 
			
		||||
		offset = (offset >> 4);
 | 
			
		||||
		if (offset == -2047) /* unspecified offset */
 | 
			
		||||
		if (offset == -2047)	/* unspecified offset */
 | 
			
		||||
			offset = 0;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	} else
 | 
			
		||||
		offset = 0;
 | 
			
		||||
 | 
			
		||||
	if ((src.year < EPOCH_YEAR) ||
 | 
			
		||||
		(src.year >= EPOCH_YEAR+MAX_YEAR_SECONDS))
 | 
			
		||||
	{
 | 
			
		||||
	    (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
 | 
			
		||||
		*dest = -1;
 | 
			
		||||
		*dest_usec = -1;
 | 
			
		||||
		return NULL;
 | 
			
		||||
@@ -112,16 +107,16 @@ udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
 | 
			
		||||
	*dest = year_seconds[src.year - EPOCH_YEAR];
 | 
			
		||||
	*dest -= offset * 60;
 | 
			
		||||
 | 
			
		||||
	yday = ((__mon_yday[__isleap (src.year)]
 | 
			
		||||
		[src.month-1]) + (src.day-1));
 | 
			
		||||
	*dest += ( ( (yday* 24) + src.hour ) * 60 + src.minute ) * 60 + src.second;
 | 
			
		||||
	*dest_usec = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds;
 | 
			
		||||
	yday = ((__mon_yday[__isleap(src.year)]
 | 
			
		||||
		 [src.month - 1]) + (src.day - 1));
 | 
			
		||||
	*dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second;
 | 
			
		||||
	*dest_usec =
 | 
			
		||||
	    src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 +
 | 
			
		||||
	    src.microseconds;
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
kernel_timestamp *
 | 
			
		||||
udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
 | 
			
		||||
kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
 | 
			
		||||
{
 | 
			
		||||
	long int days, rem, y;
 | 
			
		||||
	const unsigned short int *ip;
 | 
			
		||||
@@ -146,28 +141,28 @@ udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
 | 
			
		||||
#define DIV(a,b) ((a) / (b) - ((a) % (b) < 0))
 | 
			
		||||
#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
 | 
			
		||||
 | 
			
		||||
	while (days < 0 || days >= (__isleap(y) ? 366 : 365))
 | 
			
		||||
	{
 | 
			
		||||
	while (days < 0 || days >= (__isleap(y) ? 366 : 365)) {
 | 
			
		||||
		long int yg = y + days / 365 - (days % 365 < 0);
 | 
			
		||||
 | 
			
		||||
		/* Adjust DAYS and Y to match the guessed year.  */
 | 
			
		||||
		days -= ((yg - y) * 365
 | 
			
		||||
			+ LEAPS_THRU_END_OF (yg - 1)
 | 
			
		||||
			- LEAPS_THRU_END_OF (y - 1));
 | 
			
		||||
		days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1)
 | 
			
		||||
			 - LEAPS_THRU_END_OF(y - 1));
 | 
			
		||||
		y = yg;
 | 
			
		||||
	}
 | 
			
		||||
	dest->year = y;
 | 
			
		||||
	ip = __mon_yday[__isleap(y)];
 | 
			
		||||
	for (y = 11; days < (long int) ip[y]; --y)
 | 
			
		||||
	for (y = 11; days < (long int)ip[y]; --y)
 | 
			
		||||
		continue;
 | 
			
		||||
	days -= ip[y];
 | 
			
		||||
	dest->month = y + 1;
 | 
			
		||||
	dest->day = days + 1;
 | 
			
		||||
 | 
			
		||||
	dest->centiseconds = ts.tv_nsec / 10000000;
 | 
			
		||||
	dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
 | 
			
		||||
	dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
 | 
			
		||||
		dest->hundredsOfMicroseconds * 100);
 | 
			
		||||
	dest->hundredsOfMicroseconds =
 | 
			
		||||
	    (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
 | 
			
		||||
	dest->microseconds =
 | 
			
		||||
	    (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
 | 
			
		||||
	     dest->hundredsOfMicroseconds * 100);
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										299
									
								
								fs/udf/unicode.c
									
									
									
									
									
								
							
							
						
						
									
										299
									
								
								fs/udf/unicode.c
									
									
									
									
									
								
							@@ -29,9 +29,9 @@
 | 
			
		||||
 | 
			
		||||
static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int);
 | 
			
		||||
 | 
			
		||||
static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
 | 
			
		||||
static int udf_char_to_ustr(struct ustr *dest, const uint8_t * src, int strlen)
 | 
			
		||||
{
 | 
			
		||||
	if ( (!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN-2) )
 | 
			
		||||
	if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2))
 | 
			
		||||
		return 0;
 | 
			
		||||
	memset(dest, 0, sizeof(struct ustr));
 | 
			
		||||
	memcpy(dest->u_name, src, strlen);
 | 
			
		||||
@@ -43,33 +43,33 @@ static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
 | 
			
		||||
/*
 | 
			
		||||
 * udf_build_ustr
 | 
			
		||||
 */
 | 
			
		||||
int udf_build_ustr(struct ustr *dest, dstring *ptr, int size)
 | 
			
		||||
int udf_build_ustr(struct ustr *dest, dstring * ptr, int size)
 | 
			
		||||
{
 | 
			
		||||
	int usesize;
 | 
			
		||||
 | 
			
		||||
	if ( (!dest) || (!ptr) || (!size) )
 | 
			
		||||
	if ((!dest) || (!ptr) || (!size))
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	memset(dest, 0, sizeof(struct ustr));
 | 
			
		||||
	usesize= (size > UDF_NAME_LEN) ? UDF_NAME_LEN : size;
 | 
			
		||||
	dest->u_cmpID=ptr[0];
 | 
			
		||||
	dest->u_len=ptr[size-1];
 | 
			
		||||
	memcpy(dest->u_name, ptr+1, usesize-1);
 | 
			
		||||
	usesize = (size > UDF_NAME_LEN) ? UDF_NAME_LEN : size;
 | 
			
		||||
	dest->u_cmpID = ptr[0];
 | 
			
		||||
	dest->u_len = ptr[size - 1];
 | 
			
		||||
	memcpy(dest->u_name, ptr + 1, usesize - 1);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * udf_build_ustr_exact
 | 
			
		||||
 */
 | 
			
		||||
static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
 | 
			
		||||
static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize)
 | 
			
		||||
{
 | 
			
		||||
	if ( (!dest) || (!ptr) || (!exactsize) )
 | 
			
		||||
	if ((!dest) || (!ptr) || (!exactsize))
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	memset(dest, 0, sizeof(struct ustr));
 | 
			
		||||
	dest->u_cmpID=ptr[0];
 | 
			
		||||
	dest->u_len=exactsize-1;
 | 
			
		||||
	memcpy(dest->u_name, ptr+1, exactsize-1);
 | 
			
		||||
	dest->u_cmpID = ptr[0];
 | 
			
		||||
	dest->u_len = exactsize - 1;
 | 
			
		||||
	memcpy(dest->u_name, ptr + 1, exactsize - 1);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -108,22 +108,20 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
 | 
			
		||||
	cmp_id = ocu_i->u_cmpID;
 | 
			
		||||
	utf_o->u_len = 0;
 | 
			
		||||
 | 
			
		||||
	if (ocu_len == 0)
 | 
			
		||||
	{
 | 
			
		||||
	if (ocu_len == 0) {
 | 
			
		||||
		memset(utf_o, 0, sizeof(struct ustr));
 | 
			
		||||
		utf_o->u_cmpID = 0;
 | 
			
		||||
		utf_o->u_len = 0;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((cmp_id != 8) && (cmp_id != 16))
 | 
			
		||||
	{
 | 
			
		||||
		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", cmp_id, ocu_i->u_name);
 | 
			
		||||
	if ((cmp_id != 8) && (cmp_id != 16)) {
 | 
			
		||||
		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
 | 
			
		||||
		       cmp_id, ocu_i->u_name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN-3)) ;)
 | 
			
		||||
	{
 | 
			
		||||
	for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
 | 
			
		||||
 | 
			
		||||
		/* Expand OSTA compressed Unicode to Unicode */
 | 
			
		||||
		c = ocu[i++];
 | 
			
		||||
@@ -132,20 +130,22 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
 | 
			
		||||
 | 
			
		||||
		/* Compress Unicode to UTF-8 */
 | 
			
		||||
		if (c < 0x80U)
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
 | 
			
		||||
		else if (c < 0x800U)
 | 
			
		||||
		{
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] = (uint8_t) c;
 | 
			
		||||
		else if (c < 0x800U) {
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] =
 | 
			
		||||
			    (uint8_t) (0xc0 | (c >> 6));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] =
 | 
			
		||||
			    (uint8_t) (0x80 | (c & 0x3f));
 | 
			
		||||
		} else {
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] =
 | 
			
		||||
			    (uint8_t) (0xe0 | (c >> 12));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] =
 | 
			
		||||
			    (uint8_t) (0x80 | ((c >> 6) & 0x3f));
 | 
			
		||||
			utf_o->u_name[utf_o->u_len++] =
 | 
			
		||||
			    (uint8_t) (0x80 | (c & 0x3f));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	utf_o->u_cmpID=8;
 | 
			
		||||
	utf_o->u_cmpID = 8;
 | 
			
		||||
 | 
			
		||||
	return utf_o->u_len;
 | 
			
		||||
}
 | 
			
		||||
@@ -173,7 +173,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
 | 
			
		||||
 *	November 12, 1997 - Andrew E. Mileski
 | 
			
		||||
 *	Written, tested, and released.
 | 
			
		||||
 */
 | 
			
		||||
static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
 | 
			
		||||
static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
 | 
			
		||||
{
 | 
			
		||||
	unsigned c, i, max_val, utf_char;
 | 
			
		||||
	int utf_cnt, u_len;
 | 
			
		||||
@@ -182,53 +182,38 @@ static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
 | 
			
		||||
	ocu[0] = 8;
 | 
			
		||||
	max_val = 0xffU;
 | 
			
		||||
 | 
			
		||||
try_again:
 | 
			
		||||
      try_again:
 | 
			
		||||
	u_len = 0U;
 | 
			
		||||
	utf_char = 0U;
 | 
			
		||||
	utf_cnt = 0U;
 | 
			
		||||
	for (i = 0U; i < utf->u_len; i++)
 | 
			
		||||
	{
 | 
			
		||||
		c = (uint8_t)utf->u_name[i];
 | 
			
		||||
	for (i = 0U; i < utf->u_len; i++) {
 | 
			
		||||
		c = (uint8_t) utf->u_name[i];
 | 
			
		||||
 | 
			
		||||
		/* Complete a multi-byte UTF-8 character */
 | 
			
		||||
		if (utf_cnt)
 | 
			
		||||
		{
 | 
			
		||||
		if (utf_cnt) {
 | 
			
		||||
			utf_char = (utf_char << 6) | (c & 0x3fU);
 | 
			
		||||
			if (--utf_cnt)
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
		} else {
 | 
			
		||||
			/* Check for a multi-byte UTF-8 character */
 | 
			
		||||
			if (c & 0x80U)
 | 
			
		||||
			{
 | 
			
		||||
			if (c & 0x80U) {
 | 
			
		||||
				/* Start a multi-byte UTF-8 character */
 | 
			
		||||
				if ((c & 0xe0U) == 0xc0U)
 | 
			
		||||
				{
 | 
			
		||||
				if ((c & 0xe0U) == 0xc0U) {
 | 
			
		||||
					utf_char = c & 0x1fU;
 | 
			
		||||
					utf_cnt = 1;
 | 
			
		||||
				}
 | 
			
		||||
				else if ((c & 0xf0U) == 0xe0U)
 | 
			
		||||
				{
 | 
			
		||||
				} else if ((c & 0xf0U) == 0xe0U) {
 | 
			
		||||
					utf_char = c & 0x0fU;
 | 
			
		||||
					utf_cnt = 2;
 | 
			
		||||
				}
 | 
			
		||||
				else if ((c & 0xf8U) == 0xf0U)
 | 
			
		||||
				{
 | 
			
		||||
				} else if ((c & 0xf8U) == 0xf0U) {
 | 
			
		||||
					utf_char = c & 0x07U;
 | 
			
		||||
					utf_cnt = 3;
 | 
			
		||||
				}
 | 
			
		||||
				else if ((c & 0xfcU) == 0xf8U)
 | 
			
		||||
				{
 | 
			
		||||
				} else if ((c & 0xfcU) == 0xf8U) {
 | 
			
		||||
					utf_char = c & 0x03U;
 | 
			
		||||
					utf_cnt = 4;
 | 
			
		||||
				}
 | 
			
		||||
				else if ((c & 0xfeU) == 0xfcU)
 | 
			
		||||
				{
 | 
			
		||||
				} else if ((c & 0xfeU) == 0xfcU) {
 | 
			
		||||
					utf_char = c & 0x01U;
 | 
			
		||||
					utf_cnt = 5;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				} else
 | 
			
		||||
					goto error_out;
 | 
			
		||||
				continue;
 | 
			
		||||
			} else
 | 
			
		||||
@@ -237,37 +222,33 @@ try_again:
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Choose no compression if necessary */
 | 
			
		||||
		if (utf_char > max_val)
 | 
			
		||||
		{
 | 
			
		||||
			if ( 0xffU == max_val )
 | 
			
		||||
			{
 | 
			
		||||
		if (utf_char > max_val) {
 | 
			
		||||
			if (0xffU == max_val) {
 | 
			
		||||
				max_val = 0xffffU;
 | 
			
		||||
				ocu[0] = (uint8_t)0x10U;
 | 
			
		||||
				ocu[0] = (uint8_t) 0x10U;
 | 
			
		||||
				goto try_again;
 | 
			
		||||
			}
 | 
			
		||||
			goto error_out;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (max_val == 0xffffU)
 | 
			
		||||
		{
 | 
			
		||||
			ocu[++u_len] = (uint8_t)(utf_char >> 8);
 | 
			
		||||
		if (max_val == 0xffffU) {
 | 
			
		||||
			ocu[++u_len] = (uint8_t) (utf_char >> 8);
 | 
			
		||||
		}
 | 
			
		||||
		ocu[++u_len] = (uint8_t)(utf_char & 0xffU);
 | 
			
		||||
		ocu[++u_len] = (uint8_t) (utf_char & 0xffU);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (utf_cnt)
 | 
			
		||||
	{
 | 
			
		||||
error_out:
 | 
			
		||||
	if (utf_cnt) {
 | 
			
		||||
	      error_out:
 | 
			
		||||
		ocu[++u_len] = '?';
 | 
			
		||||
		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ocu[length - 1] = (uint8_t)u_len + 1;
 | 
			
		||||
	ocu[length - 1] = (uint8_t) u_len + 1;
 | 
			
		||||
	return u_len + 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, struct ustr *ocu_i)
 | 
			
		||||
static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 | 
			
		||||
			struct ustr *ocu_i)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *ocu;
 | 
			
		||||
	uint32_t c;
 | 
			
		||||
@@ -280,36 +261,35 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, struct ustr *
 | 
			
		||||
	cmp_id = ocu_i->u_cmpID;
 | 
			
		||||
	utf_o->u_len = 0;
 | 
			
		||||
 | 
			
		||||
	if (ocu_len == 0)
 | 
			
		||||
	{
 | 
			
		||||
	if (ocu_len == 0) {
 | 
			
		||||
		memset(utf_o, 0, sizeof(struct ustr));
 | 
			
		||||
		utf_o->u_cmpID = 0;
 | 
			
		||||
		utf_o->u_len = 0;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((cmp_id != 8) && (cmp_id != 16))
 | 
			
		||||
	{
 | 
			
		||||
		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", cmp_id, ocu_i->u_name);
 | 
			
		||||
	if ((cmp_id != 8) && (cmp_id != 16)) {
 | 
			
		||||
		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
 | 
			
		||||
		       cmp_id, ocu_i->u_name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN-3)) ;)
 | 
			
		||||
	{
 | 
			
		||||
	for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
 | 
			
		||||
		/* Expand OSTA compressed Unicode to Unicode */
 | 
			
		||||
		c = ocu[i++];
 | 
			
		||||
		if (cmp_id == 16)
 | 
			
		||||
			c = (c << 8) | ocu[i++];
 | 
			
		||||
 | 
			
		||||
		utf_o->u_len += nls->uni2char(c, &utf_o->u_name[utf_o->u_len], 
 | 
			
		||||
			UDF_NAME_LEN - utf_o->u_len);
 | 
			
		||||
		utf_o->u_len += nls->uni2char(c, &utf_o->u_name[utf_o->u_len],
 | 
			
		||||
					      UDF_NAME_LEN - utf_o->u_len);
 | 
			
		||||
	}
 | 
			
		||||
	utf_o->u_cmpID=8;
 | 
			
		||||
	utf_o->u_cmpID = 8;
 | 
			
		||||
 | 
			
		||||
	return utf_o->u_len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, int length)
 | 
			
		||||
static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
 | 
			
		||||
			int length)
 | 
			
		||||
{
 | 
			
		||||
	unsigned len, i, max_val;
 | 
			
		||||
	uint16_t uni_char;
 | 
			
		||||
@@ -319,93 +299,87 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, i
 | 
			
		||||
	ocu[0] = 8;
 | 
			
		||||
	max_val = 0xffU;
 | 
			
		||||
 | 
			
		||||
try_again:
 | 
			
		||||
      try_again:
 | 
			
		||||
	u_len = 0U;
 | 
			
		||||
	for (i = 0U; i < uni->u_len; i++)
 | 
			
		||||
	{
 | 
			
		||||
		len = nls->char2uni(&uni->u_name[i], uni->u_len-i, &uni_char);
 | 
			
		||||
	for (i = 0U; i < uni->u_len; i++) {
 | 
			
		||||
		len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
 | 
			
		||||
		if (len <= 0)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		if (uni_char > max_val)
 | 
			
		||||
		{
 | 
			
		||||
		if (uni_char > max_val) {
 | 
			
		||||
			max_val = 0xffffU;
 | 
			
		||||
			ocu[0] = (uint8_t)0x10U;
 | 
			
		||||
			ocu[0] = (uint8_t) 0x10U;
 | 
			
		||||
			goto try_again;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		if (max_val == 0xffffU)
 | 
			
		||||
			ocu[++u_len] = (uint8_t)(uni_char >> 8);
 | 
			
		||||
		ocu[++u_len] = (uint8_t)(uni_char & 0xffU);
 | 
			
		||||
			ocu[++u_len] = (uint8_t) (uni_char >> 8);
 | 
			
		||||
		ocu[++u_len] = (uint8_t) (uni_char & 0xffU);
 | 
			
		||||
		i += len - 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ocu[length - 1] = (uint8_t)u_len + 1;
 | 
			
		||||
	ocu[length - 1] = (uint8_t) u_len + 1;
 | 
			
		||||
	return u_len + 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, int flen)
 | 
			
		||||
int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname,
 | 
			
		||||
		     int flen)
 | 
			
		||||
{
 | 
			
		||||
	struct ustr filename, unifilename;
 | 
			
		||||
	int len;
 | 
			
		||||
 | 
			
		||||
	if (udf_build_ustr_exact(&unifilename, sname, flen))
 | 
			
		||||
	{
 | 
			
		||||
	if (udf_build_ustr_exact(&unifilename, sname, flen)) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
 | 
			
		||||
	{
 | 
			
		||||
		if (!udf_CS0toUTF8(&filename, &unifilename) )
 | 
			
		||||
		{
 | 
			
		||||
			udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
 | 
			
		||||
		if (!udf_CS0toUTF8(&filename, &unifilename)) {
 | 
			
		||||
			udf_debug("Failed in udf_get_filename: sname = %s\n",
 | 
			
		||||
				  sname);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 | 
			
		||||
	{
 | 
			
		||||
		if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename) )
 | 
			
		||||
		{
 | 
			
		||||
			udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
 | 
			
		||||
	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
 | 
			
		||||
		if (!udf_CS0toNLS
 | 
			
		||||
		    (UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
 | 
			
		||||
			udf_debug("Failed in udf_get_filename: sname = %s\n",
 | 
			
		||||
				  sname);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	} else
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if ((len = udf_translate_to_linux(dname, filename.u_name, filename.u_len,
 | 
			
		||||
		unifilename.u_name, unifilename.u_len)))
 | 
			
		||||
	{
 | 
			
		||||
	if ((len =
 | 
			
		||||
	     udf_translate_to_linux(dname, filename.u_name, filename.u_len,
 | 
			
		||||
				    unifilename.u_name, unifilename.u_len))) {
 | 
			
		||||
		return len;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int udf_put_filename(struct super_block *sb, const uint8_t *sname, uint8_t *dname, int flen)
 | 
			
		||||
int udf_put_filename(struct super_block *sb, const uint8_t * sname,
 | 
			
		||||
		     uint8_t * dname, int flen)
 | 
			
		||||
{
 | 
			
		||||
	struct ustr unifilename;
 | 
			
		||||
	int namelen;
 | 
			
		||||
 | 
			
		||||
	if ( !(udf_char_to_ustr(&unifilename, sname, flen)) )
 | 
			
		||||
	{
 | 
			
		||||
	if (!(udf_char_to_ustr(&unifilename, sname, flen))) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
 | 
			
		||||
	{
 | 
			
		||||
		if ( !(namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN)) )
 | 
			
		||||
		{
 | 
			
		||||
	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
 | 
			
		||||
		if (!
 | 
			
		||||
		    (namelen =
 | 
			
		||||
		     udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN))) {
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 | 
			
		||||
	{
 | 
			
		||||
		if ( !(namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN)) )
 | 
			
		||||
		{
 | 
			
		||||
	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
 | 
			
		||||
		if (!
 | 
			
		||||
		    (namelen =
 | 
			
		||||
		     udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename,
 | 
			
		||||
				  UDF_NAME_LEN))) {
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	} else
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	return namelen;
 | 
			
		||||
@@ -416,40 +390,36 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname, uint8_t *dnam
 | 
			
		||||
#define CRC_MARK			'#'
 | 
			
		||||
#define EXT_SIZE			5
 | 
			
		||||
 | 
			
		||||
static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen, uint8_t *fidName, int fidNameLen)
 | 
			
		||||
static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
 | 
			
		||||
				  int udfLen, uint8_t * fidName, int fidNameLen)
 | 
			
		||||
{
 | 
			
		||||
	int index, newIndex = 0, needsCRC = 0;	
 | 
			
		||||
	int index, newIndex = 0, needsCRC = 0;
 | 
			
		||||
	int extIndex = 0, newExtIndex = 0, hasExt = 0;
 | 
			
		||||
	unsigned short valueCRC;
 | 
			
		||||
	uint8_t curr;
 | 
			
		||||
	const uint8_t hexChar[] = "0123456789ABCDEF";
 | 
			
		||||
 | 
			
		||||
	if (udfName[0] == '.' && (udfLen == 1 ||
 | 
			
		||||
		(udfLen == 2 && udfName[1] == '.')))
 | 
			
		||||
	{
 | 
			
		||||
				  (udfLen == 2 && udfName[1] == '.'))) {
 | 
			
		||||
		needsCRC = 1;
 | 
			
		||||
		newIndex = udfLen;
 | 
			
		||||
		memcpy(newName, udfName, udfLen);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{	
 | 
			
		||||
		for (index = 0; index < udfLen; index++)
 | 
			
		||||
		{
 | 
			
		||||
	} else {
 | 
			
		||||
		for (index = 0; index < udfLen; index++) {
 | 
			
		||||
			curr = udfName[index];
 | 
			
		||||
			if (curr == '/' || curr == 0)
 | 
			
		||||
			{
 | 
			
		||||
			if (curr == '/' || curr == 0) {
 | 
			
		||||
				needsCRC = 1;
 | 
			
		||||
				curr = ILLEGAL_CHAR_MARK;
 | 
			
		||||
				while (index+1 < udfLen && (udfName[index+1] == '/' ||
 | 
			
		||||
					udfName[index+1] == 0))
 | 
			
		||||
				while (index + 1 < udfLen
 | 
			
		||||
				       && (udfName[index + 1] == '/'
 | 
			
		||||
					   || udfName[index + 1] == 0))
 | 
			
		||||
					index++;
 | 
			
		||||
			}
 | 
			
		||||
			if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE)
 | 
			
		||||
			{
 | 
			
		||||
			if (curr == EXT_MARK
 | 
			
		||||
			    && (udfLen - index - 1) <= EXT_SIZE) {
 | 
			
		||||
				if (udfLen == index + 1)
 | 
			
		||||
					hasExt = 0;
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
				else {
 | 
			
		||||
					hasExt = 1;
 | 
			
		||||
					extIndex = index;
 | 
			
		||||
					newExtIndex = newIndex;
 | 
			
		||||
@@ -461,26 +431,29 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
 | 
			
		||||
				needsCRC = 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (needsCRC)
 | 
			
		||||
	{
 | 
			
		||||
	if (needsCRC) {
 | 
			
		||||
		uint8_t ext[EXT_SIZE];
 | 
			
		||||
		int localExtIndex = 0;
 | 
			
		||||
 | 
			
		||||
		if (hasExt)
 | 
			
		||||
		{
 | 
			
		||||
		if (hasExt) {
 | 
			
		||||
			int maxFilenameLen;
 | 
			
		||||
			for(index = 0; index<EXT_SIZE && extIndex + index +1 < udfLen;
 | 
			
		||||
				index++ )
 | 
			
		||||
			{
 | 
			
		||||
			for (index = 0;
 | 
			
		||||
			     index < EXT_SIZE && extIndex + index + 1 < udfLen;
 | 
			
		||||
			     index++) {
 | 
			
		||||
				curr = udfName[extIndex + index + 1];
 | 
			
		||||
 | 
			
		||||
				if (curr == '/' || curr == 0)
 | 
			
		||||
				{
 | 
			
		||||
				if (curr == '/' || curr == 0) {
 | 
			
		||||
					needsCRC = 1;
 | 
			
		||||
					curr = ILLEGAL_CHAR_MARK;
 | 
			
		||||
					while(extIndex + index + 2 < udfLen && (index + 1 < EXT_SIZE
 | 
			
		||||
						&& (udfName[extIndex + index + 2] == '/' ||
 | 
			
		||||
							udfName[extIndex + index + 2] == 0)))
 | 
			
		||||
					while (extIndex + index + 2 < udfLen
 | 
			
		||||
					       && (index + 1 < EXT_SIZE
 | 
			
		||||
						   &&
 | 
			
		||||
						   (udfName
 | 
			
		||||
						    [extIndex + index + 2] ==
 | 
			
		||||
						    '/'
 | 
			
		||||
						    || udfName[extIndex +
 | 
			
		||||
							       index + 2] ==
 | 
			
		||||
						    0)))
 | 
			
		||||
						index++;
 | 
			
		||||
				}
 | 
			
		||||
				ext[localExtIndex++] = curr;
 | 
			
		||||
@@ -490,8 +463,7 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
 | 
			
		||||
				newIndex = maxFilenameLen;
 | 
			
		||||
			else
 | 
			
		||||
				newIndex = newExtIndex;
 | 
			
		||||
		}
 | 
			
		||||
		else if (newIndex > 250)
 | 
			
		||||
		} else if (newIndex > 250)
 | 
			
		||||
			newIndex = 250;
 | 
			
		||||
		newName[newIndex++] = CRC_MARK;
 | 
			
		||||
		valueCRC = udf_crc(fidName, fidNameLen, 0);
 | 
			
		||||
@@ -500,10 +472,9 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
 | 
			
		||||
		newName[newIndex++] = hexChar[(valueCRC & 0x00f0) >> 4];
 | 
			
		||||
		newName[newIndex++] = hexChar[(valueCRC & 0x000f)];
 | 
			
		||||
 | 
			
		||||
		if (hasExt)
 | 
			
		||||
		{
 | 
			
		||||
		if (hasExt) {
 | 
			
		||||
			newName[newIndex++] = EXT_MARK;
 | 
			
		||||
			for (index = 0;index < localExtIndex ;index++ )
 | 
			
		||||
			for (index = 0; index < localExtIndex; index++)
 | 
			
		||||
				newName[newIndex++] = ext[index];
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user