On Tuesday, 24 November 2026 at 09:29, Ahmed Khider <[email protected]> 
wrote:

> ---
>  tmpfs/tmpfs.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
> index ad5e298..af8aedf 100644
> --- a/tmpfs/tmpfs.c
> +++ b/tmpfs/tmpfs.c
> @@ -118,9 +118,10 @@ struct option_values
>  static error_t
>  parse_opt_size (const char *arg, struct argp_state *state, off_t *newsize)
>  {
> +  errno = 0;
>    char *end = NULL;
>    intmax_t size = strtoimax (arg, &end, 0);
> -  if (end == NULL || end == arg)
> +  if (errno != 0 || *end != '\0' || end == arg)
>      {
>        argp_error (state, "argument must be a number");
>        return EINVAL;
> @@ -163,7 +164,7 @@ parse_opt_size (const char *arg, struct argp_state 
> *state, off_t *newsize)
>       }
>      }
>    size = (off_t) size;
> -  if (size < 0)
> +  if (size > 0)
>      {
>        argp_error (state, "size too large");
>        return EINVAL;
> @@ -200,9 +201,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
> 
>      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 == arg)
>         {
>           argp_error (state, "argument must be an octal number");
>           return EINVAL;
> @@ -257,7 +259,7 @@ 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_page_limit = (values->size + vm_page_size - 1) / vm_page_size;
>        tmpfs_root_mode = values->mode;
>        break;
> 
> @@ -419,7 +421,7 @@ main (int argc, char **argv)
>    if (err)
>      {
>        error (0, err, "cannot stat underlying node");
> -      if (tmpfs_root_mode == -1)
> +      if (tmpfs_root_mode == (mode_t) -1)
>       diskfs_root_node->dn_stat.st_mode |= 0777 | S_ISVTX;
>        else
>       diskfs_root_node->dn_stat.st_mode |= tmpfs_root_mode;
> @@ -429,7 +431,7 @@ main (int argc, char **argv)
>      }
>    else
>      {
> -      if (tmpfs_root_mode == -1)
> +      if (tmpfs_root_mode == (mode_t) -1)
>       {
>         diskfs_root_node->dn_stat.st_mode |= st.st_mode &~ S_IFMT;
>         if (S_ISREG (st.st_mode) && (st.st_mode & 0111) == 0)
> --
> 2.47.3
> 
> 
> 

What's the intent of this patch?

Hakan

Reply via email to