[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cdi-devel] [PATCH] ata: Remove partition handling



Handling partitions is not the disk driver's job. Remove the
corresponding code.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 ata/device.c       |   57 ----------------------------------
 ata/libpartition.c |   86 ----------------------------------------------------
 ata/libpartition.h |   58 -----------------------------------
 3 files changed, 0 insertions(+), 201 deletions(-)
 delete mode 100644 ata/libpartition.c
 delete mode 100644 ata/libpartition.h

diff --git a/ata/device.c b/ata/device.c
index 7339d65..dd087c3 100644
--- a/ata/device.c
+++ b/ata/device.c
@@ -36,7 +36,6 @@
 #include "cdi/scsi.h"
 
 #include "device.h"
-#include "libpartition.h"
 
 // IRQ-Handler
 static inline void ata_controller_irq(struct cdi_device* dev);
@@ -157,59 +156,6 @@ int ata_wait_irq(struct ata_controller* controller, uint32_t timeout)
     return 1;
 }
 
-/**
- * Partitionstabelle auf einem ATA-Geraet verarbeiten
- */
-void ata_parse_partitions(struct ata_device* dev)
-{
-    struct partition_table partition_table;
-    uint8_t mbr[ATA_SECTOR_SIZE];
-    int i;
-
-    // Die Partitionstabelle liegt im MBR
-    if (!dev->read_sectors(dev, 0, 1, mbr)) {
-        DEBUG("Fehler beim Einlesen der Partitionstabelle");
-        return;
-    }
-
-    // Partitionstabelle Verarbeiten
-    if (!partition_table_fill(&partition_table, mbr)) {
-        DEBUG("Fehler beim Verarbeiten der Partitionstabelle");
-        return;
-    }
-
-    // Ansonsten wird die Tabelle jetzt verarbeitet
-    for (i = 0; i < 4; i++) {
-        if (partition_table.entries[i].used) {
-            // Erweiterter Eintrag => ueberspringen
-            if (partition_table.entries[i].type == PARTITION_TYPE_EXTENDED) {
-                DEBUG("TODO Erweiterte Partitionstabelleneintraege\n");
-                continue;
-            }
-            
-            struct ata_partition* partition = malloc(sizeof(*partition));
-            partition->realdev = dev;
-            partition->null = NULL;
-            partition->start = partition_table.entries[i].start;
-            partition->dev.storage.block_size = ATA_SECTOR_SIZE;
-            partition->dev.storage.block_count = partition_table.entries[i].size;
-            DEBUG("Partition von %d bis %d\n", partition->start, partition->dev.storage.block_count + partition->start - 1);
-            asprintf((char**) &(partition->dev.storage.dev.name), "ata%01d%01d_p%01d",
-                (uint32_t) dev->controller->id, dev->id, cdi_list_size(dev->
-                partition_list));
-
-            // Geraet registrieren
-            partition->dev.storage.dev.driver = &dev->controller->storage->drv;
-            ata_init_device((struct ata_device*) partition);
-            cdi_list_push(dev->controller->storage->drv.devices, partition);
-
-            // An Partitionsliste fuer das aktuelle Geraet anhaengen
-            cdi_list_push(dev->partition_list, partition);
-        }
-    }
-}
-
-
 
 
 /**
@@ -296,9 +242,6 @@ void ata_init_controller(struct ata_controller* controller)
                 asprintf((char**) &(dev->dev.storage.dev.name), "ata%01d%01d",
                     (uint32_t) controller->id, i);
 
-                // Partitionen parsen
-                ata_parse_partitions(dev);
-
                 // Geraet registrieren
                 dev->dev.storage.dev.driver = &controller->storage->drv;
                 ata_init_device(dev);
diff --git a/ata/libpartition.c b/ata/libpartition.c
deleted file mode 100644
index 17c41e1..0000000
--- a/ata/libpartition.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
- *
- * This code is derived from software contributed to the tyndur Project
- * by Antoine Kaufmann.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "libpartition.h"
-#include <stdint.h>
-
-/**
- * Roher Partitionstabelleneintrag
- */
-struct raw_entry {
-    uint8_t active;
-    uint8_t begin_chs[3];
-    uint8_t type;
-    uint8_t end_chs[3];
-    uint32_t start;
-    uint32_t size;
-} PACKED;
-
-/**
- * Uebergebene Partitionstabelle anhand des Sektors fuellen
- *
- * @return 1 wenn die Tabelle erfolgreich gefuellt wurde, 0 sonst
- */
-int partition_table_fill(struct partition_table* table, void* sector)
-{
-    struct raw_entry* entry = (struct raw_entry*) (sector +
-        PARTITION_TABLE_OFFSET);
-    uint16_t* signature = sector + PARTITION_TABLE_SIG_OFFSET;
-    int i;
-
-    // Zuerst die Signatur pruefen, denn ohne die muss garnicht weiter gesucht
-    // werden.
-    if (*signature != PARTITION_TABLE_SIGNATURE) {
-        return 0;
-    }
-    
-    // Wenn die Signatur existiert koennen die einzelnen Eintraege ausgelesen
-    // werden
-    for (i = 0; i < 4; i++) {
-        // Wenn 0 als Groesse eingetragen ist, ist der Eintrag unbenutzt
-        if (entry->size == 0) {
-            table->entries[i].used = 0;
-        } else {
-            table->entries[i].used = 1;
-
-            // Fuer erweiterte Partitionen wollen wir generell Typ 0x5, die
-            // anderen aus Windows und Linux werden deshalb ausgetauscht.
-            if ((entry->type == 0x0F) || (entry->type == 0x85)) {
-                table->entries[i].type = PARTITION_TYPE_EXTENDED;
-            } else {
-                table->entries[i].type = entry->type;
-            }
-
-            table->entries[i].start = entry->start;
-            table->entries[i].size = entry->size;
-        }
-        entry++;
-    }
-    return 1;
-}
-
diff --git a/ata/libpartition.h b/ata/libpartition.h
deleted file mode 100644
index e8d2837..0000000
--- a/ata/libpartition.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
- *
- * This code is derived from software contributed to the tyndur Project
- * by Antoine Kaufmann.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _LIBPARTITION_H_
-#define _LIBPARTITION_H_
-
-#include <stdint.h>
-
-#define PACKED __attribute__((packed))
-#define PARTITION_TABLE_OFFSET 446
-#define PARTITION_TABLE_SIG_OFFSET 510;
-#define PARTITION_TABLE_SIGNATURE 0xAA55
-
-// Typ fuer eine Erweiterte Partition, deren Startsektor wieder eine
-// Partitionstabelle beinhaltet.
-#define PARTITION_TYPE_EXTENDED 0x05
-
-struct partition {
-    uint8_t     used;
-    uint8_t     type;
-    uint32_t    start;
-    uint32_t    size;
-};
-
-struct partition_table {
-    struct partition entries[4];
-};
-
-// Fuellt die Angegebene Partitionstabelle anhand des uebergebenen Sektors auf
-int partition_table_fill(struct partition_table* table, void* sector);
-
-#endif // ifndef _LIBPARTITION_H_
-
-- 
1.6.0.2