Fork me on GitHub

root/drivers/block/part.c

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

DEFINITIONS

This source file includes following definitions.
  1. read_msdos_partition

   1 /*
   2  * fiwix/drivers/block/part.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/ide.h>
   9 #include <fiwix/ide_hd.h>
  10 #include <fiwix/fs.h>
  11 #include <fiwix/part.h>
  12 #include <fiwix/mm.h>
  13 #include <fiwix/errno.h>
  14 #include <fiwix/stdio.h>
  15 #include <fiwix/string.h>
  16 
  17 int read_msdos_partition(__dev_t dev, struct partition *part)
  18 {
  19         char *buffer;
  20 
  21         if(!(buffer = (void *)kmalloc())) {
  22                 return -ENOMEM;
  23         }
  24 
  25         if(ide_hd_read(dev, PARTITION_BLOCK, buffer, BLKSIZE_1K) <= 0) {
  26                 printk("WARNING: %s(): unable to read partition block in device %d,%d.\n", __FUNCTION__, MAJOR(dev), MINOR(dev));
  27                 kfree((unsigned int)buffer);
  28                 return -EIO;
  29         }
  30 
  31         memcpy_b(part, (void *)(buffer + MBR_CODE_SIZE), sizeof(struct partition) * NR_PARTITIONS);
  32         kfree((unsigned int)buffer);
  33         return 0;
  34 }

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