Annotation of OSKit-Mach/oskit/ds_partition.c, revision 1.1

1.1     ! root        1: /* device server routines for disk partitions within oskit block devices
        !             2:  */
        !             3: 
        !             4: #include "ds_oskit.h"
        !             5: 
        !             6: #include <oskit/io/blkio.h>
        !             7: #include <oskit/diskpart/diskpart.h>
        !             8: 
        !             9: static io_return_t
        !            10: adjust_recnum (device_t dev, recnum_t *recnum, unsigned int count)
        !            11: {
        !            12:   recnum_t countrecs = count / dev->com.blkpart.blk->com.blk.size;
        !            13:   if (*recnum + countrecs > dev->com.blkpart.part->size)
        !            14:     INVALREC;
        !            15:   *recnum += dev->com.blkpart.part->start;
        !            16:   return 0;
        !            17: }
        !            18: 
        !            19: io_return_t
        !            20: ds_blkpart_write (device_t dev, ipc_port_t reply_port,
        !            21:                  mach_msg_type_name_t reply_port_type, dev_mode_t mode,
        !            22:                  recnum_t recnum, io_buf_ptr_t data, unsigned int count,
        !            23:                  int *bytes_written)
        !            24: {
        !            25:   return (adjust_recnum (dev, &recnum, count) ?:
        !            26:          ds_device_write (dev->com.blkpart.blk,
        !            27:                           reply_port, reply_port_type,
        !            28:                           mode, recnum, data, count, bytes_written));
        !            29: }
        !            30: 
        !            31: io_return_t
        !            32: ds_blkpart_write_inband (device_t dev, ipc_port_t reply_port,
        !            33:                         mach_msg_type_name_t reply_port_type, dev_mode_t mode,
        !            34:                         recnum_t recnum,
        !            35:                         io_buf_ptr_t data, unsigned int count,
        !            36:                         int *bytes_written)
        !            37: {
        !            38:   return (adjust_recnum (dev, &recnum, count) ?:
        !            39:          ds_device_write_inband (dev->com.blkpart.blk,
        !            40:                                  reply_port, reply_port_type,
        !            41:                                  mode, recnum, data, count, bytes_written));
        !            42: }
        !            43: 
        !            44: 
        !            45: io_return_t
        !            46: ds_blkpart_read (device_t dev, ipc_port_t reply_port,
        !            47:                 mach_msg_type_name_t reply_port_type, dev_mode_t mode,
        !            48:                 recnum_t recnum, int count, io_buf_ptr_t *data,
        !            49:                 unsigned *bytes_read)
        !            50: {
        !            51:   return (adjust_recnum (dev, &recnum, count) ?:
        !            52:          ds_device_read (dev->com.blkpart.blk,
        !            53:                          reply_port, reply_port_type,
        !            54:                          mode, recnum, count, data, bytes_read));
        !            55: }
        !            56: 
        !            57: io_return_t
        !            58: ds_blkpart_read_inband (device_t dev, ipc_port_t reply_port,
        !            59:                        mach_msg_type_name_t reply_port_type, dev_mode_t mode,
        !            60:                        recnum_t recnum, int count, char *data,
        !            61:                        unsigned *bytes_read)
        !            62: {
        !            63:   return (adjust_recnum (dev, &recnum, count) ?:
        !            64:          ds_device_read_inband (dev->com.blkpart.blk,
        !            65:                                 reply_port, reply_port_type,
        !            66:                                 mode, recnum, count, data, bytes_read));
        !            67: }
        !            68: 
        !            69: io_return_t
        !            70: ds_blkpart_get_status (device_t dev, dev_flavor_t flavor, dev_status_t status,
        !            71:                       mach_msg_type_number_t *status_count)
        !            72: {
        !            73:   switch (flavor)
        !            74:     {
        !            75:     case DEV_GET_SIZE:
        !            76:       {
        !            77:        status[DEV_GET_SIZE_RECORD_SIZE] = dev->com.blkpart.blk->com.blk.size;
        !            78:        status[DEV_GET_SIZE_DEVICE_SIZE] = (dev->com.blkpart.blk->com.blk.size
        !            79:                                            * dev->com.blkpart.part->size);
        !            80:        *status_count = 2;
        !            81:        return D_SUCCESS;
        !            82:       }
        !            83:     }
        !            84:   INVALOP;
        !            85: }
        !            86: 
        !            87: void
        !            88: ds_blkpart_close (device_t dev)
        !            89: {
        !            90:   /* We store the partition pointer instead of a COM object here, so we'd
        !            91:      better clear this field before returning to device_deallocate, which
        !            92:      will attempt to call the COM release method.  */
        !            93:   dev->com_device = 0;
        !            94: 
        !            95:   /* Release our ref on the underlying device.  */
        !            96:   device_deallocate (dev->com.blkpart.blk);
        !            97: }
        !            98: 
        !            99: const struct device_ops block_partition_device_ops =
        !           100: {
        !           101:   write_inband: ds_blkpart_write_inband, write: ds_blkpart_write,
        !           102:   read_inband: ds_blkpart_read_inband, read: ds_blkpart_read,
        !           103:   get_status: ds_blkpart_get_status,
        !           104:   close: ds_blkpart_close
        !           105: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.