/* * fs/partitions/osf.c * * Code extracted from drivers/block/genhd.c * * Copyright (C) 1991-1998 Linus Torvalds * Re-organised Feb 1998 Russell King */ #include #include #include #include #include #include #include "check.h" #include "osf.h" int osf_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sector, int current_minor) { int i; int mask = (1 << hd->minor_shift) - 1; struct buffer_head *bh; struct disklabel { u32 d_magic; u16 d_type,d_subtype; u8 d_typename[16]; u8 d_packname[16]; u32 d_secsize; u32 d_nsectors; u32 d_ntracks; u32 d_ncylinders; u32 d_secpercyl; u32 d_secprtunit; u16 d_sparespertrack; u16 d_sparespercyl; u32 d_acylinders; u16 d_rpm, d_interleave, d_trackskew, d_cylskew; u32 d_headswitch, d_trkseek, d_flags; u32 d_drivedata[5]; u32 d_spare[5]; u32 d_magic2; u16 d_checksum; u16 d_npartitions; u32 d_bbsize, d_sbsize; struct d_partition { u32 p_size; u32 p_offset; u32 p_fsize; u8 p_fstype; u8 p_frag; u16 p_cpg; } d_partitions[8]; } * label; struct d_partition * partition; if (!(bh = bread(dev,0,get_ptable_blocksize(dev)))) { if (warn_no_part) printk("unable to read partition table\n"); return -1; } label = (struct disklabel *) (bh->b_data+64); partition = label->d_partitions; if (label->d_magic != DISKLABELMAGIC) { brelse(bh); return 0; } if (label->d_magic2 != DISKLABELMAGIC) { brelse(bh); return 0; } for (i = 0 ; i < label->d_npartitions; i++, partition++) { if ((current_minor & mask) == 0) break; if (partition->p_size) add_gd_partition(hd, current_minor, first_sector+partition->p_offset, partition->p_size); current_minor++; } printk("\n"); brelse(bh); return 1; }