diff options
author | Michael Brown <mcb30@ipxe.org> | 2010-06-16 01:31:29 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-06-22 15:50:31 +0100 |
commit | 4327d5d39f101f1df0ace6c03f3b3ada5f6a6213 (patch) | |
tree | ccf92bdfd23046b6c7f64f87b57350f02f63ad6f /src/core/posix_io.c | |
parent | 7b4fbd93a5f45355e4e5d30e5d34c310f6d30c05 (diff) | |
download | ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.zip ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.gz ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.bz2 |
[interface] Convert all data-xfer interfaces to generic interfaces
Remove data-xfer as an interface type, and replace data-xfer
interfaces with generic interfaces supporting the data-xfer methods.
Filter interfaces (as used by the TLS layer) are handled using the
generic pass-through interface capability. A side-effect of this is
that deliver_raw() no longer exists as a data-xfer method. (In
practice this doesn't lose any efficiency, since there are no
instances within the current codebase where xfer_deliver_raw() is used
to pass data to an interface supporting the deliver_raw() method.)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/posix_io.c')
-rw-r--r-- | src/core/posix_io.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/src/core/posix_io.c b/src/core/posix_io.c index 2ecb154..f7ca3f0 100644 --- a/src/core/posix_io.c +++ b/src/core/posix_io.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <string.h> #include <errno.h> #include <ipxe/list.h> +#include <ipxe/iobuf.h> #include <ipxe/xfer.h> #include <ipxe/open.h> #include <ipxe/process.h> @@ -50,7 +51,7 @@ struct posix_file { */ int rc; /** Data transfer interface */ - struct xfer_interface xfer; + struct interface xfer; /** Current seek position */ size_t pos; /** File size */ @@ -87,38 +88,21 @@ static void posix_file_free ( struct refcnt *refcnt ) { * @v rc Reason for termination */ static void posix_file_finished ( struct posix_file *file, int rc ) { - xfer_nullify ( &file->xfer ); - xfer_close ( &file->xfer, rc ); + intf_shutdown ( &file->xfer, rc ); file->rc = rc; } /** - * Handle close() event - * - * @v xfer POSIX file data transfer interface - * @v rc Reason for close - */ -static void posix_file_xfer_close ( struct xfer_interface *xfer, int rc ) { - struct posix_file *file = - container_of ( xfer, struct posix_file, xfer ); - - posix_file_finished ( file, rc ); -} - -/** * Handle deliver_iob() event * - * @v xfer POSIX file data transfer interface + * @v file POSIX file * @v iobuf I/O buffer * @v meta Data transfer metadata * @ret rc Return status code */ -static int -posix_file_xfer_deliver_iob ( struct xfer_interface *xfer, - struct io_buffer *iobuf, - struct xfer_metadata *meta ) { - struct posix_file *file = - container_of ( xfer, struct posix_file, xfer ); +static int posix_file_xfer_deliver ( struct posix_file *file, + struct io_buffer *iobuf, + struct xfer_metadata *meta ) { /* Keep track of file position solely for the filesize */ if ( meta->whence != SEEK_CUR ) @@ -137,15 +121,15 @@ posix_file_xfer_deliver_iob ( struct xfer_interface *xfer, } /** POSIX file data transfer interface operations */ -static struct xfer_interface_operations posix_file_xfer_operations = { - .close = posix_file_xfer_close, - .vredirect = xfer_vreopen, - .window = unlimited_xfer_window, - .alloc_iob = default_xfer_alloc_iob, - .deliver_iob = posix_file_xfer_deliver_iob, - .deliver_raw = xfer_deliver_as_iob, +static struct interface_operation posix_file_xfer_operations[] = { + INTF_OP ( xfer_deliver, struct posix_file *, posix_file_xfer_deliver ), + INTF_OP ( intf_close, struct posix_file *, posix_file_finished ), }; +/** POSIX file data transfer interface descriptor */ +static struct interface_descriptor posix_file_xfer_desc = + INTF_DESC ( struct posix_file, xfer, posix_file_xfer_operations ); + /** * Identify file by file descriptor * @@ -201,8 +185,7 @@ int open ( const char *uri_string ) { ref_init ( &file->refcnt, posix_file_free ); file->fd = fd; file->rc = -EINPROGRESS; - xfer_init ( &file->xfer, &posix_file_xfer_operations, - &file->refcnt ); + intf_init ( &file->xfer, &posix_file_xfer_desc, &file->refcnt ); INIT_LIST_HEAD ( &file->data ); /* Open URI on data transfer interface */ |