1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 #ifndef _SYS_ZFS_FILE_H 24 #define _SYS_ZFS_FILE_H 25 26 #include <sys/zfs_context.h> 27 28 #ifndef _KERNEL 29 typedef struct zfs_file { 30 int f_fd; 31 int f_dump_fd; 32 } zfs_file_t; 33 #elif defined(__linux__) || defined(__FreeBSD__) 34 typedef struct file zfs_file_t; 35 #else 36 #error "unknown OS" 37 #endif 38 39 typedef struct zfs_file_attr { 40 uint64_t zfa_size; /* file size */ 41 mode_t zfa_mode; /* file type */ 42 } zfs_file_attr_t; 43 44 int zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fp); 45 void zfs_file_close(zfs_file_t *fp); 46 47 int zfs_file_write(zfs_file_t *fp, const void *buf, size_t len, ssize_t *resid); 48 int zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t len, loff_t off, 49 ssize_t *resid); 50 int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid); 51 int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off, 52 ssize_t *resid); 53 54 int zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence); 55 int zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr); 56 int zfs_file_fsync(zfs_file_t *fp, int flags); 57 int zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len); 58 loff_t zfs_file_off(zfs_file_t *fp); 59 int zfs_file_unlink(const char *); 60 61 zfs_file_t *zfs_file_get(int fd); 62 void zfs_file_put(zfs_file_t *fp); 63 void *zfs_file_private(zfs_file_t *fp); 64 65 #endif /* _SYS_ZFS_FILE_H */ 66