add swifi to the build/install.
[minix.git] / servers / vfs / time.c
blob3415ec689063509bf8eee11142bce9dee667a73a
1 /* This file takes care of those system calls that deal with time.
3 * The entry points into this file are
4 * do_utime: perform the UTIME system call
5 */
7 #include "fs.h"
8 #include <minix/callnr.h>
9 #include <minix/com.h>
10 #include "file.h"
11 #include "fproc.h"
12 #include "param.h"
13 #include "vnode.h"
14 #include <minix/vfsif.h>
15 #include "vmnt.h"
17 /*===========================================================================*
18 * do_utime *
19 *===========================================================================*/
20 PUBLIC int do_utime()
22 /* Perform the utime(name, timep) system call. */
23 register int len;
24 int r;
25 uid_t uid;
26 time_t actime, modtime;
27 struct vnode *vp;
29 /* Adjust for case of 'timep' being NULL;
30 * utime_strlen then holds the actual size: strlen(name)+1 */
31 len = m_in.utime_length;
32 if(len == 0) len = m_in.utime_strlen;
34 /* Temporarily open the file */
35 if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code);
36 if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code);
38 /* Only the owner of a file or the super user can change its name. */
39 r = OK;
40 if (vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) r = EPERM;
41 if (m_in.utime_length == 0 && r != OK) r = forbidden(vp, W_BIT);
42 if (read_only(vp) != OK) r = EROFS; /* Not even su can touch if R/O */
43 if (r == OK) {
44 /* Issue request */
45 if(m_in.utime_length == 0) {
46 actime = modtime = clock_time();
47 } else {
48 actime = m_in.utime_actime;
49 modtime = m_in.utime_modtime;
51 r = req_utime(vp->v_fs_e, vp->v_inode_nr, actime, modtime);
54 put_vnode(vp);
55 return(r);