diff options
Diffstat (limited to 'tmpfs')
-rw-r--r-- | tmpfs/dir.c | 5 | ||||
-rw-r--r-- | tmpfs/node.c | 11 | ||||
-rw-r--r-- | tmpfs/tmpfs.h | 1 |
3 files changed, 12 insertions, 5 deletions
diff --git a/tmpfs/dir.c b/tmpfs/dir.c index 25b99bd8..65386e0a 100644 --- a/tmpfs/dir.c +++ b/tmpfs/dir.c @@ -58,9 +58,6 @@ diskfs_get_directs (struct node *dp, int entry, int n, struct dirent *entp; int i; - assert (offsetof (struct tmpfs_dirent, name) - >= offsetof (struct dirent, d_name)); - if (bufsiz == 0) bufsiz = dp->dn_stat.st_size + 2 * ((offsetof (struct dirent, d_name[3]) + 7) & ~7); @@ -247,7 +244,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, > tmpfs_page_limit) return ENOSPC; - new = malloc (entsize); + new = malloc (offsetof (struct tmpfs_dirent, name) + namelen + 1); if (new == 0) return ENOSPC; diff --git a/tmpfs/node.c b/tmpfs/node.c index 55a45723..17fe8ce7 100644 --- a/tmpfs/node.c +++ b/tmpfs/node.c @@ -61,8 +61,10 @@ diskfs_free_node (struct node *np, mode_t mode) switch (np->dn->type) { case DT_REG: - if (np->dn->u.reg.memobj != MACH_PORT_NULL) + if (np->dn->u.reg.memobj != MACH_PORT_NULL) { + vm_deallocate (mach_task_self (), np->dn->u.reg.memref, 4096); mach_port_deallocate (mach_task_self (), np->dn->u.reg.memobj); + } break; case DT_DIR: assert (np->dn->u.dir.entries == 0); @@ -500,6 +502,13 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) past the specified size of the file. */ err = default_pager_object_set_size (np->dn->u.reg.memobj, np->allocsize); + assert_perror (err); + + /* XXX we need to keep a reference to the object, or GNU Mach + will terminate it when we release the map. */ + vm_map (mach_task_self (), &np->dn->u.reg.memref, 4096, 0, 1, + np->dn->u.reg.memobj, 0, 0, VM_PROT_NONE, VM_PROT_NONE, + VM_INHERIT_NONE); } /* XXX always writable */ diff --git a/tmpfs/tmpfs.h b/tmpfs/tmpfs.h index 3032ce3c..3cb31e6b 100644 --- a/tmpfs/tmpfs.h +++ b/tmpfs/tmpfs.h @@ -47,6 +47,7 @@ struct disknode struct { mach_port_t memobj; + vm_address_t memref; unsigned int allocpages; /* largest size while memobj was live */ } reg; struct |