utime.c 818 B

12345678910111213141516171819202122232425262728293031323334353637
  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. libc_hidden_proto(utime)
  12. #ifdef __NR_utime
  13. _syscall2(int, utime, const char *, file, const struct utimbuf *, times);
  14. #else
  15. #include <stdlib.h>
  16. #include <sys/time.h>
  17. libc_hidden_proto(utimes)
  18. libc_hidden_proto(gettimeofday)
  19. int utime(const char *file, const struct utimbuf *times)
  20. {
  21. struct timeval timevals[2];
  22. if (times != NULL) {
  23. timevals[0].tv_usec = 0L;
  24. timevals[1].tv_usec = 0L;
  25. timevals[0].tv_sec = (long int) times->actime;
  26. timevals[1].tv_sec = (long int) times->modtime;
  27. }
  28. return utimes(file, times ? timevals : NULL);
  29. }
  30. #endif
  31. libc_hidden_def(utime)