minix/servers/mfs/time.c
Thomas Veerman ab19ece134 Define protocol version of {mode,ino,uid,gid}_t
Change-Id: Ia2027749f2ce55a561d19eb895a5618505e9a2ac
2014-02-18 11:25:01 +01:00

72 lines
1.7 KiB
C

#include "fs.h"
#include "inode.h"
#include <sys/stat.h>
#include <minix/vfsif.h>
/*===========================================================================*
* fs_utime *
*===========================================================================*/
int fs_utime()
{
register struct inode *rip;
register int r;
/* Temporarily open the file. */
if( (rip = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL);
/*
* Only the owner of a file or the super_user can change the timestamps.
* Here we assume VFS did that check before.
*/
r = OK;
if(read_only(rip) != OK) r = EROFS; /* not even su can touch if R/O */
if(r == OK) {
rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */
switch(fs_m_in.REQ_ACNSEC) {
case UTIME_NOW:
rip->i_update |= ATIME;
break;
case UTIME_OMIT: /* do not touch */
break;
default:
/*
* cases fs_m_in.REQ_ACNSEC < 0 || fs_m_in.REQ_ACNSEC >= 1E9
* are caught by VFS to cooperate with old instances of MFS
*/
rip->i_atime = fs_m_in.REQ_ACTIME;
/*
* MFS does not support better than second resolution,
* so we discard REQ_ACNSEC to round down
*/
break;
}
switch(fs_m_in.REQ_MODNSEC) {
case UTIME_NOW:
rip->i_update |= MTIME;
break;
case UTIME_OMIT: /* do not touch */
break;
default:
/*
* cases fs_m_in.REQ_MODNSEC < 0 || fs_m_in.REQ_MODNSEC >= 1E9
* are caught by VFS to cooperate with old instances of MFS
*/
rip->i_mtime = fs_m_in.REQ_MODTIME;
/*
* MFS does not support better than second resolution,
* so we discard REQ_MODNSEC to round down
*/
break;
}
IN_MARKDIRTY(rip);
}
put_inode(rip);
return(r);
}