[BACK]Return to vfs.h CVS log [TXT][DIR] Up to [local] / prex / usr / server / fs / vfs

Annotation of prex/usr/server/fs/vfs/vfs.h, Revision 1.1

1.1     ! nbrk        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 <prex/prex.h>
        !            34: #include <sys/vnode.h>
        !            35: #include <sys/file.h>
        !            36: #include <sys/mount.h>
        !            37: #include <sys/dirent.h>
        !            38:
        !            39: #include <assert.h>
        !            40:
        !            41: /*
        !            42:  * Tunable parameters
        !            43:  */
        !            44: #define PRIO_FS                128             /* priority of file system server */
        !            45: #define FSMAXNAMES     16              /* max length of 'file system' name */
        !            46:
        !            47: /* #define DEBUG_VFS 1 */
        !            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:
        !            57: #define        DPRINTF(_m,X)   if (vfs_debug & (_m)) dprintf X
        !            58: #else
        !            59: #define        DPRINTF(_m, X)
        !            60: #endif
        !            61:
        !            62: #ifdef DEBUG
        !            63: #define ASSERT(e)      assert(e)
        !            64: #else
        !            65: #define ASSERT(e)
        !            66: #endif
        !            67:
        !            68: #if CONFIG_FS_THREADS > 1
        !            69: #define malloc(s)              malloc_r(s)
        !            70: #define free(p)                        free_r(p)
        !            71: #else
        !            72: #define mutex_init(m)          do {} while (0)
        !            73: #define mutex_destroy(m)       do {} while (0)
        !            74: #define mutex_lock(m)          do {} while (0)
        !            75: #define mutex_unlock(m)                do {} while (0)
        !            76: #define mutex_trylock(m)       do {} while (0)
        !            77: #endif
        !            78:
        !            79: /*
        !            80:  * per task data
        !            81:  */
        !            82: struct task {
        !            83:        struct list     link;           /* hash link */
        !            84:        task_t          task;           /* task id */
        !            85:        char            cwd[PATH_MAX];  /* current working directory */
        !            86:        file_t          cwdfp;          /* directory for cwd */
        !            87:        file_t          file[OPEN_MAX]; /* array of file pointers */
        !            88:        int             nopens;         /* number of opening files */
        !            89:        mutex_t         lock;           /* lock for this task */
        !            90:        cap_t           cap;            /* task capabilities */
        !            91: };
        !            92:
        !            93: extern const struct vfssw vfssw_table[];
        !            94:
        !            95: extern struct task *task_lookup(task_t task);
        !            96: extern int task_alloc(task_t task, struct task **pt);
        !            97: extern void task_free(struct task *t);
        !            98: extern void task_update(struct task *t, task_t task);
        !            99: extern void task_unlock(struct task *t);
        !           100: extern file_t task_getfp(struct task *t, int fd);
        !           101: extern int task_newfd(struct task *t);
        !           102: extern int task_conv(struct task *t, char *path, char *full);
        !           103: extern void task_dump(void);
        !           104: extern void task_init(void);
        !           105:
        !           106: extern int namei(char *path, vnode_t *vpp);
        !           107: extern int lookup(char *path, vnode_t *vpp, char **name);
        !           108:
        !           109: extern void vnode_init(void);
        !           110: #ifdef DEBUG
        !           111: extern void vnode_dump(void);
        !           112: #endif
        !           113:
        !           114: extern int sys_mount(char *dev, char *dir, char *fsname, int flags, void *data);
        !           115: extern int sys_umount(char *path);
        !           116: extern int sys_sync(void);
        !           117: extern int vfs_findroot(char *path, mount_t *mp, char **root);
        !           118: extern void vfs_busy(mount_t mp);
        !           119: extern void vfs_unbusy(mount_t mp);
        !           120: #ifdef DEBUG
        !           121: extern void mount_dump(void);
        !           122: #endif
        !           123:
        !           124: extern int sys_open(char *path, int flags, mode_t mode, file_t *pfp);
        !           125: extern int sys_close(file_t fp);
        !           126: extern int sys_read(file_t fp, void *buf, size_t size, size_t *result);
        !           127: extern int sys_write(file_t fp, void *buf, size_t size, size_t *result);
        !           128: extern int sys_lseek(file_t fp, off_t off, int type, off_t * cur_off);
        !           129: extern int sys_ioctl(file_t fp, u_long request, void *buf);
        !           130: extern int sys_fstat(file_t fp, struct stat *st);
        !           131: extern int sys_fsync(file_t fp);
        !           132:
        !           133: extern int sys_opendir(char *path, file_t * file);
        !           134: extern int sys_closedir(file_t fp);
        !           135: extern int sys_readdir(file_t fp, struct dirent *dirent);
        !           136: extern int sys_rewinddir(file_t fp);
        !           137: extern int sys_seekdir(file_t fp, long loc);
        !           138: extern int sys_telldir(file_t fp, long *loc);
        !           139: extern int sys_mkdir(char *path, mode_t mode);
        !           140: extern int sys_rmdir(char *path);
        !           141: extern int sys_mknod(char *path, mode_t mode);
        !           142: extern int sys_rename(char *src, char *dest);
        !           143: extern int sys_unlink(char *path);
        !           144: extern int sys_access(char *path, int mode);
        !           145: extern int sys_stat(char *path, struct stat *st);
        !           146:
        !           147: #endif /* !_VFS_H */

CVSweb