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
8 #include <minix/callnr.h>
15 #include <minix/vfsif.h>
18 /*===========================================================================*
20 *===========================================================================*/
23 /* Perform the utime(name, timep) system call. */
25 time_t actime
, modtime
, newactime
, newmodtime
;
28 char fullpath
[PATH_MAX
];
29 struct lookup resolve
;
31 size_t vname_length
, len
;
33 vname
= (vir_bytes
) job_m_in
.utime_file
;
34 vname_length
= (size_t) job_m_in
.utime_length
;
35 actime
= job_m_in
.utime_actime
;
36 modtime
= job_m_in
.utime_modtime
;
38 /* Adjust for case of 'timep' being NULL;
39 * utime_strlen then holds the actual size: strlen(name)+1 */
41 if (len
== 0) len
= (size_t) job_m_in
.utime_strlen
;
43 lookup_init(&resolve
, fullpath
, PATH_NOFLAGS
, &vmp
, &vp
);
44 resolve
.l_vmnt_lock
= VMNT_WRITE
;
45 resolve
.l_vnode_lock
= VNODE_READ
;
47 /* Temporarily open the file */
48 if (fetch_name(vname
, len
, fullpath
) != OK
) return(err_code
);
49 if ((vp
= eat_path(&resolve
, fp
)) == NULL
) return(err_code
);
51 /* Only the owner of a file or the super user can change its name. */
53 if (vp
->v_uid
!= fp
->fp_effuid
&& fp
->fp_effuid
!= SU_UID
) r
= EPERM
;
54 if (vname_length
== 0 && r
!= OK
) r
= forbidden(fp
, vp
, W_BIT
);
55 if (read_only(vp
) != OK
) r
= EROFS
; /* Not even su can touch if R/O */
58 if (vname_length
== 0) {
59 newactime
= newmodtime
= clock_time();
64 r
= req_utime(vp
->v_fs_e
, vp
->v_inode_nr
, newactime
, newmodtime
);