diff options
author | Michael Marineau <mike@marineau.org> | 2008-02-05 01:28:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:15 -0500 |
commit | 818db35992c249dc32c1d86daf7d533fb0952f5d (patch) | |
tree | 8577fe7cff367eade84f632621b16054c362d39a /mm/shmem.c | |
parent | 5b04c6890f0dc7ea6c85b9adebc883c55c667d97 (diff) |
tmpfs: fix mounts when size is less than the page size
When tmpfs is mounted with a size less than one page, the number of blocks
is set to 0 which makes the tmpfs mount unlimited. This can lead to a
quick and surprising death if someone typos a tmpfs mount command and
writes too much.
tmpfs can still be mounted as unlimited if size or nr_blocks is exactly 0,
as Documentation/filesystems/tmpfs.txt says.
Hugh: do this by rounding size up instead of down in all cases: which
slightly expands other odd-sized tmpfs mounts, but in a consistent way.
Signed-off-by: Michael Marineau <mike@marineau.org>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index ce64b6616376..7be94342bf06 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2012,7 +2012,7 @@ static int shmem_parse_options(char *options, int *mode, uid_t *uid, | |||
2012 | } | 2012 | } |
2013 | if (*rest) | 2013 | if (*rest) |
2014 | goto bad_val; | 2014 | goto bad_val; |
2015 | *blocks = size >> PAGE_CACHE_SHIFT; | 2015 | *blocks = DIV_ROUND_UP(size, PAGE_CACHE_SIZE); |
2016 | } else if (!strcmp(this_char,"nr_blocks")) { | 2016 | } else if (!strcmp(this_char,"nr_blocks")) { |
2017 | *blocks = memparse(value,&rest); | 2017 | *blocks = memparse(value,&rest); |
2018 | if (*rest) | 2018 | if (*rest) |