Back to index

glibc  2.9
lutimes.c
Go to the documentation of this file.
00001 /* Change access and/or modification date of file.  Do not follow symbolic
00002    links.
00003    Copyright (C) 2007 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <errno.h>
00022 #include <fcntl.h>
00023 #include <time.h>
00024 #include <sys/time.h>
00025 #include <sysdep.h>
00026 #include <kernel-features.h>
00027 
00028 
00029 int
00030 lutimes (const char *file, const struct timeval tvp[2])
00031 {
00032 #ifdef __NR_utimensat
00033   /* The system call espects timespec, not timeval.  */
00034   struct timespec ts[2];
00035   if (tvp != NULL)
00036     {
00037       if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
00038           || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
00039        {
00040          __set_errno (EINVAL);
00041          return -1;
00042        }
00043 
00044       TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]);
00045       TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
00046     }
00047 
00048   return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tvp ? ts : NULL,
00049                       AT_SYMLINK_NOFOLLOW);
00050 #else
00051   __set_errno (ENOSYS);
00052   return -1;
00053 #endif
00054 }
00055 
00056 #ifndef __NR_utimensat
00057 stub_warning (lutimes)
00058 # include <stub-tag.h>
00059 #endif