rtems-kernel-init.c tries to re-make existing "/etc"

Kinsey Moore kinsey.moore at oarcorp.com
Thu Apr 18 14:34:06 UTC 2024


On Thu, Apr 18, 2024 at 9:18 AM Peter Dufault <dufault at hda.com> wrote:

> I just rebased to "6-freebsd-12".  This change:
>
> ###
> commit 62e0ca8283603573d42a0f15da044cd406a2f00a
> Author: Kinsey Moore <kinsey.moore at oarcorp.com>
> Date:   Tue Jan 23 13:25:45 2024 -0600
>
>     rtemsbsd/rtems: Check function return values
> ###
> [dufault at gen6 rtems-libbsd]$ git diff
> 6514d561587fd1527fe6a26cb43e6b5742c8c779 rtemsbsd/rtems/rtems-kernel-init.c
> diff --git a/rtemsbsd/rtems/rtems-kernel-init.c
> b/rtemsbsd/rtems/rtems-kernel-init.c
> index 90a9c80..8ac2f59 100644
> --- a/rtemsbsd/rtems/rtems-kernel-init.c
> +++ b/rtemsbsd/rtems/rtems-kernel-init.c
> @@ -223,7 +223,9 @@ rtems_bsd_initialize(void)
>                 return RTEMS_UNSATISFIED;
>         }
>
> -       mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
> +       if (mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
> +               return RTEMS_UNSATISFIED;
> +       }
>
>         sc = rtems_timer_initiate_server(rtems_bsd_get_task_priority(name),
>             rtems_bsd_get_task_stack_size(name), RTEMS_DEFAULT_ATTRIBUTES);
> ###
>
> causes a crash at startup in "uma_zalloc()" (in at least the "telnetd01"
> test).
> I printed out the error, the directory already exists:
>
> mkdir("/etc",...): File exists
>
> For now I'm just checking for EEXIST and ignoring the error.
> Does anyone care to object now and say I should investigate further to fix
> the caller before I submit a patch?
>

A patch for EEXIST here should be fine. It would be nice if the caller were
more resilient.

Kinsey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20240418/bbe10033/attachment.htm>


More information about the devel mailing list