root/arch/m68k/atari/atapart.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. atari_check_partition

   1 /*
   2  * linux/atari/atapart.c
   3  *
   4  * Atari partition checking driver for 680x0 Linux
   5  * Written by Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de)
   6  *
   7  * 5/3/94 Roman Hodek:
   8  *   Added some sanity checks
   9  *   Linux device names start from 1 not 0, so I changed the initial value
  10  *   for i to 1.
  11  *
  12  * 10/09/94 Guenther Kelleter:
  13  *   Added support for ICD/Supra partition info.
  14  *
  15  * This file is subject to the terms and conditions of the GNU General Public
  16  * License.  See the file README.legal in the main directory of this archive
  17  * for more details.
  18  */
  19 
  20 #include <linux/fs.h>
  21 #include <linux/genhd.h>
  22 #include <linux/kernel.h>
  23 
  24 #include <asm/atari_rootsec.h>
  25 
  26 /* ++guenther: this should be settable by the user ("make config")?.
  27  */
  28 #define ICD_PARTS
  29 
  30 extern int current_minor;
  31 
  32 void
  33 atari_check_partition (struct gendisk *hd, unsigned int dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  34 {
  35   int i, minor = current_minor, m_lim = current_minor + hd->max_p;
  36   struct buffer_head *bh;
  37   struct rootsector *rs;
  38   struct partition_info *pi;
  39   ulong extensect;
  40 #ifdef ICD_PARTS
  41   int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
  42 #endif
  43 
  44   bh = bread (dev, 0, 1024);
  45   if (!bh)
  46     {
  47       printk (" unable to read block 0\n");
  48       return;
  49     }
  50 
  51   rs = (struct rootsector *) bh->b_data;
  52   printk ("  %s%c:", hd->major_name, 'a' + (minor >> hd->minor_shift));
  53 
  54   pi = &rs->part[0];
  55   for (i = 1; pi < &rs->part[4] && minor < m_lim; i++, minor++, pi++)
  56     {
  57       if (pi->flg & 1)
  58   /* active partition */
  59   {
  60     if (memcmp (pi->id, "XGM", 3) == 0)
  61       /* extension partition */
  62       {
  63         struct rootsector *xrs;
  64         struct buffer_head *xbh;
  65         ulong partsect;
  66 
  67 #ifdef ICD_PARTS
  68         part_fmt = 1;
  69 #endif
  70         partsect = extensect = pi->st;
  71         while (1)
  72       {
  73         xbh = bread (dev, partsect / 2, 1024);
  74         if (!xbh)
  75           {
  76             printk (" block %ld read failed\n", partsect);
  77             return;
  78           }
  79         if (partsect & 1)
  80           xrs = (struct rootsector *) &xbh->b_data[512];
  81         else
  82           xrs = (struct rootsector *) &xbh->b_data[0];
  83 
  84                 /* ++roman: sanity check: bit 0 of flg field must be set */
  85                 if (!(xrs->part[0].flg & 1)) {
  86                         printk( "\nFirst sub-partition in extended partition is not valid!\n" );
  87                         break;
  88                 }
  89                 
  90         hd->part[minor].start_sect = partsect + xrs->part[0].st;
  91         hd->part[minor].nr_sects = xrs->part[0].siz;
  92         printk (" %s%c%d", hd->major_name,
  93             'a' + (minor >> hd->minor_shift), i);
  94 
  95                 if (!(xrs->part[1].flg & 1)) {
  96                         /* end of linked partition list */
  97                         brelse( xbh );
  98                         break;
  99                 }
 100                 if (memcmp( xrs->part[1].id, "XGM", 3 ) != 0) {
 101                         printk( "\nID of extended partition is not XGM!\n" );
 102                         brelse( xbh );
 103                         break;
 104                 }
 105                 
 106                 partsect = xrs->part[1].st + extensect;
 107         brelse (xbh);
 108         i++;
 109         minor++;
 110         if (minor >= m_lim) {
 111                         printk( "\nMaximum number of partitions reached!\n" );
 112                         break;
 113                 }
 114       }
 115       }
 116     else
 117       {
 118         /* we don't care about other id's */
 119         hd->part[minor].start_sect = pi->st;
 120         hd->part[minor].nr_sects = pi->siz;
 121         printk (" %s%c%d", hd->major_name,
 122             'a' + (minor >> hd->minor_shift), i);
 123 
 124       }
 125   }
 126     }
 127 #ifdef ICD_PARTS
 128   if ( part_fmt!=1 ) /* no extended partitions -> test ICD-format */
 129   {
 130     pi = &rs->icdpart[0];
 131     /* sanity check: no ICD format if first partition invalid */
 132     if (memcmp (pi->id, "GEM", 3) == 0 ||
 133         memcmp (pi->id, "BGM", 3) == 0 ||
 134         memcmp (pi->id, "RAW", 3) == 0 )
 135     {
 136       for (i = 1; pi < &rs->icdpart[8] && minor < m_lim; i++, minor++, pi++)
 137       {
 138         /* accept only GEM,BGM,RAW partitions */
 139         if (pi->flg & 1 && 
 140             (memcmp (pi->id, "GEM", 3) == 0 ||
 141              memcmp (pi->id, "BGM", 3) == 0 ||
 142              memcmp (pi->id, "RAW", 3) == 0) )
 143         {
 144           part_fmt = 2;
 145           hd->part[minor].start_sect = pi->st;
 146           hd->part[minor].nr_sects = pi->siz;
 147           printk (" %s%c%d", hd->major_name,
 148               'a' + (minor >> hd->minor_shift), i);
 149         }
 150       }
 151     }
 152   }
 153 #endif
 154   brelse (bh);
 155 
 156   printk ("\n");
 157 }
 158 

/* [previous][next][first][last][top][bottom][index][help] */