xref: /minix3/minix/fs/mfs/time.c (revision ccaeedb267288a9eea9fd8cd1c553aa98bdef60d)
1 #include "fs.h"
2 #include "inode.h"
3 #include <sys/time.h>
4 #include <sys/stat.h>
5 
6 
7 /*===========================================================================*
8  *				fs_utime				     *
9  *===========================================================================*/
fs_utime(ino_t ino_nr,struct timespec * atime,struct timespec * mtime)10 int fs_utime(ino_t ino_nr, struct timespec *atime, struct timespec *mtime)
11 {
12   register struct inode *rip;
13 
14   /* Temporarily open the file. */
15   if( (rip = get_inode(fs_dev, ino_nr)) == NULL)
16         return(EINVAL);
17 
18   rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */
19 
20   switch (atime->tv_nsec) {
21   case UTIME_NOW:
22 	rip->i_update |= ATIME;
23 	break;
24   case UTIME_OMIT: /* do not touch */
25 	break;
26   default:
27 	/* MFS does not support subsecond resolution, so we round down. */
28 	rip->i_atime = atime->tv_sec;
29 	break;
30   }
31 
32   switch (mtime->tv_nsec) {
33   case UTIME_NOW:
34 	rip->i_update |= MTIME;
35 	break;
36   case UTIME_OMIT: /* do not touch */
37 	break;
38   default:
39 	/* MFS does not support subsecond resolution, so we round down. */
40 	rip->i_mtime = mtime->tv_sec;
41 	break;
42   }
43 
44   IN_MARKDIRTY(rip);
45 
46   put_inode(rip);
47   return(OK);
48 }
49 
50