Hello,

The new size check appears to be reversed. With 4096-byte pages, an
8192-byte limit now gives one page
instead of two, while a 2048-byte limit still gives zero. If the intent is
to allow at least one page for a positive size,
please apply that minimum only to sub-page requests and keep the existing
division for larger sizes.

Could you also guard the page-limit update with a check for the unset size?
As written, changing only the root
mode also overwrites tmpfs_page_limit. The mode update can then appear
once, after the size check.

Best regards,
Alperen Erkan

On Mon, Nov 23, 2026 at 6:56 PM Ahmed Khider <[email protected]> wrote:

> ---
>  tmpfs/tmpfs.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
> index ad5e2983..183e0190 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);
> @@ -202,7 +202,7 @@ parse_opt (int key, char *arg, struct argp_state
> *state)
>        {
>         char *end = NULL;
>         mode_t mode = strtoul (arg, &end, 8);
> -       if (end == NULL || end == arg)
> +       if (end == NULL || end == arg || *end != '\0')
>           {
>             argp_error (state, "argument must be an octal number");
>             return EINVAL;
> @@ -257,10 +257,22 @@ 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;
> -      tmpfs_root_mode = values->mode;
> -      break;
> +      if (vm_page_size > values->size)
> +       {
> +         tmpfs_page_limit = values->size / vm_page_size;
> +         if (values->mode != (mode_t)-1)
> +           tmpfs_root_mode = values->mode;
> +         break;
> +       }
> +      else
> +       {
> +         tmpfs_page_limit = 1;
> +         if (values->mode != (mode_t)-1)
> +           tmpfs_root_mode = values->mode;
> +         break;
> +       }
>
> +
>      default:
>        return ARGP_ERR_UNKNOWN;
>      }
> --
> 2.47.3
>
>
>

Reply via email to