Remove videobook.tmpl
[linux-2.6] / fs / partitions / osf.c
1 /*
2  *  fs/partitions/osf.c
3  *
4  *  Code extracted from drivers/block/genhd.c
5  *
6  *  Copyright (C) 1991-1998  Linus Torvalds
7  *  Re-organised Feb 1998 Russell King
8  */
9
10 #include "check.h"
11 #include "osf.h"
12
13 int osf_partition(struct parsed_partitions *state, struct block_device *bdev)
14 {
15         int i;
16         int slot = 1;
17         Sector sect;
18         unsigned char *data;
19         struct disklabel {
20                 __le32 d_magic;
21                 __le16 d_type,d_subtype;
22                 u8 d_typename[16];
23                 u8 d_packname[16];
24                 __le32 d_secsize;
25                 __le32 d_nsectors;
26                 __le32 d_ntracks;
27                 __le32 d_ncylinders;
28                 __le32 d_secpercyl;
29                 __le32 d_secprtunit;
30                 __le16 d_sparespertrack;
31                 __le16 d_sparespercyl;
32                 __le32 d_acylinders;
33                 __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
34                 __le32 d_headswitch, d_trkseek, d_flags;
35                 __le32 d_drivedata[5];
36                 __le32 d_spare[5];
37                 __le32 d_magic2;
38                 __le16 d_checksum;
39                 __le16 d_npartitions;
40                 __le32 d_bbsize, d_sbsize;
41                 struct d_partition {
42                         __le32 p_size;
43                         __le32 p_offset;
44                         __le32 p_fsize;
45                         u8  p_fstype;
46                         u8  p_frag;
47                         __le16 p_cpg;
48                 } d_partitions[8];
49         } * label;
50         struct d_partition * partition;
51
52         data = read_dev_sector(bdev, 0, &sect);
53         if (!data)
54                 return -1;
55
56         label = (struct disklabel *) (data+64);
57         partition = label->d_partitions;
58         if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
59                 put_dev_sector(sect);
60                 return 0;
61         }
62         if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
63                 put_dev_sector(sect);
64                 return 0;
65         }
66         for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
67                 if (slot == state->limit)
68                         break;
69                 if (le32_to_cpu(partition->p_size))
70                         put_partition(state, slot,
71                                 le32_to_cpu(partition->p_offset),
72                                 le32_to_cpu(partition->p_size));
73                 slot++;
74         }
75         printk("\n");
76         put_dev_sector(sect);
77         return 1;
78 }