---
tmpfs/tmpfs.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index ad5e298..ce43a36 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -191,7 +191,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
return ENOMEM;
state->hook = values;
values->size = -1;
- values->mode = -1;
+ values->mode = (mode_t) -1;
break;
case ARGP_KEY_FINI:
free (values);
@@ -199,10 +199,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case 'm': /* --mode=OCTAL */
- {
+ {
+ errno = 0;
char *end = NULL;
mode_t mode = strtoul (arg, &end, 8);
- if (end == NULL || end == arg)
+ if (errno != 0 || *end != '\0' || end == NULL || end == arg)
{
argp_error (state, "argument must be an octal number");
return EINVAL;
@@ -257,7 +258,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
case ARGP_KEY_SUCCESS:
/* All options parse successfully, so implement ours if possible. */
- tmpfs_page_limit = values->size / vm_page_size;
+
+ if(values->size > vm_page_size )
+ tmpfs_page_limit = (values->size + vm_page_size -1) / vm_page_size;
+ else
+ tmpfs_page_limit = 1;
+
tmpfs_root_mode = values->mode;
break;
--
2.47.3