OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [partitions/] [ultrix.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
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, struct block_device *bdev,
18
                            unsigned long first_sector, int first_part_minor)
19
{
20
        int i;
21
        Sector sect;
22
        unsigned char *data;
23
        struct ultrix_disklabel {
24
                s32     pt_magic;       /* magic no. indicating part. info exits */
25
                s32     pt_valid;       /* set by driver if pt is current */
26
                struct  pt_info {
27
                        s32             pi_nblocks; /* no. of sectors */
28
                        u32             pi_blkoff;  /* block offset for start */
29
                } pt_part[8];
30
        } *label;
31
 
32
#define PT_MAGIC        0x032957        /* Partition magic number */
33
#define PT_VALID        1               /* Indicates if struct is valid */
34
 
35
        data = read_dev_sector(bdev, (16384 - sizeof(*label))/512, &sect);
36
        if (!data)
37
                return -1;
38
 
39
        label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
40
 
41
        if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
42
                for (i=0; i<8; i++, first_part_minor++)
43
                        if (label->pt_part[i].pi_nblocks)
44
                                add_gd_partition(hd, first_part_minor,
45
                                              label->pt_part[i].pi_blkoff,
46
                                              label->pt_part[i].pi_nblocks);
47
                put_dev_sector(sect);
48
                printk ("\n");
49
                return 1;
50
        } else {
51
                put_dev_sector(sect);
52
                return 0;
53
        }
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.