utimes.c 683 B

12345678910111213141516171819202122232425262728293031323334
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * utimes() 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 <sys/time.h>
  11. #ifdef __NR_utimes
  12. _syscall2(int, utimes, const char *, file, const struct timeval *, tvp)
  13. #else
  14. # define __need_NULL
  15. # include <stddef.h>
  16. # include <utime.h>
  17. int utimes(const char *file, const struct timeval tvp[2])
  18. {
  19. struct utimbuf buf, *times;
  20. if (tvp) {
  21. times = &buf;
  22. times->actime = tvp[0].tv_sec;
  23. times->modtime = tvp[1].tv_sec;
  24. } else {
  25. times = NULL;
  26. }
  27. return utime(file, times);
  28. }
  29. #endif
  30. libc_hidden_def(utimes)