utimes.c 815 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. link_warning(utimes, "the use of LEGACY `utimes' is discouraged, use `utime'")
  33. libc_hidden_def(utimes)