Merge of VFS by Balasz Gerofi with Minix trunk.
[minix3.git] / servers / mfs / time.c
blob32785d20cf78082b2d000809db963bc73539d4b1
4 #include "fs.h"
5 #include <minix/callnr.h>
6 #include <minix/com.h>
7 #include "inode.h"
9 #include <minix/vfsif.h>
12 /*===========================================================================*
13 * fs_utime *
14 *===========================================================================*/
15 PUBLIC int fs_utime()
17 register struct inode *rip;
18 register int r;
20 caller_uid = fs_m_in.REQ_UID;
21 caller_gid = fs_m_in.REQ_GID;
23 /* Temporarily open the file. */
24 if ( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) {
25 printf("MFS(%d) get_inode by fs_utime() failed\n", SELF_E);
26 return(EINVAL);
29 /* Only the owner of a file or the super_user can change its time. */
30 r = OK;
31 if (rip->i_uid != caller_uid && caller_uid != SU_UID) r = EPERM;
32 if (fs_m_in.REQ_ACTIME == 0 && r != OK) r = forbidden(rip, W_BIT);
33 if (read_only(rip) != OK) r = EROFS; /* not even su can touch if R/O */
34 if (r == OK) {
35 if (fs_m_in.REQ_ACTIME == 0) {
36 rip->i_atime = fs_m_in.REQ_MODTIME;
37 rip->i_mtime = rip->i_atime;
38 } else {
39 rip->i_atime = fs_m_in.REQ_ACTIME;
40 rip->i_mtime = fs_m_in.REQ_MODTIME;
42 rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */
43 rip->i_dirt = DIRTY;
46 put_inode(rip);
47 return(r);
50 PUBLIC int fs_stime()
52 boottime = fs_m_in.REQ_BOOTTIME;
53 printf("MFS(%d) boottime: %d\n", SELF_E, boottime);
54 return OK;