utimes.c 755 B

123456789101112131415161718192021222324252627282930313233343536
  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. #elif defined __NR_utime
  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. #if defined __NR_utimes || defined __NR_utime
  31. libc_hidden_def(utimes)
  32. #endif