mknod bug (in uClibc)

Doug Graham dgraham at nortel.com
Thu Nov 13 11:35:57 PST 2008


This is probably the wrong mailing list to report this bug to, but it's
the one I subscribe to, and this bug is relevant to this list, so you
might be interested.

uClibc's mknod implementation looks like this:

  int mknod(const char *path, mode_t mode, dev_t dev)
  {
       /* We must convert the dev_t value to a __kernel_dev_t */
       __kernel_dev_t k_dev;

       k_dev = ((major(dev) & 0xff) << 8) | (minor(dev) & 0xff);
       return __syscall_mknod(path, mode, k_dev);
  }

That conversion to k_dev only works properly on kernels where a
__kernel_dev_t is 16 bits.  On modern kernels, a __kernel_dev_t is
32 bits.  This is a problem for us, as we're using minor device numbers
greater than 256.  Since it's easier for us to change busybox than it
is to change uClibc on all platforms, we've worked around this bug by
changing the mknod(name, mode, dev) call in coreutils/mknod.c to this
instead:

  syscall(SYS_mknod, name, mode, (uint32_t) dev)

It would probably also have been possible to call __syscall_mknod()
directly.

--Doug.


More information about the busybox mailing list