File: /usr/src/linux/fs/partitions/ultrix.c

1     /*
2      *  fs/partitions/ultrix.c
3      *
4      *  Code extracted from drivers/block/genhd.c
5      *
6      *  Re-organised Jul 1999 Russell King
7      */
8     
9     #include <linux/fs.h>
10     #include <linux/genhd.h>
11     #include <linux/kernel.h>
12     #include <linux/major.h>
13     #include <linux/blk.h>
14     
15     #include "check.h"
16     
17     int ultrix_partition(struct gendisk *hd, kdev_t dev,
18                                 unsigned long first_sector, int first_part_minor)
19     {
20     	int i;
21     	struct buffer_head *bh;
22     	struct ultrix_disklabel {
23     		s32	pt_magic;	/* magic no. indicating part. info exits */
24     		s32	pt_valid;	/* set by driver if pt is current */
25     		struct  pt_info {
26     			s32		pi_nblocks; /* no. of sectors */
27     			u32		pi_blkoff;  /* block offset for start */
28     		} pt_part[8];
29     	} *label;
30     
31     #define PT_MAGIC	0x032957	/* Partition magic number */
32     #define PT_VALID	1		/* Indicates if struct is valid */
33     
34     #define	SBLOCK	((unsigned long)((16384 - sizeof(struct ultrix_disklabel)) \
35                       /get_ptable_blocksize(dev)))
36     
37     	bh = bread (dev, SBLOCK, get_ptable_blocksize(dev));
38     	if (!bh) {
39     		if (warn_no_part) printk (" unable to read block 0x%lx\n", SBLOCK);
40     		return -1;
41     	}
42     	
43     	label = (struct ultrix_disklabel *)(bh->b_data
44                                                 + get_ptable_blocksize(dev)
45                                                 - sizeof(struct ultrix_disklabel));
46     
47     	if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
48     		for (i=0; i<8; i++, first_part_minor++)
49     			if (label->pt_part[i].pi_nblocks)
50     				add_gd_partition(hd, first_part_minor, 
51     					      label->pt_part[i].pi_blkoff,
52     					      label->pt_part[i].pi_nblocks);
53     		brelse(bh);
54     		printk ("\n");
55     		return 1;
56     	} else {
57     		brelse(bh);
58     		return 0;
59     	}
60     }
61