Home | History | Annotate | Download | only in common
      1  8615  Andrew /*
      2  8615  Andrew  * CDDL HEADER START
      3  8615  Andrew  *
      4  8615  Andrew  * The contents of this file are subject to the terms of the
      5  8615  Andrew  * Common Development and Distribution License (the "License").
      6  8615  Andrew  * You may not use this file except in compliance with the License.
      7  8615  Andrew  *
      8  8615  Andrew  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  8615  Andrew  * or http://www.opensolaris.org/os/licensing.
     10  8615  Andrew  * See the License for the specific language governing permissions
     11  8615  Andrew  * and limitations under the License.
     12  8615  Andrew  *
     13  8615  Andrew  * When distributing Covered Code, include this CDDL HEADER in each
     14  8615  Andrew  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  8615  Andrew  * If applicable, add the following below this CDDL HEADER, with the
     16  8615  Andrew  * fields enclosed by brackets "[]" replaced with your own identifying
     17  8615  Andrew  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  8615  Andrew  *
     19  8615  Andrew  * CDDL HEADER END
     20  8615  Andrew  */
     21  8615  Andrew /*
     22  8615  Andrew  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23  8615  Andrew  * Use is subject to license terms.
     24  8615  Andrew  *
     25  8615  Andrew  */
     26  8615  Andrew 
     27  8615  Andrew 
     28  8615  Andrew #ifndef _FSPLUG_H
     29  8615  Andrew #define	_FSPLUG_H
     30  8615  Andrew 
     31  8615  Andrew #include <dirent.h>
     32  8615  Andrew #include "config.h"
     33  8615  Andrew #include <sys/stat.h>
     34  8615  Andrew 
     35  8615  Andrew /*
     36  8615  Andrew  * Type of file system client plug-in desired.
     37  8615  Andrew  */
     38  8615  Andrew typedef enum fb_plugin_type {
     39  8615  Andrew 	LOCAL_FS_PLUG = 0,
     40  8615  Andrew 	NFS3_PLUG,
     41  8615  Andrew 	NFS4_PLUG,
     42  8615  Andrew 	CIFS_PLUG
     43  8615  Andrew } fb_plugin_type_t;
     44  8615  Andrew 
     45  8615  Andrew /* universal file descriptor for both local and nfs file systems */
     46  8615  Andrew typedef union fb_fdesc {
     47  8615  Andrew 	int		fd_num;		/* OS file descriptor number */
     48  8615  Andrew 	void		*fd_ptr;	/* Pointer to nfs information block */
     49  8615  Andrew } fb_fdesc_t;
     50  8615  Andrew 
     51  8615  Andrew typedef struct aiolist aiol_t;
     52  8615  Andrew 
     53  8615  Andrew /* Functions vector for file system plug-ins */
     54  8615  Andrew typedef struct fsplug_func_s {
     55  8615  Andrew 	char fs_name[16];
     56  8615  Andrew 	int (*fsp_freemem)(fb_fdesc_t *, off64_t);
     57  8615  Andrew 	int (*fsp_open)(fb_fdesc_t *, char *, int, int);
     58  8615  Andrew 	int (*fsp_pread)(fb_fdesc_t *, caddr_t, fbint_t, off64_t);
     59  8615  Andrew 	int (*fsp_read)(fb_fdesc_t *, caddr_t, fbint_t);
     60  8615  Andrew 	int (*fsp_pwrite)(fb_fdesc_t *, caddr_t, fbint_t, off64_t);
     61  8615  Andrew 	int (*fsp_write)(fb_fdesc_t *, caddr_t, fbint_t);
     62  8615  Andrew 	int (*fsp_lseek)(fb_fdesc_t *, off64_t, int);
     63  8615  Andrew 	int (*fsp_ftrunc)(fb_fdesc_t *, off64_t);
     64  8615  Andrew 	int (*fsp_rename)(const char *, const char *);
     65  8615  Andrew 	int (*fsp_close)(fb_fdesc_t *);
     66  8615  Andrew 	int (*fsp_link)(const char *, const char *);
     67  8615  Andrew 	int (*fsp_symlink)(const char *, const char *);
     68  8615  Andrew 	int (*fsp_unlink)(char *);
     69  8615  Andrew 	ssize_t (*fsp_readlink)(const char *, char *, size_t);
     70  8615  Andrew 	int (*fsp_mkdir)(char *, int);
     71  8615  Andrew 	int (*fsp_rmdir)(char *);
     72  8615  Andrew 	DIR *(*fsp_opendir)(char *);
     73  8615  Andrew 	struct dirent *(*fsp_readdir)(DIR *);
     74  8615  Andrew 	int (*fsp_closedir)(DIR *);
     75  8615  Andrew 	int (*fsp_fsync)(fb_fdesc_t *);
     76  8615  Andrew 	int (*fsp_stat)(char *, struct stat64 *);
     77  8615  Andrew 	int (*fsp_fstat)(fb_fdesc_t *, struct stat64 *);
     78  8615  Andrew 	int (*fsp_access)(const char *, int);
     79  9356  Andrew 	void (*fsp_recur_rm)(char *);
     80  8615  Andrew } fsplug_func_t;
     81  8615  Andrew 
     82  8615  Andrew extern fsplug_func_t *fs_functions_vec;
     83  8615  Andrew 
     84  8615  Andrew /* Macros for calling functions */
     85  8615  Andrew #define	FB_FREEMEM(fd, sz) \
     86  8615  Andrew 	(*fs_functions_vec->fsp_freemem)(fd, sz)
     87  8615  Andrew 
     88  8615  Andrew #define	FB_OPEN(fd, path, flags, perms) \
     89  8615  Andrew 	(*fs_functions_vec->fsp_open)(fd, path, flags, perms)
     90  8615  Andrew 
     91  8615  Andrew #define	FB_PREAD(fdesc, iobuf, iosize, offset) \
     92  8615  Andrew 	(*fs_functions_vec->fsp_pread)(fdesc, iobuf, iosize, offset)
     93  8615  Andrew 
     94  8615  Andrew #define	FB_READ(fdesc, iobuf, iosize) \
     95  8615  Andrew 	(*fs_functions_vec->fsp_read)(fdesc, iobuf, iosize)
     96  8615  Andrew 
     97  8615  Andrew #define	FB_PWRITE(fdesc, iobuf, iosize, offset) \
     98  8615  Andrew 	(*fs_functions_vec->fsp_pwrite)(fdesc, iobuf, iosize, offset)
     99  8615  Andrew 
    100  8615  Andrew #define	FB_WRITE(fdesc, iobuf, iosize) \
    101  8615  Andrew 	(*fs_functions_vec->fsp_write)(fdesc, iobuf, iosize)
    102  8615  Andrew 
    103  8615  Andrew #define	FB_LSEEK(fdesc, amnt, whence) \
    104  8615  Andrew 	(*fs_functions_vec->fsp_lseek)(fdesc, amnt, whence)
    105  8615  Andrew 
    106  8615  Andrew #define	FB_CLOSE(fdesc) \
    107  8615  Andrew 	(*fs_functions_vec->fsp_close)(fdesc)
    108  8615  Andrew 
    109  8615  Andrew #define	FB_UNLINK(path) \
    110  8615  Andrew 	(*fs_functions_vec->fsp_unlink)(path)
    111  8615  Andrew 
    112  8615  Andrew #define	FB_MKDIR(path, perm) \
    113  8615  Andrew 	(*fs_functions_vec->fsp_mkdir)(path, perm)
    114  8615  Andrew 
    115  8615  Andrew #define	FB_RMDIR(path) \
    116  8615  Andrew 	(*fs_functions_vec->fsp_rmdir)(path)
    117  8615  Andrew 
    118  8615  Andrew #define	FB_OPENDIR(path) \
    119  8615  Andrew 	(*fs_functions_vec->fsp_opendir)(path)
    120  8615  Andrew 
    121  8615  Andrew #define	FB_READDIR(dir) \
    122  8615  Andrew 	(*fs_functions_vec->fsp_readdir)(dir)
    123  8615  Andrew 
    124  8615  Andrew #define	FB_CLOSEDIR(dir) \
    125  8615  Andrew 	(*fs_functions_vec->fsp_closedir)(dir)
    126  8615  Andrew 
    127  8615  Andrew #define	FB_FSYNC(fdesc) \
    128  8615  Andrew 	(*fs_functions_vec->fsp_fsync)(fdesc)
    129  8615  Andrew 
    130  9356  Andrew #define	FB_RECUR_RM(path) \
    131  9356  Andrew 	(*fs_functions_vec->fsp_recur_rm)(path)
    132  9356  Andrew 
    133  8615  Andrew #define	FB_STAT(path, statp) \
    134  8615  Andrew 	(*fs_functions_vec->fsp_stat)(path, statp)
    135  8615  Andrew 
    136  8615  Andrew #define	FB_FSTAT(fdesc, statp) \
    137  8615  Andrew 	(*fs_functions_vec->fsp_fstat)(fdesc, statp)
    138  8615  Andrew 
    139  8615  Andrew #define	FB_FTRUNC(fdesc, size) \
    140  8615  Andrew 	(*fs_functions_vec->fsp_ftrunc)(fdesc, size)
    141  8615  Andrew 
    142  8615  Andrew #define	FB_LINK(existing, new) \
    143  8615  Andrew 	(*fs_functions_vec->fsp_link)(existing, new)
    144  8615  Andrew 
    145  8615  Andrew #define	FB_SYMLINK(name1, name2) \
    146  8615  Andrew 	(*fs_functions_vec->fsp_symlink)(name1, name2)
    147  8615  Andrew 
    148  8615  Andrew #endif /* _FSPLUG_H */
    149