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