vnode - #ifndef _VNODE_H_ #define _VNODE_H_ struct uio;...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#ifndef _VNODE_H_ #define _VNODE_H_ struct uio; struct stat; /* * A struct vnode is an abstract representation of a file. * * It is an interface in the Java sense that allows the kernel's * filesystem-independent code to interact usefully with multiple sets * of filesystem code. */ /* * Abstract low-level file. * * Note: vn_fs may be null if the vnode refers to a device. * * vn_opencount is managed using VOP_INCOPEN and VOP_DECOPEN by * vfs_open() and vfs_close(). Code above the VFS layer should not * need to worry about it. */ struct vnode { int vn_refcount; /* Reference count */ int vn_opencount; struct lock *vn_countlock; /* Lock for vn_refcount/opencount */ struct fs *vn_fs; /* Filesystem vnode belongs to */ void *vn_data; /* Filesystem-specific data */ const struct vnode_ops *vn_ops; /* Functions on this vnode */ }; /* * Abstract operations on a vnode. * * These are used in the form VOP_FOO(vnode, args), which are macros * that expands to vnode->vn_ops->vop_foo(vnode, args). The operations * "foo" are: * * vop_open - Called on *each* open() of a file. Can be used to * reject illegal or undesired open modes. Note that * various operations can be performed without the * file actually being opened. * The vnode need not look at O_CREAT, O_EXCL, or * O_TRUNC, as these are handled in the VFS layer. * * VOP_OPEN should not be called directly from above * the VFS layer - use vfs_open() to open vnodes. * This maintains the open count so VOP_CLOSE can be * called at the right time. * * vop_close - To be called on *last* close() of a file. * * VOP_CLOSE should not be called directly from above * the VFS layer - use vfs_close() to close vnodes * opened with vfs_open(). * * vop_reclaim - Called when vnode is no longer in use. Note that * this may be substantially after vop_close is * called. *
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
***************************************** * * vop_read - Read data from file to uio, at offset specified * in the uio, updating uio_resid to reflect the * amount read, and updating uio_offset to match. * Not allowed on directories or symlinks. * * vop_readlink - Read the contents of a symlink into a uio. * Not allowed on other types of object. * * vop_getdirentry - Read a single filename from a directory into a
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/15/2012 for the course CS 153 taught by Professor Brecht during the Spring '12 term at Alabama.

Page1 / 5

vnode - #ifndef _VNODE_H_ #define _VNODE_H_ struct uio;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online