syscalls.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * some system calls possibly missing from libc
  4. *
  5. * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <stdio.h>
  23. #include <errno.h>
  24. #include <unistd.h>
  25. /* Kernel headers before 2.1.mumble need this on the Alpha to get
  26. _syscall* defined. */
  27. #define __LIBRARY__
  28. #include <sys/syscall.h>
  29. #include "libbb.h"
  30. int sysfs(int option, unsigned int fs_index, char * buf)
  31. {
  32. return(syscall(__NR_sysfs, option, fs_index, buf));
  33. }
  34. int pivot_root(const char * new_root,const char * put_old)
  35. {
  36. #ifndef __NR_pivot_root
  37. #warning This kernel does not support the pivot_root syscall
  38. #warning -> The pivot_root system call is being stubbed out...
  39. /* BusyBox was compiled against a kernel that did not support
  40. * the pivot_root system call. To make this application work,
  41. * you will need to recompile with a kernel supporting the
  42. * pivot_root system call.
  43. */
  44. bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
  45. "BusyBox with a kernel supporting the pivot_root system call.\n");
  46. errno = ENOSYS;
  47. return -1;
  48. #else
  49. return(syscall(__NR_pivot_root, new_root, put_old));
  50. #endif /* __NR_pivot_root */
  51. }
  52. /* These syscalls are not included in ancient glibc versions,
  53. so we have to define them ourselves, whee ! */
  54. #if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
  55. int bdflush(int func, int data)
  56. {
  57. return(syscall(__NR_bdflush, func, data));
  58. }
  59. #ifndef __alpha__
  60. # define __NR_klogctl __NR_syslog
  61. int klogctl(int type, char *b, int len)
  62. {
  63. return(syscall(__NR_klogctl, type, b, len));
  64. }
  65. #endif /* __alpha__ */
  66. int umount2(const char * special_file, int flags)
  67. {
  68. #ifndef __NR_umount2
  69. #warning This kernel does not support the umount2 syscall
  70. #warning -> The umount2 system call is being stubbed out...
  71. /* BusyBox was compiled against a kernel that did not support
  72. * the umount2 system call. To make this application work,
  73. * you will need to recompile with a kernel supporting the
  74. * umount2 system call.
  75. */
  76. bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
  77. "BusyBox with a kernel supporting the umount2 system call.\n");
  78. errno = ENOSYS;
  79. return -1;
  80. #else
  81. return(syscall(__NR_umount2, special_file, flags));
  82. #endif /* __NR_pivot_root */
  83. }
  84. #endif /* old glibc check */
  85. /* END CODE */
  86. /*
  87. Local Variables:
  88. c-file-style: "linux"
  89. c-basic-offset: 4
  90. tab-width: 4
  91. End:
  92. */