summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksym Planeta <mcsim.planeta@gmail.com>2012-01-23 02:29:18 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-02 00:18:57 +0200
commitbf1a2c7dd16ff547fdf00c5730f7476fa8e7bca0 (patch)
treed0c27790af316509e491470421b8163c096a5a59
parent24b07e7a3e7ff8b48033de422f27db7c0a2c690d (diff)
Correct handling of object size.
* tmpfs/node.c (diskfs_truncate): Pass the original (non-rounded) size to default_pager_object_set_size. (diskfs_grow): Likewise. (diskfs_get_filemap): Do not set object size, as default_pager_object_create already sets it.
-rw-r--r--tmpfs/node.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/tmpfs/node.c b/tmpfs/node.c
index 9d3647f8..bce15370 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -403,13 +403,12 @@ diskfs_truncate (struct node *np, off_t size)
np->dn_stat.st_size = size;
+ off_t set_size = size;
size = round_page (size);
- if (size == np->allocsize)
- return 0;
if (np->dn->u.reg.memobj != MACH_PORT_NULL)
{
- error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, size);
+ error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, set_size);
if (err == MIG_BAD_ID)
/* This is an old default pager. We have no way to truncate the
memory object. Note that the behavior here will be wrong in
@@ -442,6 +441,7 @@ diskfs_grow (struct node *np, off_t size, struct protid *cred)
if (np->allocsize >= size)
return 0;
+ off_t set_size = size;
size = round_page (size);
if (round_page (tmpfs_space_used + size - np->allocsize)
/ vm_page_size > tmpfs_page_limit)
@@ -453,7 +453,7 @@ diskfs_grow (struct node *np, off_t size, struct protid *cred)
if (np->dn->u.reg.memobj != MACH_PORT_NULL)
{
/* Increase the limit the memory object will allow to be accessed. */
- error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, size);
+ error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, set_size);
if (err == MIG_BAD_ID) /* Old default pager, never limited it. */
err = 0;
if (err)
@@ -507,11 +507,6 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot)
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);
-
- /* A new-fangled default pager lets us prevent user accesses
- past the specified size of the file. */
- err = default_pager_object_set_size (np->dn->u.reg.memobj,
- np->allocsize);
assert_perror (err);
}