kernels/linux-2.4.0/fs/partitions/msdos.c
/* 
 * Create devices for BSD partitions listed in a disklabel, under a
 * dos-like partition. See extended_partition() for more information.
 */
Create devices for BSD partitions listed in a disklabel, under a
dos-like partition. See extended_partition() for more information.
Create devices for BSD partitions listed in a disklabel under a dos - like partition . See extended_partition () for more information .
static void bsd_disklabel_partition(struct gendisk *hd, int minor, int type) {
	struct buffer_head *bh;
	struct bsd_disklabel *l;
	struct bsd_partition *p;
	int max_partitions;
	int mask = (1 << hd->minor_shift) - 1;
	char buf[40];
	if (!(bh = get_partition_table_block(hd, minor, 0)))
		return;
	l = (struct bsd_disklabel *) (bh->b_data+512);
	if (l->d_magic != BSD_DISKMAGIC) {
		brelse(bh);
		return;
	}
	printk(" %s:", disk_name(hd, minor, buf));
	printk((type == OPENBSD_PARTITION) ? " <openbsd:" :
	       (type == NETBSD_PARTITION) ? " <netbsd:" : " <bsd:");
	max_partitions = ((type == OPENBSD_PARTITION) ? OPENBSD_MAXPARTITIONS
			                              : BSD_MAXPARTITIONS);
	if (l->d_npartitions < max_partitions)
		max_partitions = l->d_npartitions;
	for (p = l->d_partitions; p - l->d_partitions <  max_partitions; p++) {
		if ((current_minor & mask) >= (4 + hd->max_p))
			break;
		if (p->p_fstype != BSD_FS_UNUSED) 
			check_and_add_bsd_partition(hd, p, minor);
	}
	bforget(bh);
	printk(" >\n");
}
static void bsd_disklabel_partition ( struct gendisk * hd , int minor , int type ) { struct buffer_head * bh ; struct bsd_disklabel * l ; struct bsd_partition * p ; int max_partitions ; int mask = ( 1 << hd -> minor_shift ) - 1 ; char buf [ 40 ] ; if ( ! ( bh = get_partition_table_block ( hd , minor , 0 ) ) ) return ; l = ( struct bsd_disklabel * ) ( bh -> b_data + 512 ) ; if ( l -> d_magic != BSD_DISKMAGIC ) { brelse ( bh ) ; return ; } printk ( " " , disk_name ( hd , minor , buf ) ) ; printk ( ( type == OPENBSD_PARTITION ) ? " " : ( type == NETBSD_PARTITION ) ? " " : " " ) ; max_partitions = ( ( type == OPENBSD_PARTITION ) ? OPENBSD_MAXPARTITIONS : BSD_MAXPARTITIONS ) ; if ( l -> d_npartitions < max_partitions ) max_partitions = l -> d_npartitions ; for ( p = l -> d_partitions ; p - l -> d_partitions < max_partitions ; p ++ ) { if ( ( current_minor & mask ) >= ( 4 + hd -> max_p ) ) break ; if ( p -> p_fstype != BSD_FS_UNUSED ) check_and_add_bsd_partition ( hd , p , minor ) ; } bforget ( bh ) ; printk ( " \n " ) ; }
Create devices for BSD partitions listed in a disklabel, under a
 dos-like partition.
Create devices for BSD partitions listed in a disklabel under a dos - like partition .
/* Use bforget(), as we have changed the disk setup */