next up previous contents
Next: 3.4 Composition Up: 3. Mechanisms for Interposition Previous: 3.2 Creating Links Among

   
3.3 Using Links Among Vnodes

Most other vnode/VFS operations in Wrapfs are very simple: they call the operation on the interposed vnode and return the status code. Figure fig-wrapfs-getattr sketches the wrapping implementation of the ``Get File Attributes'' operation, getattr. The pattern is similar to that shown in Figure fig-wrapfs-create but differs in that fist_wrap_interpose() is not called. In the case of getattr, all that happens is that VOP_GETATTR expands into the getattr operation appropriate for the type of vnode that is interposed upon. Before and after invoking the vnode operation on the interposed vnode, it is possible to manipulate the arguments passed or results returned.


  
Figure: Skeleton Getattr Operation for the ``Wrap'' File System Type

Figure: Skeleton Getattr Operation for the ``Wrap'' File System Type


static int fist_wrap_getattr(vnode_t *vp, vattr_t *vap,
                             int flags, cred_t *cr)
{
  int error = 0;
  vnode_t *hidden_vp;

  /* get interposed-on vnode */
  hidden_vp = vntofwn(vp)->fwn_vnodep[0];

  /* Note: can manipulate passed arguments here */

  /* pass operation to interposed-on file system and return status */
  error = VOP_GETATTR(hidden_vp, vap, flags, cr);

  /* Note: can manipulate returning results here */

  return (error);
}





5.1in


static int fist_wrap_getattr(vnode_t *vp, vattr_t *vap,
                             int flags, cred_t *cr)
{
  int error = 0;
  vnode_t *hidden_vp;

  /* get interposed-on vnode */
  hidden_vp = vntofwn(vp)->fwn_vnodep[0];

  /* Note: can manipulate passed arguments here */

  /* pass operation to interposed-on file system and return status */
  error = VOP_GETATTR(hidden_vp, vap, flags, cr);

  /* Note: can manipulate returning results here */

  return (error);
}



Erez Zadok
1999-12-07