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

Annotation of prex-old/usr/server/fs/vfs/vfs.h, Revision 1.1.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: #include <sys/syslog.h>
                     39:
                     40: #include <assert.h>
                     41:
                     42: /*
                     43:  * Tunable parameters
                     44:  */
                     45: #define PRIO_FS                128             /* priority of file system server */
                     46: #define FSMAXNAMES     16              /* max length of 'file system' name */
                     47:
                     48: #ifdef DEBUG
                     49: /* #define DEBUG_VFS   1 */
                     50: /* #define DEBUG_VNODE 1 */
                     51: /* #define DEBUG_BIO   1 */
                     52: #endif
                     53:
                     54: #ifdef DEBUG_VFS
                     55: #define dprintf(fmt, args...)  syslog(LOG_DEBUG, "vfs: "fmt, ## args)
                     56: #else
                     57: #define dprintf(fmt...)                do {} while (0)
                     58: #endif
                     59: #ifdef DEBUG_VNODE
                     60: #define vn_printf(fmt, args...)        syslog(LOG_DEBUG, fmt, ## args)
                     61: #else
                     62: #define vn_printf(fmt...)      do {} while (0)
                     63: #endif
                     64: #ifdef DEBUG_BIO
                     65: #define bio_printf(fmt, args...) syslog(LOG_DEBUG, fmt, ## args)
                     66: #else
                     67: #define bio_printf(fmt...)      do {} while (0)
                     68: #endif
                     69:
                     70: #ifdef DEBUG
                     71: #define ASSERT(e)      assert(e)
                     72: #else
                     73: #define ASSERT(e)
                     74: #endif
                     75:
                     76: #if CONFIG_FS_THREADS > 1
                     77: #define malloc(s)              malloc_r(s)
                     78: #define free(p)                        free_r(p)
                     79: #else
                     80: #define mutex_init(m)          do {} while (0)
                     81: #define mutex_destroy(m)       do {} while (0)
                     82: #define mutex_lock(m)          do {} while (0)
                     83: #define mutex_unlock(m)                do {} while (0)
                     84: #define mutex_trylock(m)       do {} while (0)
                     85: #endif
                     86:
                     87: /*
                     88:  * per task data
                     89:  */
                     90: struct task {
                     91:        struct list     link;           /* hash link */
                     92:        task_t          task;           /* task id */
                     93:        char            cwd[PATH_MAX];  /* current working directory */
                     94:        file_t          cwd_fp;         /* directory for cwd */
                     95:        file_t          file[OPEN_MAX]; /* array of file pointers */
                     96:        int             nr_open;        /* number of opening files */
                     97:        mutex_t         lock;           /* lock for this task */
                     98:        cap_t           cap;            /* task capabilities */
                     99: };
                    100:
                    101: extern const struct vfssw vfssw_table[];
                    102:
                    103: extern struct task *task_lookup(task_t task);
                    104: extern int task_alloc(task_t task, struct task **pt);
                    105: extern void task_free(struct task *t);
                    106: extern void task_update(struct task *t, task_t task);
                    107: extern void task_unlock(struct task *t);
                    108: extern file_t task_getfp(struct task *t, int fd);
                    109: extern int task_conv(struct task *t, char *path, char *full);
                    110: extern void task_dump(void);
                    111: extern void task_init(void);
                    112:
                    113: extern int namei(char *path, vnode_t *vpp);
                    114: extern int lookup(char *path, vnode_t *vpp, char **name);
                    115:
                    116: extern vnode_t vn_lookup(mount_t mp, char *path);
                    117: extern void vn_lock(vnode_t vp);
                    118: extern void vn_unlock(vnode_t vp);
                    119: extern vnode_t vget(mount_t mp, char *path);
                    120: extern void vput(vnode_t vp);
                    121: extern void vgone(vnode_t vp);
                    122: extern void vref(vnode_t vp);
                    123: extern void vrele(vnode_t vp);
                    124: extern int vcount(vnode_t vp);
                    125: extern void vflush(mount_t mp);
                    126: extern void vnode_init(void);
                    127: #ifdef DEBUG
                    128: extern void vnode_dump(void);
                    129: #endif
                    130:
                    131: extern void bio_init(void);
                    132:
                    133: extern int sys_mount(char *dev, char *dir, char *fsname, int flags, void *data);
                    134: extern int sys_umount(char *path);
                    135: extern int sys_sync(void);
                    136: extern int vfs_findroot(char *path, mount_t *mp, char **root);
                    137: extern void vfs_busy(mount_t mp);
                    138: extern void vfs_unbusy(mount_t mp);
                    139: #ifdef DEBUG
                    140: extern void mount_dump(void);
                    141: #endif
                    142:
                    143: extern int sys_open(char *path, int flags, mode_t mode, file_t * file);
                    144: extern int sys_close(file_t fl);
                    145: extern int sys_read(file_t fl, void *buf, size_t size, size_t *result);
                    146: extern int sys_write(file_t fl, void *buf, size_t size, size_t *result);
                    147: extern int sys_lseek(file_t fl, off_t off, int type, off_t * cur_off);
                    148: extern int sys_ioctl(file_t fl, int request, char *buf);
                    149: extern int sys_fstat(file_t fl, struct stat *st);
                    150: extern int sys_fsync(file_t fl);
                    151:
                    152: extern int sys_opendir(char *path, file_t * file);
                    153: extern int sys_closedir(file_t fl);
                    154: extern int sys_readdir(file_t fl, struct dirent *dirent);
                    155: extern int sys_rewinddir(file_t fl);
                    156: extern int sys_seekdir(file_t fl, long loc);
                    157: extern int sys_telldir(file_t fl, long *loc);
                    158: extern int sys_mkdir(char *path, mode_t mode);
                    159: extern int sys_rmdir(char *path);
                    160: extern int sys_mknod(char *path, mode_t mode);
                    161: extern int sys_rename(char *src, char *dest);
                    162: extern int sys_unlink(char *path);
                    163: extern int sys_access(char *path, int mode);
                    164:
                    165: #endif /* !_VFS_H */

CVSweb