utime.c 817 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * utime() 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. #ifdef __NR_utime
  12. _syscall2(int, utime, const char *, file, const struct utimbuf *, times)
  13. #else
  14. #include <stdlib.h>
  15. #include <sys/time.h>
  16. int utime(const char *file, const struct utimbuf *times)
  17. {
  18. struct timeval timevals[2];
  19. if (times != NULL) {
  20. timevals[0].tv_usec = 0L;
  21. timevals[1].tv_usec = 0L;
  22. timevals[0].tv_sec = (long int) times->actime;
  23. timevals[1].tv_sec = (long int) times->modtime;
  24. }
  25. return utimes(file, times ? timevals : NULL);
  26. }
  27. #endif
  28. link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use `utimes'")
  29. libc_hidden_def(utime)