diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-01 03:03:59 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2010-08-01 03:03:59 +0200 |
commit | 05b2f1f650af3b2e41c79d96bed67f9af0d4ef9d (patch) | |
tree | 766c05bc311918c23e569fb5a1581f5654614223 /mach-defpager | |
parent | ba374ac11cbf23bc814834a7b78594ed021ab9bc (diff) |
Fix swap on large devices
DEV_GET_SIZE values overflow with large devices, rather use
DEV_GET_RECORDS.
* mach-defpager/setup.c (S_default_pager_paging_storage): Use DEV_GET_RECORDS
instead of DEV_GET_SIZE.
Diffstat (limited to 'mach-defpager')
-rw-r--r-- | mach-defpager/setup.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mach-defpager/setup.c b/mach-defpager/setup.c index aea4310f..e7e89299 100644 --- a/mach-defpager/setup.c +++ b/mach-defpager/setup.c @@ -1,6 +1,6 @@ /* Backing store access callbacks for Hurd version of Mach default pager. - Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2007, 2010 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -45,7 +45,7 @@ S_default_pager_paging_storage (mach_port_t pager, boolean_t add) { struct file_direct *fdp; - int sizes[DEV_GET_SIZE_COUNT]; + int sizes[DEV_GET_RECORDS_COUNT]; natural_t count; mach_msg_type_number_t i; error_t err; @@ -60,15 +60,15 @@ S_default_pager_paging_storage (mach_port_t pager, if (nrun < 2 || nrun % 2 != 0) return EINVAL; - count = DEV_GET_SIZE_COUNT; - err = device_get_status (device, DEV_GET_SIZE, sizes, &count); + count = DEV_GET_RECORDS_COUNT; + err = device_get_status (device, DEV_GET_RECORDS, sizes, &count); if (err) return err; - if (count < DEV_GET_SIZE_COUNT || sizes[DEV_GET_SIZE_RECORD_SIZE] <= 0) + if (count < DEV_GET_RECORDS_COUNT || sizes[DEV_GET_RECORDS_RECORD_SIZE] <= 0) return EINVAL; - devsize = sizes[DEV_GET_SIZE_DEVICE_SIZE] / sizes[DEV_GET_SIZE_RECORD_SIZE]; + devsize = sizes[DEV_GET_RECORDS_DEVICE_RECORDS]; - if (vm_page_size % sizes[DEV_GET_SIZE_RECORD_SIZE] != 0) + if (vm_page_size % sizes[DEV_GET_RECORDS_RECORD_SIZE] != 0) /* We can't write disk blocks larger than pages. */ return EINVAL; @@ -77,8 +77,8 @@ S_default_pager_paging_storage (mach_port_t pager, return ENOMEM; fdp->device = device; - fdp->bshift = ffs (sizes[DEV_GET_SIZE_RECORD_SIZE]) - 1; - fdp->fd_bsize = sizes[DEV_GET_SIZE_RECORD_SIZE]; + fdp->bshift = ffs (sizes[DEV_GET_RECORDS_RECORD_SIZE]) - 1; + fdp->fd_bsize = sizes[DEV_GET_RECORDS_RECORD_SIZE]; fdp->nruns = nrun / 2; fdp->fd_size = 0; for (i = 0; i < nrun; i += 2) |