Skip to content
  • Keno Fischer's avatar
    029ed1bd
    9p: darwin: Implement compatibility for mknodat · 029ed1bd
    Keno Fischer authored
    
    
    Darwin does not support mknodat. However, to avoid race conditions
    with later setting the permissions, we must avoid using mknod on
    the full path instead. We could try to fchdir, but that would cause
    problems if multiple threads try to call mknodat at the same time.
    However, luckily there is a solution: Darwin includes a function
    that sets the cwd for the current thread only.
    This should suffice to use mknod safely.
    
    This function (pthread_fchdir_np) is protected by a check in
    meson in a patch later in this series.
    
    Signed-off-by: default avatarKeno Fischer <keno@juliacomputing.com>
    Signed-off-by: default avatarMichael Roitzsch <reactorcontrol@icloud.com>
    [Will Cohen: - Adjust coding style
                 - Replace clang references with gcc
                 - Note radar filed with Apple for missing syscall
                 - Replace direct syscall with pthread_fchdir_np and
                   adjust patch notes accordingly
                 - Declare pthread_fchdir_np with
                 - __attribute__((weak_import)) to allow checking for
                   its presence before usage
                 - Move declarations above cplusplus guard
                 - Add CONFIG_PTHREAD_FCHDIR_NP to meson and check for
                   presence in 9p-util
                 - Rebase to apply cleanly on top of the 2022-02-10
                   changes to 9pfs
                 - Fix line over 90 characters formatting error]
    Signed-off-by: default avatarWill Cohen <wwcohen@gmail.com>
    Message-Id: <20220227223522.91937-10-wwcohen@gmail.com>
    Signed-off-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
    Reviewed-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
    029ed1bd
    9p: darwin: Implement compatibility for mknodat
    Keno Fischer authored
    
    
    Darwin does not support mknodat. However, to avoid race conditions
    with later setting the permissions, we must avoid using mknod on
    the full path instead. We could try to fchdir, but that would cause
    problems if multiple threads try to call mknodat at the same time.
    However, luckily there is a solution: Darwin includes a function
    that sets the cwd for the current thread only.
    This should suffice to use mknod safely.
    
    This function (pthread_fchdir_np) is protected by a check in
    meson in a patch later in this series.
    
    Signed-off-by: default avatarKeno Fischer <keno@juliacomputing.com>
    Signed-off-by: default avatarMichael Roitzsch <reactorcontrol@icloud.com>
    [Will Cohen: - Adjust coding style
                 - Replace clang references with gcc
                 - Note radar filed with Apple for missing syscall
                 - Replace direct syscall with pthread_fchdir_np and
                   adjust patch notes accordingly
                 - Declare pthread_fchdir_np with
                 - __attribute__((weak_import)) to allow checking for
                   its presence before usage
                 - Move declarations above cplusplus guard
                 - Add CONFIG_PTHREAD_FCHDIR_NP to meson and check for
                   presence in 9p-util
                 - Rebase to apply cleanly on top of the 2022-02-10
                   changes to 9pfs
                 - Fix line over 90 characters formatting error]
    Signed-off-by: default avatarWill Cohen <wwcohen@gmail.com>
    Message-Id: <20220227223522.91937-10-wwcohen@gmail.com>
    Signed-off-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
    Reviewed-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
Loading