Changeset 3ab9c76d in rtems


Ignore:
Timestamp:
Mar 5, 2012, 3:22:33 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
113944fa
Parents:
0121172
git-author:
Sebastian Huber <sebastian.huber@…> (03/05/12 15:22:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/13/12 11:24:19)
Message:

libblock: Use new API for disk media

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/src/media.c

    r0121172 r3ab9c76d  
    88
    99/*
    10  * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    2323#include <string.h>
    2424#include <assert.h>
     25#include <unistd.h>
    2526
    2627#include <rtems.h>
    2728#include <rtems/bdbuf.h>
    28 #include <rtems/diskdevs.h>
     29#include <rtems/blkdev.h>
    2930#include <rtems/bdpart.h>
    3031#include <rtems/libio.h>
     
    3839
    3940typedef struct {
    40   dev_t physical_disk;
    41   dev_t logical_disk;
     41  size_t index;
    4242  rtems_blkdev_bnum begin;
    4343  rtems_blkdev_bnum count;
     
    578578  if (state == RTEMS_MEDIA_STATE_READY) {
    579579    partition *part = worker_arg;
    580     rtems_device_minor_number minor =
    581       rtems_filesystem_dev_minor_t(part->logical_disk);
    582     char *part_path = rtems_media_append_minor(src, minor);
     580    char *part_path = rtems_media_append_minor(src, part->index);
    583581
    584582    if (part_path == NULL) {
     
    586584    }
    587585
    588     sc = rtems_disk_create_log(
    589       part->logical_disk,
    590       part->physical_disk,
     586    sc = rtems_blkdev_create_partition(
     587      part_path,
     588      src,
    591589      part->begin,
    592       part->count,
    593       part_path
     590      part->count
    594591    );
    595592    if (sc != RTEMS_SUCCESSFUL) {
     
    607604static rtems_status_code attach_and_mount_partitions(
    608605  const char *disk_path,
    609   rtems_bdpart_partition *partitions,
     606  const rtems_bdpart_partition *partitions,
    610607  size_t count
    611608)
    612609{
    613610  rtems_status_code sc = RTEMS_SUCCESSFUL;
    614   rtems_device_major_number major = 0;
    615   rtems_device_minor_number minor = 0;
    616   dev_t dev = 0;
    617611  size_t i = 0;
    618612
    619   sc = rtems_media_get_device_identifier(disk_path, &dev);
    620   if (sc != RTEMS_SUCCESSFUL) {
    621     return RTEMS_INVALID_ID;
    622   }
    623 
    624   major = rtems_filesystem_dev_major_t(dev);
    625   minor = rtems_filesystem_dev_minor_t(dev) + 1;
    626 
    627   for (i = 0; i < count; ++i, ++minor) {
     613  for (i = 0; i < count; ++i) {
    628614    partition part_desc = {
    629       .physical_disk = dev,
    630       .logical_disk = rtems_filesystem_make_dev_t(major, minor),
     615      .index = i,
    631616      .begin = partitions [i].begin,
    632617      .count = partitions [i].end - partitions [i].begin
     
    808793)
    809794{
    810   rtems_status_code sc = RTEMS_SUCCESSFUL;
    811795  rtems_status_code rsc = RTEMS_SUCCESSFUL;
    812796
    813797  if (state == RTEMS_MEDIA_STATE_READY) {
    814     dev_t dev = 0;
    815     rtems_disk_device *dd = NULL;
    816 
    817     sc = rtems_media_get_device_identifier(src, &dev);
    818     if (sc != RTEMS_SUCCESSFUL) {
    819       return RTEMS_IO_ERROR;
    820     }
    821 
    822     dd = rtems_disk_obtain(dev);
    823     if (dd != NULL) {
    824       sc = rtems_bdbuf_syncdev(dd);
    825       if (sc != RTEMS_SUCCESSFUL) {
    826         rsc = RTEMS_IO_ERROR;
    827       }
    828     }
    829 
    830     sc = rtems_disk_delete(dev);
    831     if (sc != RTEMS_SUCCESSFUL) {
     798    int rv = unlink(src);
     799
     800    if (rv != 0) {
    832801      rsc = RTEMS_IO_ERROR;
    833     }
    834 
    835     if (dd != NULL) {
    836       rtems_bdbuf_purge_dev(dd);
    837       rtems_disk_release(dd);
    838     }
    839 
    840     if (rtems_filesystem_dev_minor_t(dev) == 0) {
    841       sc = rtems_io_unregister_driver(rtems_filesystem_dev_major_t(dev));
    842       if (sc != RTEMS_SUCCESSFUL) {
    843         rsc = RTEMS_IO_ERROR;
    844       }
    845802    }
    846803  }
Note: See TracChangeset for help on using the changeset viewer.