The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/partitions/osf.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 <linux/fs.h>
   11 #include <linux/genhd.h>
   12 #include <linux/kernel.h>
   13 #include <linux/major.h>
   14 #include <linux/string.h>
   15 #include <linux/blk.h>
   16 
   17 #include "check.h"
   18 #include "osf.h"
   19 
   20 int osf_partition(struct gendisk *hd, struct block_device *bdev,
   21                 unsigned long first_sector, int current_minor)
   22 {
   23         int i;
   24         Sector sect;
   25         unsigned char *data;
   26         int mask = (1 << hd->minor_shift) - 1;
   27         struct disklabel {
   28                 u32 d_magic;
   29                 u16 d_type,d_subtype;
   30                 u8 d_typename[16];
   31                 u8 d_packname[16];
   32                 u32 d_secsize;
   33                 u32 d_nsectors;
   34                 u32 d_ntracks;
   35                 u32 d_ncylinders;
   36                 u32 d_secpercyl;
   37                 u32 d_secprtunit;
   38                 u16 d_sparespertrack;
   39                 u16 d_sparespercyl;
   40                 u32 d_acylinders;
   41                 u16 d_rpm, d_interleave, d_trackskew, d_cylskew;
   42                 u32 d_headswitch, d_trkseek, d_flags;
   43                 u32 d_drivedata[5];
   44                 u32 d_spare[5];
   45                 u32 d_magic2;
   46                 u16 d_checksum;
   47                 u16 d_npartitions;
   48                 u32 d_bbsize, d_sbsize;
   49                 struct d_partition {
   50                         u32 p_size;
   51                         u32 p_offset;
   52                         u32 p_fsize;
   53                         u8  p_fstype;
   54                         u8  p_frag;
   55                         u16 p_cpg;
   56                 } d_partitions[8];
   57         } * label;
   58         struct d_partition * partition;
   59 
   60         data = read_dev_sector(bdev, 0, &sect);
   61         if (!data)
   62                 return -1;
   63 
   64         label = (struct disklabel *) (data+64);
   65         partition = label->d_partitions;
   66         if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
   67                 put_dev_sector(sect);
   68                 return 0;
   69         }
   70         if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
   71                 put_dev_sector(sect);
   72                 return 0;
   73         }
   74         for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
   75                 if ((current_minor & mask) == 0)
   76                         break;
   77                 if (le32_to_cpu(partition->p_size))
   78                         add_gd_partition(hd, current_minor,
   79                                 first_sector+le32_to_cpu(partition->p_offset),
   80                                 le32_to_cpu(partition->p_size));
   81                 current_minor++;
   82         }
   83         printk("\n");
   84         put_dev_sector(sect);
   85         return 1;
   86 }
   87 

Cache object: 6f3550c682082433ff50aef52b628a50


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.