Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
osf.c
Go to the documentation of this file.
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 #define MAX_OSF_PARTITIONS 18
14 
16 {
17  int i;
18  int slot = 1;
19  unsigned int npartitions;
20  Sector sect;
21  unsigned char *data;
22  struct disklabel {
25  u8 d_typename[16];
26  u8 d_packname[16];
39  __le32 d_spare[5];
44  struct d_partition {
45  __le32 p_size;
48  u8 p_fstype;
49  u8 p_frag;
50  __le16 p_cpg;
52  } * label;
53  struct d_partition * partition;
54 
55  data = read_part_sector(state, 0, &sect);
56  if (!data)
57  return -1;
58 
59  label = (struct disklabel *) (data+64);
60  partition = label->d_partitions;
61  if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
62  put_dev_sector(sect);
63  return 0;
64  }
65  if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
66  put_dev_sector(sect);
67  return 0;
68  }
69  npartitions = le16_to_cpu(label->d_npartitions);
70  if (npartitions > MAX_OSF_PARTITIONS) {
71  put_dev_sector(sect);
72  return 0;
73  }
74  for (i = 0 ; i < npartitions; i++, partition++) {
75  if (slot == state->limit)
76  break;
77  if (le32_to_cpu(partition->p_size))
78  put_partition(state, slot,
79  le32_to_cpu(partition->p_offset),
80  le32_to_cpu(partition->p_size));
81  slot++;
82  }
83  strlcat(state->pp_buf, "\n", PAGE_SIZE);
84  put_dev_sector(sect);
85  return 1;
86 }