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/mac.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/mac.c
    3  *
    4  *  Code extracted from drivers/block/genhd.c
    5  *  Copyright (C) 1991-1998  Linus Torvalds
    6  *  Re-organised Feb 1998 Russell King
    7  */
    8 
    9 #include <linux/config.h>
   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 #include <linux/ctype.h>
   17 
   18 #include <asm/system.h>
   19 
   20 #include "check.h"
   21 #include "mac.h"
   22 
   23 /*
   24  * Code to understand MacOS partition tables.
   25  */
   26 
   27 int mac_partition(struct gendisk *hd, struct block_device *bdev,
   28                 unsigned long fsec, int first_part_minor)
   29 {
   30         Sector sect;
   31         unsigned char *data;
   32         int blk, blocks_in_map;
   33         unsigned secsize;
   34         struct mac_partition *part;
   35         struct mac_driver_desc *md;
   36 
   37         /* Get 0th block and look at the first partition map entry. */
   38         md = (struct mac_driver_desc *) read_dev_sector(bdev, 0, &sect);
   39         if (!md)
   40                 return -1;
   41         if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) {
   42                 put_dev_sector(sect);
   43                 return 0;
   44         }
   45         secsize = be16_to_cpu(md->block_size);
   46         put_dev_sector(sect);
   47         data = read_dev_sector(bdev, secsize/512, &sect);
   48         if (!data)
   49                 return -1;
   50         part = (struct mac_partition *) (data + secsize%512);
   51         if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
   52                 put_dev_sector(sect);
   53                 return 0;               /* not a MacOS disk */
   54         }
   55         printk(" [mac]");
   56         blocks_in_map = be32_to_cpu(part->map_count);
   57         for (blk = 1; blk <= blocks_in_map; ++blk) {
   58                 int pos = blk * secsize;
   59                 put_dev_sector(sect);
   60                 data = read_dev_sector(bdev, pos/512, &sect);
   61                 if (!data)
   62                         return -1;
   63                 part = (struct mac_partition *) (data + pos%512);
   64                 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC)
   65                         break;
   66                 add_gd_partition(hd, first_part_minor,
   67                         fsec + be32_to_cpu(part->start_block) * (secsize/512),
   68                         be32_to_cpu(part->block_count) * (secsize/512));
   69 
   70                 ++first_part_minor;
   71         }
   72 
   73         put_dev_sector(sect);
   74         printk("\n");
   75         return 1;
   76 }
   77 

Cache object: da85d8b252ea0c1ae4885794bbf5c935


[ 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.