utime.c 838 B

12345678910111213141516171819202122232425262728293031323334
  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. # define __need_NULL
  15. # include <stddef.h>
  16. # include <sys/time.h>
  17. int utime(const char *file, const struct utimbuf *times)
  18. {
  19. struct timeval timevals[2];
  20. if (times != NULL) {
  21. timevals[0].tv_usec = 0L;
  22. timevals[1].tv_usec = 0L;
  23. timevals[0].tv_sec = (long int) times->actime;
  24. timevals[1].tv_sec = (long int) times->modtime;
  25. }
  26. return utimes(file, times ? timevals : NULL);
  27. }
  28. #endif
  29. link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use `utimes'")
  30. libc_hidden_def(utime)