[BACK]Return to vnode.h CVS log [TXT][DIR] Up to [local] / prex-old / include / sys

Annotation of prex-old/include/sys/vnode.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 _SYS_VNODE_H
                     31: #define _SYS_VNODE_H
                     32:
                     33: #include <sys/types.h>
                     34: #include <sys/stat.h>
                     35: #include <sys/file.h>
                     36: #include <sys/list.h>
                     37: #include <sys/dirent.h>
                     38: #include <sys/syslimits.h>
                     39:
                     40: struct vfsops;
                     41: struct vnops;
                     42: struct vnode;
                     43: struct file;
                     44:
                     45: /*
                     46:  * Vnode types.
                     47:  */
                     48: enum {
                     49:        VNON,       /* no type */
                     50:        VREG,       /* regular file  */
                     51:        VDIR,       /* directory */
                     52:        VBLK,       /* block device */
                     53:        VCHR,       /* character device */
                     54:        VLNK,       /* symbolic link */
                     55:        VSOCK,      /* socks */
                     56:        VFIFO       /* FIFO */
                     57: };
                     58:
                     59: /*
                     60:  * Reading or writing any of these items requires holding the
                     61:  * appropriate lock.
                     62:  */
                     63: struct vnode {
                     64:        struct list     v_link;         /* link for hash list */
                     65:        struct mount    *v_mount;       /* mounted vfs pointer */
                     66:        struct vnops    *v_op;          /* vnode operations */
                     67:        int             v_refcount;     /* reference count */
                     68:        int             v_type;         /* vnode type */
                     69:        int             v_flags;        /* vnode flag */
                     70:        mode_t          v_mode;         /* file mode */
                     71:        size_t          v_size;         /* file size */
                     72:        mutex_t         v_lock;         /* lock for this vnode */
                     73:        int             v_nrlocks;      /* lock count (for debug) */
                     74:        int             v_blkno;        /* block number */
                     75:        char            *v_path;        /* pointer to path in fs */
                     76:        void            *v_data;        /* private data for fs */
                     77: };
                     78: typedef struct vnode *vnode_t;
                     79:
                     80: /* flags for vnode */
                     81: #define VROOT          0x0001          /* root of its file system */
                     82:
                     83: /*
                     84:  * Vnode attribute
                     85:  */
                     86: struct vattr {
                     87:        int             va_type;        /* vnode type */
                     88:        mode_t          va_mode;        /* file access mode */
                     89: };
                     90:
                     91: /*
                     92:  * Modes
                     93:  */
                     94: #define VREAD          0x0004
                     95: #define VWRITE         0x0002
                     96: #define VEXEC          0x0001
                     97:
                     98: /*
                     99:  * vnode operations
                    100:  */
                    101: struct vnops {
                    102:        int (*open)     (vnode_t vp, mode_t mode);
                    103:        int (*close)    (vnode_t vp, file_t fp);
                    104:        int (*read)     (vnode_t vp, file_t fp, void *buf, size_t size, size_t *result);
                    105:        int (*write)    (vnode_t vp, file_t fp, void *buf, size_t size, size_t *result);
                    106:        int (*seek)     (vnode_t vp, file_t fp, off_t oldoff, off_t newoff);
                    107:        int (*ioctl)    (vnode_t vp, file_t fp, int cmd, u_long arg);
                    108:        int (*fsync)    (vnode_t vp, file_t fp);
                    109:        int (*readdir)  (vnode_t vp, file_t fp, struct dirent *dirent);
                    110:        int (*lookup)   (vnode_t dvp, char *name, vnode_t vp);
                    111:        int (*create)   (vnode_t dvp, char *name, mode_t mode);
                    112:        int (*remove)   (vnode_t dvp, vnode_t vp, char *name);
                    113:        int (*rename)   (vnode_t dvp1, vnode_t vp1, char *name1, vnode_t dvp2, vnode_t vp2, char *name2);
                    114:        int (*mkdir)    (vnode_t dvp, char *name, mode_t mode);
                    115:        int (*rmdir)    (vnode_t dvp, vnode_t vp, char *name);
                    116:        int (*getattr)  (vnode_t vp, struct vattr *vap);
                    117:        int (*setattr)  (vnode_t vp, struct vattr *vap);
                    118:        int (*inactive) (vnode_t vp);
                    119:        int (*truncate) (vnode_t vp);
                    120: };
                    121:
                    122: typedef        int (*vnop_open_t)      (vnode_t, mode_t);
                    123: typedef        int (*vnop_close_t)     (vnode_t, file_t);
                    124: typedef        int (*vnop_read_t)      (vnode_t, file_t, void *, size_t, size_t *);
                    125: typedef        int (*vnop_write_t)     (vnode_t, file_t, void *, size_t, size_t *);
                    126: typedef        int (*vnop_seek_t)      (vnode_t, file_t, off_t, off_t);
                    127: typedef        int (*vnop_ioctl_t)     (vnode_t, file_t, int, u_long);
                    128: typedef        int (*vnop_fsync_t)     (vnode_t, file_t);
                    129: typedef        int (*vnop_readdir_t)   (vnode_t, file_t, struct dirent *);
                    130: typedef        int (*vnop_lookup_t)    (vnode_t, char *, vnode_t);
                    131: typedef        int (*vnop_create_t)    (vnode_t, char *, mode_t);
                    132: typedef        int (*vnop_remove_t)    (vnode_t, vnode_t, char *);
                    133: typedef        int (*vnop_rename_t)    (vnode_t, vnode_t, char *, vnode_t, vnode_t, char *);
                    134: typedef        int (*vnop_mkdir_t)     (vnode_t, char *, mode_t);
                    135: typedef        int (*vnop_rmdir_t)     (vnode_t, vnode_t, char *);
                    136: typedef        int (*vnop_getattr_t)   (vnode_t, struct vattr *);
                    137: typedef        int (*vnop_setattr_t)   (vnode_t, struct vattr *);
                    138: typedef        int (*vnop_inactive_t)  (vnode_t);
                    139: typedef        int (*vnop_truncate_t)  (vnode_t);
                    140:
                    141: /*
                    142:  * vnode interface
                    143:  */
                    144: #define VOP_OPEN(VP, M)                   ((VP)->v_op->open)(VP, M)
                    145: #define VOP_CLOSE(VP, FP)         ((VP)->v_op->close)(VP, FP)
                    146: #define VOP_READ(VP, FP, B, S, C)  ((VP)->v_op->read)(VP, FP, B, S, C)
                    147: #define VOP_WRITE(VP, FP, B, S, C) ((VP)->v_op->write)(VP, FP, B, S, C)
                    148: #define VOP_SEEK(VP, FP, OLD, NEW) ((VP)->v_op->seek)(VP, FP, OLD, NEW)
                    149: #define VOP_IOCTL(VP, FP, C, A)           ((VP)->v_op->ioctl)(VP, FP, C, A)
                    150: #define VOP_FSYNC(VP, FP)         ((VP)->v_op->fsync)(VP, FP)
                    151: #define VOP_READDIR(VP, FP, DIR)   ((VP)->v_op->readdir)(VP, FP, DIR)
                    152: #define VOP_LOOKUP(DVP, N, VP)    ((DVP)->v_op->lookup)(DVP, N, VP)
                    153: #define VOP_CREATE(DVP, N, M)     ((DVP)->v_op->create)(DVP, N, M)
                    154: #define VOP_REMOVE(DVP, VP, N)    ((DVP)->v_op->remove)(DVP, VP, N)
                    155: #define VOP_RENAME(DVP1, VP1, N1, DVP2, VP2, N2) \
                    156:                           ((DVP1)->v_op->rename)(DVP1, VP1, N1, DVP2, VP2, N2)
                    157: #define VOP_MKDIR(DVP, N, M)      ((DVP)->v_op->mkdir)(DVP, N, M)
                    158: #define VOP_RMDIR(DVP, VP, N)     ((DVP)->v_op->rmdir)(DVP, VP, N)
                    159: #define VOP_GETATTR(VP, VAP)      ((VP)->v_op->getattr)(VP, VAP)
                    160: #define VOP_SETATTR(VP, VAP)      ((VP)->v_op->setattr)(VP, VAP)
                    161: #define VOP_INACTIVE(VP)          ((VP)->v_op->inactive)(VP)
                    162: #define VOP_TRUNCATE(VP)          ((VP)->v_op->truncate)(VP)
                    163:
                    164: __BEGIN_DECLS
                    165: int     vop_nullop(void);
                    166: int     vop_einval(void);
                    167: __END_DECLS
                    168:
                    169: #endif /* !_SYS_VNODE_H */

CVSweb