/* * 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, kdev_t dev, int max_partitions) { struct buffer_head *bh; struct bsd_disklabel *l; struct bsd_partition *p; int mask = (1 << hd->minor_shift) - 1; if (!(bh = bread(dev,0,get_ptable_blocksize(dev)))) return; bh->b_state = 0; l = (struct bsd_disklabel *) (bh->b_data+512); if (l->d_magic != BSD_DISKMAGIC) { brelse(bh); return; } 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, dev); } brelse(bh); }
/* * Create devices for BSD partitions listed in a disklabel, under a * dos-like partition. See extended_partition() for more information. */ static void do_bsd_partition(struct gendisk *hd, struct block_device *bdev, int minor, int *current_minor, char *name, int max_partitions) { long offset = hd->part[minor].start_sect; Sector sect; struct bsd_disklabel *l; struct bsd_partition *p; int mask = (1 << hd->minor_shift) - 1; char buf[40]; l = (struct bsd_disklabel *)read_dev_sector(bdev, offset+1, §); if (!l) return; if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) { put_dev_sector(sect); return; } printk(" %s: <%s", partition_name(hd, minor, buf), name); if (le16_to_cpu(l->d_npartitions) < max_partitions) max_partitions = le16_to_cpu(l->d_npartitions); for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) { if ((*current_minor & mask) == 0) break; if (p->p_fstype == BSD_FS_UNUSED) continue; check_and_add_bsd_partition(hd, p, minor, current_minor); } put_dev_sector(sect); printk(" >\n"); }