Home | History | Annotate | Download | only in common
      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 	void (*fsp_recur_rm)(char *);
     80 } fsplug_func_t;
     81 
     82 extern fsplug_func_t *fs_functions_vec;
     83 
     84 /* Macros for calling functions */
     85 #define	FB_FREEMEM(fd, sz) \
     86 	(*fs_functions_vec->fsp_freemem)(fd, sz)
     87 
     88 #define	FB_OPEN(fd, path, flags, perms) \
     89 	(*fs_functions_vec->fsp_open)(fd, path, flags, perms)
     90 
     91 #define	FB_PREAD(fdesc, iobuf, iosize, offset) \
     92 	(*fs_functions_vec->fsp_pread)(fdesc, iobuf, iosize, offset)
     93 
     94 #define	FB_READ(fdesc, iobuf, iosize) \
     95 	(*fs_functions_vec->fsp_read)(fdesc, iobuf, iosize)
     96 
     97 #define	FB_PWRITE(fdesc, iobuf, iosize, offset) \
     98 	(*fs_functions_vec->fsp_pwrite)(fdesc, iobuf, iosize, offset)
     99 
    100 #define	FB_WRITE(fdesc, iobuf, iosize) \
    101 	(*fs_functions_vec->fsp_write)(fdesc, iobuf, iosize)
    102 
    103 #define	FB_LSEEK(fdesc, amnt, whence) \
    104 	(*fs_functions_vec->fsp_lseek)(fdesc, amnt, whence)
    105 
    106 #define	FB_CLOSE(fdesc) \
    107 	(*fs_functions_vec->fsp_close)(fdesc)
    108 
    109 #define	FB_UNLINK(path) \
    110 	(*fs_functions_vec->fsp_unlink)(path)
    111 
    112 #define	FB_MKDIR(path, perm) \
    113 	(*fs_functions_vec->fsp_mkdir)(path, perm)
    114 
    115 #define	FB_RMDIR(path) \
    116 	(*fs_functions_vec->fsp_rmdir)(path)
    117 
    118 #define	FB_OPENDIR(path) \
    119 	(*fs_functions_vec->fsp_opendir)(path)
    120 
    121 #define	FB_READDIR(dir) \
    122 	(*fs_functions_vec->fsp_readdir)(dir)
    123 
    124 #define	FB_CLOSEDIR(dir) \
    125 	(*fs_functions_vec->fsp_closedir)(dir)
    126 
    127 #define	FB_FSYNC(fdesc) \
    128 	(*fs_functions_vec->fsp_fsync)(fdesc)
    129 
    130 #define	FB_RECUR_RM(path) \
    131 	(*fs_functions_vec->fsp_recur_rm)(path)
    132 
    133 #define	FB_STAT(path, statp) \
    134 	(*fs_functions_vec->fsp_stat)(path, statp)
    135 
    136 #define	FB_FSTAT(fdesc, statp) \
    137 	(*fs_functions_vec->fsp_fstat)(fdesc, statp)
    138 
    139 #define	FB_FTRUNC(fdesc, size) \
    140 	(*fs_functions_vec->fsp_ftrunc)(fdesc, size)
    141 
    142 #define	FB_LINK(existing, new) \
    143 	(*fs_functions_vec->fsp_link)(existing, new)
    144 
    145 #define	FB_SYMLINK(name1, name2) \
    146 	(*fs_functions_vec->fsp_symlink)(name1, name2)
    147 
    148 #endif /* _FSPLUG_H */
    149