1. 30 5月, 2014 1 次提交
    • R
      support linux kernel apis (new archs) with old syscalls removed · dd5f50da
      Rich Felker 提交于
      such archs are expected to omit definitions of the SYS_* macros for
      syscalls their kernels lack from arch/$ARCH/bits/syscall.h. the
      preprocessor is then able to select the an appropriate implementation
      for affected functions. two basic strategies are used on a
      case-by-case basis:
      
      where the old syscalls correspond to deprecated library-level
      functions, the deprecated functions have been converted to wrappers
      for the modern function, and the modern function has fallback code
      (omitted at the preprocessor level on new archs) to make use of the
      old syscalls if the new syscall fails with ENOSYS. this also improves
      functionality on older kernels and eliminates the incentive to program
      with deprecated library-level functions for the sake of compatibility
      with older kernels.
      
      in other situations where the old syscalls correspond to library-level
      functions which are not deprecated but merely lack some new features,
      such as the *at functions, the old syscalls are still used on archs
      which support them. this may change at some point in the future if or
      when fallback code is added to the new functions to make them usable
      (possibly with reduced functionality) on old kernels.
      dd5f50da
  2. 28 2月, 2014 1 次提交
    • R
      rename superh port to "sh" for consistency · aacd3486
      Rich Felker 提交于
      linux, gcc, etc. all use "sh" as the name for the superh arch. there
      was already some inconsistency internally in musl: the dynamic linker
      was searching for "ld-musl-sh.path" as its path file despite its own
      name being "ld-musl-superh.so.1". there was some sentiment in both
      directions as to how to resolve the inconsistency, but overall "sh"
      was favored.
      aacd3486
  3. 24 2月, 2014 1 次提交
  4. 20 12月, 2013 1 次提交
    • R
      fix failure of fchmod, fstat, fchdir, and fchown to produce EBADF · 65ea604c
      Rich Felker 提交于
      the workaround/fallback code for supporting O_PATH file descriptors
      when the kernel lacks support for performing these operations on them
      caused EBADF to get replaced by ENOENT (due to missing entry in
      /proc/self/fd). this is unlikely to affect real-world code (calls that
      might yield EBADF are generally unsafe, especially in library code)
      but it was breaking some test cases.
      
      the fix I've applied is something of a tradeoff: it adds one syscall
      to these operations on kernels where the workaround is needed. the
      alternative would be to catch ENOENT from the /proc lookup and
      translate it to EBADF, but I want to avoid doing that in the interest
      of not touching/depending on /proc at all in these functions as long
      as the kernel correctly supports the operations. this is following the
      general principle of isolating hacks to code paths that are taken on
      broken systems, and keeping the code for correct systems completely
      hack-free.
      65ea604c
  5. 12 12月, 2013 1 次提交
  6. 07 12月, 2013 1 次提交
  7. 02 11月, 2013 2 次提交
  8. 18 10月, 2013 1 次提交
  9. 13 10月, 2013 1 次提交
    • R
      fix uid/gid-setting error in faccessat with AT_EACCESS flag · 51635856
      Rich Felker 提交于
      this fixes an issue reported by Daniel Thau whereby faccessat with the
      AT_EACCESS flag did not work in cases where the process is running
      suid or sgid but without root privileges. per POSIX, when the process
      does not have "appropriate privileges", setuid changes the euid, not
      the real uid, and the target uid must be equal to the current real or
      saved uid; if this condition is not met, EPERM results. this caused
      the faccessat child process to fail.
      
      using the setreuid syscall rather than setuid works. POSIX leaves it
      unspecified whether setreuid can set the real user id to the effective
      user id on processes without "appropriate privileges", but Linux
      allows this; if it's not allowed, there would be no way for this
      function to work.
      51635856
  10. 09 10月, 2013 1 次提交
    • R
      fix errno value for getcwd when size argument is zero · 4fb7df12
      Rich Felker 提交于
      based on patch by Michael Forney. at the same time, I've changed the
      if branch to be more clear, avoiding the comma operator.
      
      the underlying issue is that Linux always returns ERANGE when size is
      too short, even when it's zero, rather than returning EINVAL for the
      special case of zero as required by POSIX.
      4fb7df12
  11. 01 9月, 2013 1 次提交
  12. 10 8月, 2013 1 次提交
  13. 03 8月, 2013 3 次提交
    • R
      fix faccessat to support AT_EACCESS flag · 0a05eace
      Rich Felker 提交于
      this is another case of the kernel syscall failing to support flags
      where it needs to, leading to horrible workarounds in userspace. this
      time the workaround requires changing uid/gid, and that's not safe to
      do in the current process. in the worst case, kernel resource limits
      might prevent recovering the original values, and then there would be
      no way to safely return. so, use the safe but horribly inefficient
      alternative: forking. clone is used instead of fork to suppress
      signals from the child.
      
      fortunately this worst-case code is only needed when effective and
      real ids mismatch, which mainly happens in suid programs.
      0a05eace
    • R
      make fchdir, fchmod, fchown, and fstat support O_PATH file descriptors · 9ca1f62b
      Rich Felker 提交于
      on newer kernels, fchdir and fstat work anyway. this same fix should
      be applied to any other syscalls that are similarly affected.
      
      with this change, the current definitions of O_SEARCH and O_EXEC as
      O_PATH are mostly conforming to POSIX requirements. the main remaining
      issue is that O_NOFOLLOW has different semantics.
      9ca1f62b
    • R
      debloat code that depends on /proc/self/fd/%d with shared function · c8c0844f
      Rich Felker 提交于
      I intend to add more Linux workarounds that depend on using these
      pathnames, and some of them will be in "syscall" functions that, from
      an anti-bloat standpoint, should not depend on the whole snprintf
      framework.
      c8c0844f
  14. 09 7月, 2013 2 次提交
  15. 25 3月, 2013 1 次提交
  16. 04 2月, 2013 1 次提交
  17. 11 12月, 2012 1 次提交
  18. 25 10月, 2012 1 次提交
    • R
      greatly improve freopen behavior · 892cafff
      Rich Felker 提交于
      1. don't open /dev/null just as a basis to copy flags; use shared
      __fmodeflags function to get the right file flags for the mode.
      
      2. handle the case (probably invalid, but whatever) case where the
      original stream's file descriptor was closed; previously, the logic
      re-closed it.
      
      3. accept the "e" mode flag for close-on-exec; update dup3 to fallback
      to using dup2 so we can simply call __dup3 instead of putting fallback
      logic in freopen itself.
      892cafff
  19. 19 10月, 2012 1 次提交
    • R
      overhaul system() and popen() to use vfork; fix various related bugs · 44eb4d8b
      Rich Felker 提交于
      since we target systems without overcommit, special care should be
      taken that system() and popen(), like posix_spawn(), do not fail in
      processes whose commit charges are too high to allow ordinary forking.
      
      this in turn requires special precautions to ensure that the parent
      process's signal handlers do not end up running in the shared-memory
      child, where they could corrupt the state of the parent process.
      
      popen has also been updated to use pipe2, so it does not have a
      fd-leak race in multi-threaded programs. since pipe2 is missing on
      older kernels, (non-atomic) emulation has been added.
      
      some silly bugs in the old code should be gone too.
      44eb4d8b
  20. 30 9月, 2012 1 次提交
  21. 29 9月, 2012 1 次提交
  22. 25 9月, 2012 1 次提交
    • R
      fix handling of EINTR during close() · 82dc1e2e
      Rich Felker 提交于
      austin group interpretation for defect #529
      (http://austingroupbugs.net/view.php?id=529) tightens the
      requirements on close such that, if it returns with EINTR, the file
      descriptor must not be closed. the linux kernel developers vehemently
      disagree with this, and will not change it. we catch and remap EINTR
      to EINPROGRESS, which the standard allows close() to return when the
      operation was not finished but the file descriptor has been closed.
      82dc1e2e
  23. 10 9月, 2012 2 次提交
  24. 09 9月, 2012 1 次提交
  25. 07 9月, 2012 3 次提交
    • R
      further use of _Noreturn, for non-plain-C functions · 0c05bd3a
      Rich Felker 提交于
      note that POSIX does not specify these functions as _Noreturn, because
      POSIX is aligned with C99, not the new C11 standard. when POSIX is
      eventually updated to C11, it will almost surely give these functions
      the _Noreturn attribute. for now, the actual _Noreturn keyword is not
      used anyway when compiling with a c99 compiler, which is what POSIX
      requires; the GCC __attribute__ is used instead if it's available,
      however.
      
      in a few places, I've added infinite for loops at the end of _Noreturn
      functions to silence compiler warnings. presumably
      __buildin_unreachable could achieve the same thing, but it would only
      work on newer GCCs and would not be portable. the loops should have
      near-zero code size cost anyway.
      
      like the previous _Noreturn commit, this one is based on patches
      contributed by philomath.
      0c05bd3a
    • R
      use restrict everywhere it's required by c99 and/or posix 2008 · 400c5e5c
      Rich Felker 提交于
      to deal with the fact that the public headers may be used with pre-c99
      compilers, __restrict is used in place of restrict, and defined
      appropriately for any supported compiler. we also avoid the form
      [restrict] since older versions of gcc rejected it due to a bug in the
      original c99 standard, and instead use the form *restrict.
      400c5e5c
    • R
      fcfba995
  26. 11 7月, 2012 1 次提交
    • R
      initial version of mips (o32) port, based on work by Richard Pennington (rdp) · 6315004f
      Rich Felker 提交于
      basically, this version of the code was obtained by starting with
      rdp's work from his ellcc source tree, adapting it to musl's build
      system and coding style, auditing the bits headers for discrepencies
      with kernel definitions or glibc/LSB ABI or large file issues, fixing
      up incompatibility with the old binutils from aboriginal linux, and
      adding some new special cases to deal with the oddities of sigaction
      and pipe syscall interfaces on mips.
      
      at present, minimal test programs work, but some interfaces are broken
      or missing. threaded programs probably will not link.
      6315004f
  27. 20 6月, 2012 3 次提交
  28. 25 5月, 2012 1 次提交
  29. 02 3月, 2012 1 次提交
  30. 26 9月, 2011 1 次提交
    • R
      cleanup various minor issues reported by nsz · fd142e5e
      Rich Felker 提交于
      the changes to syscall_ret are mostly no-ops in the generated code,
      just cleanup of type issues and removal of some implementation-defined
      behavior. the one exception is the change in the comparison value,
      which is fixed so that 0xf...f000 (which in principle could be a valid
      return value for mmap, although probably never in reality) is not
      treated as an error return.
      fd142e5e
  31. 22 9月, 2011 1 次提交