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 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 */ 26 27 28 #ifndef _FSPLUG_H 29 #define _FSPLUG_H 30 31 #include <dirent.h> 32 #include "config.h" 33 #include <sys/stat.h> 34 35 /* 36 * Type of file system client plug-in desired. 37 */ 38 typedef enum fb_plugin_type { 39 LOCAL_FS_PLUG = 0, 40 NFS3_PLUG, 41 NFS4_PLUG, 42 CIFS_PLUG 43 } fb_plugin_type_t; 44 45 /* universal file descriptor for both local and nfs file systems */ 46 typedef union fb_fdesc { 47 int fd_num; /* OS file descriptor number */ 48 void *fd_ptr; /* Pointer to nfs information block */ 49 } fb_fdesc_t; 50 51 typedef struct aiolist aiol_t; 52 53 /* Functions vector for file system plug-ins */ 54 typedef struct fsplug_func_s { 55 char fs_name[16]; 56 int (*fsp_freemem)(fb_fdesc_t *, off64_t); 57 int (*fsp_open)(fb_fdesc_t *, char *, int, int); 58 int (*fsp_pread)(fb_fdesc_t *, caddr_t, fbint_t, off64_t); 59 int (*fsp_read)(fb_fdesc_t *, caddr_t, fbint_t); 60 int (*fsp_pwrite)(fb_fdesc_t *, caddr_t, fbint_t, off64_t); 61 int (*fsp_write)(fb_fdesc_t *, caddr_t, fbint_t); 62 int (*fsp_lseek)(fb_fdesc_t *, off64_t, int); 63 int (*fsp_ftrunc)(fb_fdesc_t *, off64_t); 64 int (*fsp_rename)(const char *, const char *); 65 int (*fsp_close)(fb_fdesc_t *); 66 int (*fsp_link)(const char *, const char *); 67 int (*fsp_symlink)(const char *, const char *); 68 int (*fsp_unlink)(char *); 69 ssize_t (*fsp_readlink)(const char *, char *, size_t); 70 int (*fsp_mkdir)(char *, int); 71 int (*fsp_rmdir)(char *); 72 DIR *(*fsp_opendir)(char *); 73 struct dirent *(*fsp_readdir)(DIR *); 74 int (*fsp_closedir)(DIR *); 75 int (*fsp_fsync)(fb_fdesc_t *); 76 int (*fsp_stat)(char *, struct stat64 *); 77 int (*fsp_fstat)(fb_fdesc_t *, struct stat64 *); 78 int (*fsp_access)(const char *, int); 79 } fsplug_func_t; 80 81 extern fsplug_func_t *fs_functions_vec; 82 83 /* Macros for calling functions */ 84 #define FB_FREEMEM(fd, sz) \ 85 (*fs_functions_vec->fsp_freemem)(fd, sz) 86 87 #define FB_OPEN(fd, path, flags, perms) \ 88 (*fs_functions_vec->fsp_open)(fd, path, flags, perms) 89 90 #define FB_PREAD(fdesc, iobuf, iosize, offset) \ 91 (*fs_functions_vec->fsp_pread)(fdesc, iobuf, iosize, offset) 92 93 #define FB_READ(fdesc, iobuf, iosize) \ 94 (*fs_functions_vec->fsp_read)(fdesc, iobuf, iosize) 95 96 #define FB_PWRITE(fdesc, iobuf, iosize, offset) \ 97 (*fs_functions_vec->fsp_pwrite)(fdesc, iobuf, iosize, offset) 98 99 #define FB_WRITE(fdesc, iobuf, iosize) \ 100 (*fs_functions_vec->fsp_write)(fdesc, iobuf, iosize) 101 102 #define FB_LSEEK(fdesc, amnt, whence) \ 103 (*fs_functions_vec->fsp_lseek)(fdesc, amnt, whence) 104 105 #define FB_CLOSE(fdesc) \ 106 (*fs_functions_vec->fsp_close)(fdesc) 107 108 #define FB_UNLINK(path) \ 109 (*fs_functions_vec->fsp_unlink)(path) 110 111 #define FB_MKDIR(path, perm) \ 112 (*fs_functions_vec->fsp_mkdir)(path, perm) 113 114 #define FB_RMDIR(path) \ 115 (*fs_functions_vec->fsp_rmdir)(path) 116 117 #define FB_OPENDIR(path) \ 118 (*fs_functions_vec->fsp_opendir)(path) 119 120 #define FB_READDIR(dir) \ 121 (*fs_functions_vec->fsp_readdir)(dir) 122 123 #define FB_CLOSEDIR(dir) \ 124 (*fs_functions_vec->fsp_closedir)(dir) 125 126 #define FB_FSYNC(fdesc) \ 127 (*fs_functions_vec->fsp_fsync)(fdesc) 128 129 #define FB_STAT(path, statp) \ 130 (*fs_functions_vec->fsp_stat)(path, statp) 131 132 #define FB_FSTAT(fdesc, statp) \ 133 (*fs_functions_vec->fsp_fstat)(fdesc, statp) 134 135 #define FB_FTRUNC(fdesc, size) \ 136 (*fs_functions_vec->fsp_ftrunc)(fdesc, size) 137 138 #define FB_LINK(existing, new) \ 139 (*fs_functions_vec->fsp_link)(existing, new) 140 141 #define FB_SYMLINK(name1, name2) \ 142 (*fs_functions_vec->fsp_symlink)(name1, name2) 143 144 #endif /* _FSPLUG_H */ 145