/* Copyright 2002 Johan Rydberg, jrydberg@rtmk.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _VFS_H #define _VFS_H 1 #include #include #include #include "queue.h" #include "io-uio.h" #include "io-vnode.h" struct vnode; struct vfs; #ifndef NODEV # define NODEV -1 #endif /* VFS operations structure. Notes: All file systems does not have to implement the MOUNTROOT method. */ struct vfs_ops { int (*mount) (struct vfs *vfs, const char *path, void *data, struct proc *p); int (*unmount) (struct vfs *vfs, int flag, struct proc *p); int (*mountroot) (struct vfs *vfs, dev_t rootdev); int (*root) (struct vfs *vfs, struct vnode **vpp); }; /* Mount VFS on PATH. DATA is a pointer to per-filesystem specific data. P is current process. */ #define VFS_MOUNT(VFS, PATH, DATA, P) \ ((VFS)->vfs_ops->mount) (VFS, PATH, DATA, P) /* Unmount VFS. */ #define VFS_UNMOUNT(VFS, FLAG, P) ((VFS)->vfs_ops->unmount) (VFS, FLAG, P) /* Try to mount VFS as root file system. DEV is root device. */ #define VFS_MOUNTROOT(VFS, DEV) ((VFS)->vfs_ops->mountroot) (VFS, DEV) /* Return root vnode of file system represented by VFS in *VPP. */ #define VFS_ROOT(VFS, VPP) ((VFS)->vfs_ops->root) (VFS, VPP) /* The vfs object represents a file system. The kernel allocates one vfs object for each active file system. */ struct vfs { pthread_mutex_t vfs_lock; /* Lock for this mount point. */ struct vfs *vfs_next; /* Next vfs in list. */ struct vfs_ops *vfs_ops; /* VFS operations vector. */ struct vnode *vfs_covered; /* Vnode mounted on. */ int vfs_fstype; /* File system type index. */ void *vfs_data; /* Pointer to private data structure. */ dev_t vfs_dev; /* Device id which vfs is mounted on. */ size_t vfs_bsize; /* Block size of the file system. */ struct vnode *vfs_devvp; /* Device vnonde for this file system. */ struct queue_entry vfs_vnl; /* List of vnodes associated with us. */ }; /* The VFS switch. */ struct vfssw { char *vsw_name; /* Name of file system. */ struct vfs_ops *vsw_ops; /* Operations vector. */ }; extern struct vfssw *vfssw; extern int nvfs; /* Special mounting point (not visible) for the special file system. We use this to detect aliases for device vnodes. */ extern struct vfs specfs_mount; struct file { struct vnode *f_vnode; off_t f_offset; int f_mode; }; void mountroot (char *rootname); #endif /* _VFS_H */