Prex Home / Browse Source - Prex Version: 0.9.0

root/usr/server/fs/vfs/vfs.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2005-2007, Kohsuke Ohtani
   3  * All rights reserved.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the author nor the names of any co-contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _VFS_H
  31 #define _VFS_H
  32 
  33 #include <sys/cdefs.h>
  34 #include <sys/prex.h>
  35 #include <sys/vnode.h>
  36 #include <sys/file.h>
  37 #include <sys/mount.h>
  38 #include <sys/dirent.h>
  39 
  40 #include <assert.h>
  41 
  42 /* #define DEBUG_VFS 1 */
  43 
  44 /*
  45  * Tunable parameters
  46  */
  47 #define FSMAXNAMES      16              /* max length of 'file system' name */
  48 
  49 #ifdef DEBUG_VFS
  50 extern int vfs_debug;
  51 
  52 #define VFSDB_CORE      0x00000001
  53 #define VFSDB_SYSCALL   0x00000002
  54 #define VFSDB_VNODE     0x00000004
  55 #define VFSDB_BIO       0x00000008
  56 #define VFSDB_CAP       0x00000010
  57 
  58 #define VFSDB_FLAGS     0x00000013
  59 
  60 #define DPRINTF(_m,X)   if (vfs_debug & (_m)) dprintf X
  61 #define ASSERT(e)       dassert(e)
  62 #else
  63 #define DPRINTF(_m, X)
  64 #define ASSERT(e)
  65 #endif
  66 
  67 #if CONFIG_FS_THREADS > 1
  68 #define malloc(s)               malloc_r(s)
  69 #define free(p)                 free_r(p)
  70 #else
  71 #define mutex_init(m)           do {} while (0)
  72 #define mutex_destroy(m)        do {} while (0)
  73 #define mutex_lock(m)           do {} while (0)
  74 #define mutex_unlock(m)         do {} while (0)
  75 #define mutex_trylock(m)        do {} while (0)
  76 #endif
  77 
  78 /*
  79  * per task data
  80  */
  81 struct task {
  82         struct list t_link;             /* hash link */
  83         task_t      t_taskid;           /* task id */
  84         char        t_cwd[PATH_MAX];    /* current working directory */
  85         file_t      t_cwdfp;            /* directory for cwd */
  86         file_t      t_ofile[NOFILE];    /* pointers to file structures of open files */
  87         int         t_nopens;           /* number of opening files */
  88         mutex_t     t_lock;             /* lock for this task */
  89 };
  90 
  91 extern const struct vfssw vfssw[];
  92 
  93 __BEGIN_DECLS
  94 int      sys_open(char *path, int flags, mode_t mode, file_t *pfp);
  95 int      sys_close(file_t fp);
  96 int      sys_read(file_t fp, void *buf, size_t size, size_t *result);
  97 int      sys_write(file_t fp, void *buf, size_t size, size_t *result);
  98 int      sys_lseek(file_t fp, off_t off, int type, off_t * cur_off);
  99 int      sys_ioctl(file_t fp, u_long request, void *buf);
 100 int      sys_fstat(file_t fp, struct stat *st);
 101 int      sys_fsync(file_t fp);
 102 int      sys_ftruncate(file_t fp, off_t length);
 103 
 104 int      sys_opendir(char *path, file_t * file);
 105 int      sys_closedir(file_t fp);
 106 int      sys_readdir(file_t fp, struct dirent *dirent);
 107 int      sys_rewinddir(file_t fp);
 108 int      sys_seekdir(file_t fp, long loc);
 109 int      sys_telldir(file_t fp, long *loc);
 110 int      sys_fchdir(file_t fp, char *path);
 111 
 112 int      sys_mkdir(char *path, mode_t mode);
 113 int      sys_rmdir(char *path);
 114 int      sys_mknod(char *path, mode_t mode);
 115 int      sys_rename(char *src, char *dest);
 116 int      sys_unlink(char *path);
 117 int      sys_access(char *path, int mode);
 118 int      sys_stat(char *path, struct stat *st);
 119 int      sys_truncate(char *path, off_t length);
 120 
 121 int      sys_mount(char *dev, char *dir, char *fsname, int flags, void *data);
 122 int      sys_umount(char *path);
 123 int      sys_sync(void);
 124 
 125 
 126 struct task *task_lookup(task_t task);
 127 int      task_alloc(task_t task, struct task **pt);
 128 void     task_free(struct task *t);
 129 void     task_setid(struct task *t, task_t task);
 130 void     task_unlock(struct task *t);
 131 
 132 file_t   task_getfp(struct task *t, int fd);
 133 void     task_setfp(struct task *t, int fd, file_t fp);
 134 int      task_newfd(struct task *t);
 135 void     task_delfd(struct task *t, int fd);
 136 
 137 int      task_conv(struct task *t, char *path, int mode, char *full);
 138 void     task_init(void);
 139 
 140 int      sec_file_permission(task_t task, char *path, int mode);
 141 int      sec_vnode_permission(char *path);
 142 
 143 int      namei(char *path, vnode_t *vpp);
 144 int      lookup(char *path, vnode_t *vpp, char **name);
 145 void     vnode_init(void);
 146 
 147 int      vfs_findroot(char *path, mount_t *mp, char **root);
 148 void     vfs_busy(mount_t mp);
 149 void     vfs_unbusy(mount_t mp);
 150 
 151 int      fs_noop(void);
 152 
 153 #ifdef DEBUG_VFS
 154 void     task_dump(void);
 155 void     vnode_dump(void);
 156 void     mount_dump(void);
 157 #endif
 158 __END_DECLS
 159 
 160 #endif /* !_VFS_H */

/* [<][>][^][v][top][bottom][index][help] */