utimes.c 662 B

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