From f6fb7805fca208bc9b8d1ffb0e03fb78fe004846 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Fri, 14 Mar 2014 01:43:55 +0000 Subject: Fix -o size less than PAGE_SIZE resulting in SIZE_MAX being used. Discussed with: kib MFC after: 2 weeks --- sys/fs/tmpfs/tmpfs_vfsops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/fs/tmpfs/tmpfs_vfsops.c') diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 57b9902..d5967ae 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -200,11 +200,13 @@ tmpfs_mount(struct mount *mp) * allowed to use, based on the maximum size the user passed in * the mount structure. A value of zero is treated as if the * maximum available space was requested. */ - if (size_max < PAGE_SIZE || size_max > OFF_MAX - PAGE_SIZE || + if (size_max == 0 || size_max > OFF_MAX - PAGE_SIZE || (SIZE_MAX < OFF_MAX && size_max / PAGE_SIZE >= SIZE_MAX)) pages = SIZE_MAX; - else + else { + size_max = roundup(size_max, PAGE_SIZE); pages = howmany(size_max, PAGE_SIZE); + } MPASS(pages > 0); if (nodes_max <= 3) { -- cgit v1.1