mknod.c 747 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * mknod() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <sys/stat.h>
  10. #if defined __NR_mknodat && !defined __NR_mknod
  11. # include <fcntl.h>
  12. int mknod(const char *path, mode_t mode, dev_t dev)
  13. {
  14. return mknodat(AT_FDCWD, path, mode, dev);
  15. }
  16. #else
  17. int mknod(const char *path, mode_t mode, dev_t dev)
  18. {
  19. unsigned long long int k_dev;
  20. /* We must convert the value to dev_t type used by the kernel. */
  21. k_dev = (dev) & ((1ULL << 32) - 1);
  22. if (k_dev != dev) {
  23. __set_errno(EINVAL);
  24. return -1;
  25. }
  26. return INLINE_SYSCALL(mknod, 3, path, mode, (unsigned int)k_dev);
  27. }
  28. #endif
  29. libc_hidden_def(mknod)