1433d6423SLionel Sambuc #include "fs.h" 2433d6423SLionel Sambuc #include "inode.h" 3*ccaeedb2SDavid van Moolenbroek #include <sys/time.h> 4433d6423SLionel Sambuc #include <sys/stat.h> 5433d6423SLionel Sambuc 6433d6423SLionel Sambuc 7433d6423SLionel Sambuc /*===========================================================================* 8433d6423SLionel Sambuc * fs_utime * 9433d6423SLionel Sambuc *===========================================================================*/ fs_utime(ino_t ino_nr,struct timespec * atime,struct timespec * mtime)10*ccaeedb2SDavid van Moolenbroekint fs_utime(ino_t ino_nr, struct timespec *atime, struct timespec *mtime) 11433d6423SLionel Sambuc { 12433d6423SLionel Sambuc register struct inode *rip; 13433d6423SLionel Sambuc 14433d6423SLionel Sambuc /* Temporarily open the file. */ 15*ccaeedb2SDavid van Moolenbroek if( (rip = get_inode(fs_dev, ino_nr)) == NULL) 16433d6423SLionel Sambuc return(EINVAL); 17433d6423SLionel Sambuc 18433d6423SLionel Sambuc rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */ 19*ccaeedb2SDavid van Moolenbroek 20*ccaeedb2SDavid van Moolenbroek switch (atime->tv_nsec) { 21433d6423SLionel Sambuc case UTIME_NOW: 22433d6423SLionel Sambuc rip->i_update |= ATIME; 23433d6423SLionel Sambuc break; 24433d6423SLionel Sambuc case UTIME_OMIT: /* do not touch */ 25433d6423SLionel Sambuc break; 26433d6423SLionel Sambuc default: 27*ccaeedb2SDavid van Moolenbroek /* MFS does not support subsecond resolution, so we round down. */ 28*ccaeedb2SDavid van Moolenbroek rip->i_atime = atime->tv_sec; 29433d6423SLionel Sambuc break; 30433d6423SLionel Sambuc } 31433d6423SLionel Sambuc 32*ccaeedb2SDavid van Moolenbroek switch (mtime->tv_nsec) { 33433d6423SLionel Sambuc case UTIME_NOW: 34433d6423SLionel Sambuc rip->i_update |= MTIME; 35433d6423SLionel Sambuc break; 36433d6423SLionel Sambuc case UTIME_OMIT: /* do not touch */ 37433d6423SLionel Sambuc break; 38433d6423SLionel Sambuc default: 39*ccaeedb2SDavid van Moolenbroek /* MFS does not support subsecond resolution, so we round down. */ 40*ccaeedb2SDavid van Moolenbroek rip->i_mtime = mtime->tv_sec; 41433d6423SLionel Sambuc break; 42433d6423SLionel Sambuc } 43433d6423SLionel Sambuc 44433d6423SLionel Sambuc IN_MARKDIRTY(rip); 45433d6423SLionel Sambuc 46433d6423SLionel Sambuc put_inode(rip); 47*ccaeedb2SDavid van Moolenbroek return(OK); 48433d6423SLionel Sambuc } 49433d6423SLionel Sambuc 50