staticint do_utimes_fd(int fd, struct timespec64 *times, int flags)
{ if (flags) return -EINVAL;
CLASS(fd, f)(fd); if (fd_empty(f)) return -EBADF; return vfs_utimes(&fd_file(f)->f_path, times);
}
/* * do_utimes - change times on filename or file descriptor * @dfd: open file descriptor, -1 or AT_FDCWD * @filename: path name or NULL * @times: new times or NULL * @flags: zero or more flags (only AT_SYMLINK_NOFOLLOW for the moment) * * If filename is NULL and dfd refers to an open file, then operate on * the file. Otherwise look up filename, possibly using dfd as a * starting point. * * If times==NULL, set access and modification to current time, * must be owner or have write permission. * Else, update from *times, must be owner or super user.
*/ long do_utimes(int dfd, constchar __user *filename, struct timespec64 *times, int flags)
{ if (filename == NULL && dfd != AT_FDCWD) return do_utimes_fd(dfd, times, flags); return do_utimes_path(dfd, filename, times, flags);
}
#ifdef __ARCH_WANT_SYS_UTIME /* * futimesat(), utimes() and utime() are older versions of utimensat() * that are provided for compatibility with traditional C libraries. * On modern architectures, we always use libc wrappers around * utimensat() instead.
*/ staticlong do_futimesat(int dfd, constchar __user *filename, struct __kernel_old_timeval __user *utimes)
{ struct __kernel_old_timeval times[2]; struct timespec64 tstimes[2];
if (utimes) { if (copy_from_user(×, utimes, sizeof(times))) return -EFAULT;
/* This test is needed to catch all invalid values. If we would test only in do_utimes we would miss those invalid values truncated by the multiplication with 1000. Note that we also catch UTIME_{NOW,OMIT} here which are only
valid for utimensat. */ if (times[0].tv_usec >= 1000000 || times[0].tv_usec < 0 ||
times[1].tv_usec >= 1000000 || times[1].tv_usec < 0) return -EINVAL;
if (times) { if (get_user(tv[0].tv_sec, ×->actime) ||
get_user(tv[1].tv_sec, ×->modtime)) return -EFAULT;
tv[0].tv_nsec = 0;
tv[1].tv_nsec = 0;
} return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0);
} #endif
#ifdef CONFIG_COMPAT_32BIT_TIME /* * Not all architectures have sys_utime, so implement this in terms * of sys_utimes.
*/ #ifdef __ARCH_WANT_SYS_UTIME32
SYSCALL_DEFINE2(utime32, constchar __user *, filename, struct old_utimbuf32 __user *, t)
{ struct timespec64 tv[2];
if (t) { if (get_user(tv[0].tv_sec, &t->actime) ||
get_user(tv[1].tv_sec, &t->modtime)) return -EFAULT;
tv[0].tv_nsec = 0;
tv[1].tv_nsec = 0;
} return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.