Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  fs/partitions/ultrix.c
0004  *
0005  *  Code extracted from drivers/block/genhd.c
0006  *
0007  *  Re-organised Jul 1999 Russell King
0008  */
0009 
0010 #include "check.h"
0011 
0012 int ultrix_partition(struct parsed_partitions *state)
0013 {
0014     int i;
0015     Sector sect;
0016     unsigned char *data;
0017     struct ultrix_disklabel {
0018         s32 pt_magic;   /* magic no. indicating part. info exits */
0019         s32 pt_valid;   /* set by driver if pt is current */
0020         struct  pt_info {
0021             s32     pi_nblocks; /* no. of sectors */
0022             u32     pi_blkoff;  /* block offset for start */
0023         } pt_part[8];
0024     } *label;
0025 
0026 #define PT_MAGIC    0x032957    /* Partition magic number */
0027 #define PT_VALID    1       /* Indicates if struct is valid */
0028 
0029     data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect);
0030     if (!data)
0031         return -1;
0032     
0033     label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
0034 
0035     if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
0036         for (i=0; i<8; i++)
0037             if (label->pt_part[i].pi_nblocks)
0038                 put_partition(state, i+1, 
0039                           label->pt_part[i].pi_blkoff,
0040                           label->pt_part[i].pi_nblocks);
0041         put_dev_sector(sect);
0042         strlcat(state->pp_buf, "\n", PAGE_SIZE);
0043         return 1;
0044     } else {
0045         put_dev_sector(sect);
0046         return 0;
0047     }
0048 }