Hello,
Ahmed Khider, le mar. 24 nov. 2026 01:48:40 +0300, a ecrit:
> diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
> index ad5e298..5799249 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;
Is this fixing a warning?
> break;
> case ARGP_KEY_FINI:
> free (values);
> @@ -202,7 +202,8 @@ 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)
> + errno = 0;
> + if (errno != 0 || *end !='\0' || arg[0] > 7 || arg[0] < 0)
Testing errno is meaningless this way, you want to set it before calling
strtoul.
The test of arg[0] look completely wrong: did you mean to test against
'7' and '0'? strtoul is already checking that the base is respected
anyway.
> {
> argp_error (state, "argument must be an octal number");
> return EINVAL;
> @@ -257,8 +258,14 @@ 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;
> + if(values->size > vm_page_size )
> + tmpfs_page_limit = values->size / vm_page_size;
> + else
> + tmpfs_page_limit = 1;
I would say rather make the division use an upper rounding: if the user
asked for 5000 available bytes, they should get 8192.
> +
> + if(values->mode != (mode_t) -1)
> + tmpfs_root_mode = values->mode;
I don't see the point? tmpfs_root_mode is already -1 by default.
Samuel