utime.c 911 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * utime() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  8. */
  9. #define utimes __utimes
  10. #include "syscalls.h"
  11. #include <utime.h>
  12. #ifdef __NR_utime
  13. #define __NR___utime __NR_utime
  14. attribute_hidden _syscall2(int, __utime, const char *, file, const struct utimbuf *, times);
  15. #else
  16. #include <stdlib.h>
  17. #include <sys/time.h>
  18. int attribute_hidden __utime(const char *file, const struct utimbuf *times)
  19. {
  20. struct timeval timevals[2];
  21. if (times != NULL) {
  22. timevals[0].tv_usec = 0L;
  23. timevals[1].tv_usec = 0L;
  24. timevals[0].tv_sec = (long int) times->actime;
  25. timevals[1].tv_sec = (long int) times->modtime;
  26. } else {
  27. if (gettimeofday(&timevals[0], NULL) < 0) {
  28. return -1;
  29. }
  30. timevals[1] = timevals[0];
  31. }
  32. return utimes(file, timevals);
  33. }
  34. #endif
  35. strong_alias(__utime,utime)