mknod bug?

Ken Brown
Sat May 21 21:22:24 GMT 2022

The definition of mknod in 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 [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/ b/winsup/cygwin/
index 3a652c4f4..344d1d329 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -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);
+EXPORT_ALIAS (mknod32, mknod)

  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?


More information about the Cygwin-developers mailing list