tmpfs: Implement vptofh, so programs open files in tmpfs could coredump
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 25 Oct 2011 11:57:33 +0000 (19:57 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 25 Oct 2011 11:59:24 +0000 (19:59 +0800)
Submitted-by: Tim Bissont <bissont@mac.com>
sys/vfs/tmpfs/tmpfs_vfsops.c

index 8465fb1..31e4b52 100644 (file)
@@ -500,6 +500,22 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred)
        return 0;
 }
 
+/* --------------------------------------------------------------------- */ 
+
+static int
+tmpfs_vptofh(struct vnode *vp, struct fid *fhp)
+{
+       struct tmpfs_node *node;
+       struct tmpfs_fid tfh;
+       node = VP_TO_TMPFS_NODE(vp);
+       memset(&tfh, 0, sizeof(tfh));
+       tfh.tf_len = sizeof(struct tmpfs_fid);
+       tfh.tf_gen = node->tn_gen;
+       tfh.tf_id = node->tn_id;
+       memcpy(fhp, &tfh, sizeof(tfh));
+       return (0);
+}
+
 /* --------------------------------------------------------------------- */
 
 /*
@@ -512,6 +528,7 @@ static struct vfsops tmpfs_vfsops = {
        .vfs_root =                     tmpfs_root,
        .vfs_statfs =                   tmpfs_statfs,
        .vfs_fhtovp =                   tmpfs_fhtovp,
+       .vfs_vptofh =                   tmpfs_vptofh, 
        .vfs_sync =                     vfs_stdsync
 };