utimes.c 736 B

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