* better
[mascara-docs.git] / i386 / linux-2.3.21 / fs / partitions / osf.c
blob6cd1540c0f4b810c325c7e882535cc877e8a1cb9
1 /*
2 * fs/partitions/osf.c
4 * Code extracted from drivers/block/genhd.c
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
10 #include <linux/fs.h>
11 #include <linux/genhd.h>
12 #include <linux/kernel.h>
13 #include <linux/major.h>
14 #include <linux/string.h>
15 #include <linux/blk.h>
17 #include "check.h"
18 #include "osf.h"
20 int osf_partition(struct gendisk *hd, kdev_t dev, unsigned long first_sector,
21 int current_minor)
23 int i;
24 int mask = (1 << hd->minor_shift) - 1;
25 struct buffer_head *bh;
26 struct disklabel {
27 u32 d_magic;
28 u16 d_type,d_subtype;
29 u8 d_typename[16];
30 u8 d_packname[16];
31 u32 d_secsize;
32 u32 d_nsectors;
33 u32 d_ntracks;
34 u32 d_ncylinders;
35 u32 d_secpercyl;
36 u32 d_secprtunit;
37 u16 d_sparespertrack;
38 u16 d_sparespercyl;
39 u32 d_acylinders;
40 u16 d_rpm, d_interleave, d_trackskew, d_cylskew;
41 u32 d_headswitch, d_trkseek, d_flags;
42 u32 d_drivedata[5];
43 u32 d_spare[5];
44 u32 d_magic2;
45 u16 d_checksum;
46 u16 d_npartitions;
47 u32 d_bbsize, d_sbsize;
48 struct d_partition {
49 u32 p_size;
50 u32 p_offset;
51 u32 p_fsize;
52 u8 p_fstype;
53 u8 p_frag;
54 u16 p_cpg;
55 } d_partitions[8];
56 } * label;
57 struct d_partition * partition;
59 if (!(bh = bread(dev,0,get_ptable_blocksize(dev)))) {
60 printk("unable to read partition table\n");
61 return -1;
63 label = (struct disklabel *) (bh->b_data+64);
64 partition = label->d_partitions;
65 if (label->d_magic != DISKLABELMAGIC) {
66 brelse(bh);
67 return 0;
69 if (label->d_magic2 != DISKLABELMAGIC) {
70 brelse(bh);
71 return 0;
73 for (i = 0 ; i < label->d_npartitions; i++, partition++) {
74 if ((current_minor & mask) == 0)
75 break;
76 if (partition->p_size)
77 add_gd_partition(hd, current_minor,
78 first_sector+partition->p_offset,
79 partition->p_size);
80 current_minor++;
82 printk("\n");
83 brelse(bh);
84 return 1;