minix/servers/vfs/time.c

77 lines
1.8 KiB
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
/* This file takes care of those system calls that deal with time.
*
* The entry points into this file are
* do_utime: perform the UTIME system call
* do_stime: PM informs FS about STIME system call
2005-04-21 16:53:53 +02:00
*/
#include "fs.h"
#include <minix/callnr.h>
#include <minix/com.h>
#include "file.h"
#include "fproc.h"
#include "param.h"
2007-08-07 14:52:47 +02:00
#include "vnode.h"
2005-04-21 16:53:53 +02:00
#include <minix/vfsif.h>
#include "vmnt.h"
2005-04-21 16:53:53 +02:00
/*===========================================================================*
* do_utime *
*===========================================================================*/
PUBLIC int do_utime()
{
/* Perform the utime(name, timep) system call. */
register int len;
int r;
2007-08-07 14:52:47 +02:00
uid_t uid;
time_t actime, modtime;
struct vnode *vp;
2005-04-21 16:53:53 +02:00
/* Adjust for case of 'timep' being NULL;
* utime_strlen then holds the actual size: strlen(name)+1.
*/
len = m_in.utime_length;
if (len == 0) len = m_in.utime_strlen;
if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code);
/* Request lookup */
2007-08-07 14:52:47 +02:00
if ((r = lookup_vp(0 /*flags*/, 0 /*!use_realuid*/, &vp)) != OK) return r;
2005-04-21 16:53:53 +02:00
/* Fill in request fields.*/
if (m_in.utime_length == 0) {
2007-08-07 14:52:47 +02:00
actime = modtime = clock_time();
} else {
2007-08-07 14:52:47 +02:00
actime = m_in.utime_actime;
modtime = m_in.utime_modtime;
2005-04-21 16:53:53 +02:00
}
2007-08-07 14:52:47 +02:00
uid= fp->fp_effuid;
2007-08-07 14:52:47 +02:00
r= OK;
if (vp->v_uid != uid && uid != SU_UID) r = EPERM;
if (m_in.utime_length == 0 && r != OK)
{
/* With a null times pointer, updating the times (to the current time)
* is allow if the object is writable.
*/
r = forbidden(vp, W_BIT, 0 /*!use_realuid*/);
}
Various VFS and MFS fixes to improve correctness, consistency and POSIX compliance. VFS changes: * truncate() on a file system mounted read-only no longer panics MFS. * ftruncate() and fcntl(F_FREESP) now check for write permission on the file descriptor instead of the file, write(). * utime(), chown() and fchown() now check for file system read-only status. MFS changes: * link() and rename() no longer return the internal EENTERMOUNT and ELEAVEMOUNT errors to the application as part of a check on the source path. * rename() now treats EENTERMOUNT from the destination path check as an error, preventing file system corruption from renaming a normal directory to an existing mountpoint directory. * mountpoints (mounted-on dirs) are hidden better during lookups: - if a lookup starts from a mountpoint, the first component has to be ".." (anything else being a VFS-FS protocol violation). - in that case, the permissions of the mountpoint are not checked. - in all other cases, visiting a mountpoint always results in EENTERMOUNT. * a lookup on ".." from a mount root or chroot(2) root no longer succeeds if the caller does not have search permission on that directory. * POSIX: getdents() now updates directory access times. * POSIX: readlink() now returns partial results instead of ERANGE. Miscellaneous changes: * semaphore file handling bug (leading to hangs) fixed in test 32. The VFS changes should now put the burden of checking for read-only status of file systems entirely on VFS, and limit the access permission checks that file systems have to perform, to checking search permission on directories during lookups. From this point on, any deviation from that spceification should be considered a bug. Note that for legacy reasons, the root partition is assumed to be mounted read-write.
2009-05-18 13:27:12 +02:00
if (r == OK)
r = read_only(vp);
2007-08-07 14:52:47 +02:00
if (r != OK)
{
put_vnode(vp);
return r;
}
/* Issue request */
r= req_utime(vp->v_fs_e, vp->v_inode_nr, actime, modtime);
put_vnode(vp);
return r;
2005-04-21 16:53:53 +02:00
}