source: trunk/minix/servers/fs/time.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.9 KB
Line 
1/* This file takes care of those system calls that deal with time.
2 *
3 * The entry points into this file are
4 * do_utime: perform the UTIME system call
5 * do_stime: PM informs FS about STIME system call
6 */
7
8#include "fs.h"
9#include <minix/callnr.h>
10#include <minix/com.h>
11#include "file.h"
12#include "fproc.h"
13#include "inode.h"
14#include "param.h"
15
16/*===========================================================================*
17 * do_utime *
18 *===========================================================================*/
19PUBLIC int do_utime()
20{
21/* Perform the utime(name, timep) system call. */
22
23 register struct inode *rip;
24 register int len, r;
25
26 /* Adjust for case of 'timep' being NULL;
27 * utime_strlen then holds the actual size: strlen(name)+1.
28 */
29 len = m_in.utime_length;
30 if (len == 0) len = m_in.utime_strlen;
31
32 /* Temporarily open the file. */
33 if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code);
34 if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
35
36 /* Only the owner of a file or the super_user can change its time. */
37 r = OK;
38 if (rip->i_uid != fp->fp_effuid && !super_user) r = EPERM;
39 if (m_in.utime_length == 0 && r != OK) r = forbidden(rip, W_BIT);
40 if (read_only(rip) != OK) r = EROFS; /* not even su can touch if R/O */
41 if (r == OK) {
42 if (m_in.utime_length == 0) {
43 rip->i_atime = clock_time();
44 rip->i_mtime = rip->i_atime;
45 } else {
46 rip->i_atime = m_in.utime_actime;
47 rip->i_mtime = m_in.utime_modtime;
48 }
49 rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */
50 rip->i_dirt = DIRTY;
51 }
52
53 put_inode(rip);
54 return(r);
55}
56
57/*===========================================================================*
58 * do_stime *
59 *===========================================================================*/
60PUBLIC int do_stime()
61{
62/* Perform the stime(tp) system call. */
63 boottime = (long) m_in.pm_stime;
64 return(OK);
65}
66
Note: See TracBrowser for help on using the repository browser.