mknod bug?

Ken Brown kbrown@cornell.edu
Sun May 22 16:19:28 GMT 2022


On 5/21/2022 5:22 PM, Ken Brown wrote:
> The definition of mknod in syscalls.cc has a third argument of type __dev16_t 
> instead of dev_t.  This doesn't matter on 32-bit Cygwin, because calls to mknod 
> are redirected to mknod32 via NEW_FUNCTIONS in Makefile.am [cygwin-3_3-branch 
> only].  Presumably this definition exists for the sake of old 32-bit apps that 
> were built when dev_t was 16 bits.
> 
> But it seems to be a clear bug on 64-bit Cygwin.  I think we need the following, 
> similar to what we do for many other syscalls:
> 
> diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
> index 3a652c4f4..344d1d329 100644
> --- a/winsup/cygwin/syscalls.cc
> +++ b/winsup/cygwin/syscalls.cc
> @@ -3490,11 +3490,15 @@ mknod32 (const char *path, mode_t mode, dev_t dev)
>     return -1;
>   }
> 
> +#ifdef __i386__
>   extern "C" int
>   mknod (const char *_path, mode_t mode, __dev16_t dev)
>   {
>     return mknod32 (_path, mode, (dev_t) dev);
>   }
> +#else
> +EXPORT_ALIAS (mknod32, mknod)
> +#endif
> 
>   extern "C" int
>   mkfifo (const char *path, mode_t mode)
> 
> If I'm right, this is a longstanding bug, and I'm surprised no one has noticed 
> it before.  Am I missing something?

I sent the patch to cygwin-patches.  Any comments should probably go there.

Ken


More information about the Cygwin-developers mailing list