1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 #pragma ident "@(#)daio_pread.c 1.14 09/05/26 SMI" 23 24 /* 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 #include <diskomizer/daio.h> 30 #include <diskomizer/daio_dev.h> 31 #include "findap.h" 32 #include <sys/types.h> 33 #include <sys/stat.h> 34 #include <unistd.h> 35 #include <fcntl.h> 36 #include "async.h" 37 #include "daio_async.h" 38 39 static int daio_prw_write(int fildes, uchar_t *bufp, int bufs, off_t 40 offset, daio_result_t *resultp, struct daio_id *id); 41 static int daio_prw_read(int fildes, uchar_t *bufp, int bufs, off_t 42 offset, daio_result_t *resultp, struct daio_id *id); 43 44 struct daio_ops DAIO_OPS = { 45 daio_async_init, 46 daio_async_init_checker, 47 daio_async_get_checker, 48 findap, 49 (daio_open_t)daio_dev_open, 50 daio_dev_close, 51 unlink, 52 stat64, 53 fstat64, 54 ioctl, 55 ftruncate64, 56 daio_dev_directio, 57 read_disko_vtoc, 58 daio_async_pwrite, 59 daio_async_pread, 60 daio_prw_write, 61 daio_prw_read, 62 daio_async_status, 63 daio_async_start_time, 64 daio_async_end_time, 65 daio_async_wait, 66 daio_async_cancel, 67 daio_async_fini, 68 daio_dev_dd 69 }; 70 71 static int 72 daio_prw_read(int fildes, uchar_t *bufp, int bufs, off_t offset, 73 daio_result_t *resultp, struct daio_id *id) 74 { 75 return (daio_async_rw(fildes, bufp, bufs, offset, resultp, id, 76 pread, IS_READ)); 77 } 78 static int 79 daio_prw_write(int fildes, uchar_t *bufp, int bufs, off_t offset, 80 daio_result_t *resultp, struct daio_id *id) 81 { 82 return (daio_async_rw(fildes, bufp, bufs, offset, resultp, id, 83 (ssize_t (*)(int fildes, void *buf, 84 size_t nbyte, off_t offset)) pwrite, IS_WRITE)); 85 } 86