kernels/linux-2.4.0/fs/udf/super.c
/*
 * udf_process_sequence
 *
 * PURPOSE
 *	Process a main/reserve volume descriptor sequence.
 *
 * PRE-CONDITIONS
 *	sb			Pointer to _locked_ superblock.
 *	block			First block of first extent of the sequence.
 *	lastblock		Lastblock of first extent of the sequence.
 *
 * HISTORY
 *	July 1, 1997 - Andrew E. Mileski
 *	Written, tested, and released.
 */
udf_process_sequence
PURPOSE
Process a main/reserve volume descriptor sequence.

PRE-CONDITIONS
sb                      Pointer to _locked_ superblock.
block                   First block of first extent of the sequence.
lastblock               Lastblock of first extent of the sequence.

HISTORY
July 1, 1997 - Andrew E. Mileski
Written, tested, and released.
udf_process_sequence PURPOSE Process a main / reserve volume descriptor sequence . PRE - CONDITIONS sb Pointer to _locked_ superblock . block First block of first extent of the sequence . lastblock Lastblock of first extent of the sequence . HISTORY July 1 1997 - Andrew E . Mileski Written tested and released .
static  int
udf_process_sequence(struct super_block *sb, long block, long lastblock, lb_addr *fileset)
{
	struct buffer_head *bh = NULL;
	struct udf_vds_record vds[VDS_POS_LENGTH];
	struct GenericDesc *gd;
	int done=0;
	int i,j;
	Uint32 vdsn;
	Uint16 ident;
	memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
	for (;(!done && block <= lastblock); block++)
	{
		bh = udf_read_tagged(sb, block, block, &ident);
		if (!bh) 
			break;
		gd = (struct GenericDesc *)bh->b_data;
		vdsn = le32_to_cpu(gd->volDescSeqNum);
		switch (ident)
		{
			case TID_PRIMARY_VOL_DESC: 
				if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum)
				{
					vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn;
					vds[VDS_POS_PRIMARY_VOL_DESC].block = block;
				}
				break;
			case TID_VOL_DESC_PTR: 
				if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum)
				{
					vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn;
					vds[VDS_POS_VOL_DESC_PTR].block = block;
				}
				break;
			case TID_IMP_USE_VOL_DESC: 
				if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum)
				{
					vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn;
					vds[VDS_POS_IMP_USE_VOL_DESC].block = block;
				}
				break;
			case TID_PARTITION_DESC: 
				if (!vds[VDS_POS_PARTITION_DESC].block)
					vds[VDS_POS_PARTITION_DESC].block = block;
				break;
			case TID_LOGICAL_VOL_DESC: 
				if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum)
				{
					vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn;
					vds[VDS_POS_LOGICAL_VOL_DESC].block = block;
				}
				break;
			case TID_UNALLOC_SPACE_DESC: 
				if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum)
				{
					vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn;
					vds[VDS_POS_UNALLOC_SPACE_DESC].block = block;
				}
				break;
			case TID_TERMINATING_DESC: 
				vds[VDS_POS_TERMINATING_DESC].block = block;
				done = 1;
				break;
		}
		udf_release_data(bh);
	}
	for (i=0; i<VDS_POS_LENGTH; i++)
	{
		if (vds[i].block)
		{
			bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
			if (i == VDS_POS_PRIMARY_VOL_DESC)
				udf_load_pvoldesc(sb, bh);
			else if (i == VDS_POS_LOGICAL_VOL_DESC)
				udf_load_logicalvol(sb, bh, fileset);
			else if (i == VDS_POS_PARTITION_DESC)
			{
				struct buffer_head *bh2 = NULL;
				udf_load_partdesc(sb, bh);
				for (j=vds[i].block+1; j<vds[VDS_POS_TERMINATING_DESC].block; j++)
				{
					bh2 = udf_read_tagged(sb, j, j, &ident);
					gd = (struct GenericDesc *)bh2->b_data;
					if (ident == TID_PARTITION_DESC)
						udf_load_partdesc(sb, bh2);
					udf_release_data(bh2);
				}
			}
			udf_release_data(bh);
		}
	}
	return 0;
}
static int udf_process_sequence ( struct super_block * sb , long block , long lastblock , lb_addr * fileset ) { struct buffer_head * bh = NULL ; struct udf_vds_record vds [ VDS_POS_LENGTH ] ; struct GenericDesc * gd ; int done = 0 ; int i , j ; Uint32 vdsn ; Uint16 ident ; memset ( vds , 0 , sizeof ( struct udf_vds_record ) * VDS_POS_LENGTH ) ; for ( ; ( ! done && block <= lastblock ) ; block ++ ) { bh = udf_read_tagged ( sb , block , block , & ident ) ; if ( ! bh ) break ; gd = ( struct GenericDesc * ) bh -> b_data ; vdsn = le32_to_cpu ( gd -> volDescSeqNum ) ; switch ( ident ) { case TID_PRIMARY_VOL_DESC : if ( vdsn >= vds [ VDS_POS_PRIMARY_VOL_DESC ] . volDescSeqNum ) { vds [ VDS_POS_PRIMARY_VOL_DESC ] . volDescSeqNum = vdsn ; vds [ VDS_POS_PRIMARY_VOL_DESC ] . block = block ; } break ; case TID_VOL_DESC_PTR : if ( vdsn >= vds [ VDS_POS_VOL_DESC_PTR ] . volDescSeqNum ) { vds [ VDS_POS_VOL_DESC_PTR ] . volDescSeqNum = vdsn ; vds [ VDS_POS_VOL_DESC_PTR ] . block = block ; } break ; case TID_IMP_USE_VOL_DESC : if ( vdsn >= vds [ VDS_POS_IMP_USE_VOL_DESC ] . volDescSeqNum ) { vds [ VDS_POS_IMP_USE_VOL_DESC ] . volDescSeqNum = vdsn ; vds [ VDS_POS_IMP_USE_VOL_DESC ] . block = block ; } break ; case TID_PARTITION_DESC : if ( ! vds [ VDS_POS_PARTITION_DESC ] . block ) vds [ VDS_POS_PARTITION_DESC ] . block = block ; break ; case TID_LOGICAL_VOL_DESC : if ( vdsn >= vds [ VDS_POS_LOGICAL_VOL_DESC ] . volDescSeqNum ) { vds [ VDS_POS_LOGICAL_VOL_DESC ] . volDescSeqNum = vdsn ; vds [ VDS_POS_LOGICAL_VOL_DESC ] . block = block ; } break ; case TID_UNALLOC_SPACE_DESC : if ( vdsn >= vds [ VDS_POS_UNALLOC_SPACE_DESC ] . volDescSeqNum ) { vds [ VDS_POS_UNALLOC_SPACE_DESC ] . volDescSeqNum = vdsn ; vds [ VDS_POS_UNALLOC_SPACE_DESC ] . block = block ; } break ; case TID_TERMINATING_DESC : vds [ VDS_POS_TERMINATING_DESC ] . block = block ; done = 1 ; break ; } udf_release_data ( bh ) ; } for ( i = 0 ; i < VDS_POS_LENGTH ; i ++ ) { if ( vds [ i ] . block ) { bh = udf_read_tagged ( sb , vds [ i ] . block , vds [ i ] . block , & ident ) ; if ( i == VDS_POS_PRIMARY_VOL_DESC ) udf_load_pvoldesc ( sb , bh ) ; else if ( i == VDS_POS_LOGICAL_VOL_DESC ) udf_load_logicalvol ( sb , bh , fileset ) ; else if ( i == VDS_POS_PARTITION_DESC ) { struct buffer_head * bh2 = NULL ; udf_load_partdesc ( sb , bh ) ; for ( j = vds [ i ] . block + 1 ; j < vds [ VDS_POS_TERMINATING_DESC ] . block ; j ++ ) { bh2 = udf_read_tagged ( sb , j , j , & ident ) ; gd = ( struct GenericDesc * ) bh2 -> b_data ; if ( ident == TID_PARTITION_DESC ) udf_load_partdesc ( sb , bh2 ) ; udf_release_data ( bh2 ) ; } } udf_release_data ( bh ) ; } } return 0 ; }
udf_process_sequence
 PURPOSE
      Process a main/reserve volume descriptor sequence.
udf_process_sequence PURPOSE Process a main / reserve volume descriptor sequence .
/* Read the main descriptor sequence */ /* Process each descriptor (ISO 13346 3/8.3-8.4) */ /* ISO 13346 3/10.1 */ /* ISO 13346 3/10.3 */ /* ISO 13346 3/10.4 */ /* ISO 13346 3/10.5 */ /* ISO 13346 3/10.6 */ /* ISO 13346 3/10.8 */ /* ISO 13346 3/10.9 */