mdb_fdio.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* File Descriptor I/O Backend
*
* Simple backend to pass though io_ops to the corresponding system calls on
* an underlying fd. We provide functions to create fdio objects using file
* descriptors, explicit file names, and path lookups. We save the complete
* filename so that mdb_iob_name can be used to report the complete filename
* of an open macro file in syntax error messages.
*/
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_io_impl.h>
typedef struct fd_data {
int fd_fd; /* File descriptor */
} fd_data_t;
static ssize_t
{
}
static ssize_t
{
}
static off64_t
{
}
static int
{
if (req == MDB_IOC_GETFD)
else
}
static void
{
}
static const char *
{
}
mdb_io_t *
{
int fd;
char buf[MAXPATHLEN];
int i;
break;
}
}
if (fd == -1)
} else
if (fd >= 0)
return (NULL);
}
static const mdb_io_ops_t fdio_file_ops = {
};
/*
* In order to read from a block-oriented device, we pick up the seek pointer,
* read each containing block, and then copy the desired range of bytes back
* into the caller's buffer. Unfortunately Solaris hardcodes the notion of
* DEV_BSIZE as the transfer unit for such devices; no ioctl() to obtain the
* transfer unit dynamically is currently available. At the end of the
* transfer we reset the seek pointer to where the caller thinks it should be.
*/
static ssize_t
{
return (-1); /* errno is set for us */
while (resid != 0) {
break; /* errno is set for us, unless EOF */
}
}
/*
* To perform a write to a block-oriented device, we use the same basic
* algorithm as fdio_bdev_read(), above. In the inner loop, we read an
* entire block, modify it using the data from the caller's buffer, and
* then write the entire block back to the device.
*/
static ssize_t
{
return (-1); /* errno is set for us */
while (resid != 0) {
break; /* errno is set for us, unless EOF */
break; /* errno is set for us, unless EOF */
}
}
static const mdb_io_ops_t fdio_bdev_ops = {
};
mdb_io_t *
mdb_fdio_create(int fd)
{
switch (fd) {
case STDIN_FILENO:
break;
case STDOUT_FILENO:
break;
case STDERR_FILENO:
break;
default:
}
/*
* We determine if something is a raw block-oriented disk device by
* testing to see if it is a character device that supports DKIOCINFO.
* If we are operating on a disk in raw mode, we must do our own
* block-oriented i/o; otherwise we can just use read() and write().
*/
else
return (io);
}
mdb_io_t *
{
return (io);
}