utime.c 927 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * utime() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #include <utime.h>
  11. #ifdef __NR_utime
  12. _syscall2(int, utime, const char *, file, const struct utimbuf *, times)
  13. #elif defined __NR_utimes /* alpha || ia64 */
  14. # define __need_NULL
  15. # include <stddef.h>
  16. # include <sys/time.h>
  17. int utime(const char *file, const struct utimbuf *times)
  18. {
  19. struct timeval timevals[2];
  20. if (times != NULL) {
  21. timevals[0].tv_usec = 0L;
  22. timevals[1].tv_usec = 0L;
  23. timevals[0].tv_sec = (time_t) times->actime;
  24. timevals[1].tv_sec = (time_t) times->modtime;
  25. }
  26. return utimes(file, times ? timevals : NULL);
  27. }
  28. #endif
  29. #if defined __NR_utime || defined __NR_utimes
  30. link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use `utimes'")
  31. libc_hidden_def(utime)
  32. #endif