2006-10-25 15:40:36 +02:00
|
|
|
#include "fs.h"
|
|
|
|
#include "inode.h"
|
2011-12-21 23:29:29 +01:00
|
|
|
#include <sys/stat.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_utime *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_utime()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
register struct inode *rip;
|
|
|
|
register int r;
|
2011-12-21 23:29:29 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Temporarily open the file. */
|
2013-03-07 15:46:21 +01:00
|
|
|
if( (rip = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
|
2006-10-25 15:40:36 +02:00
|
|
|
return(EINVAL);
|
|
|
|
|
2011-12-21 23:29:29 +01:00
|
|
|
/*
|
|
|
|
* Only the owner of a file or the super_user can change the timestamps.
|
|
|
|
* Here we assume VFS did that check before.
|
|
|
|
*/
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
r = OK;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if(read_only(rip) != OK) r = EROFS; /* not even su can touch if R/O */
|
|
|
|
if(r == OK) {
|
2011-12-21 23:29:29 +01:00
|
|
|
rip->i_update = CTIME; /* discard any stale ATIME and MTIME flags */
|
|
|
|
switch(fs_m_in.REQ_ACNSEC) {
|
|
|
|
case UTIME_NOW:
|
|
|
|
rip->i_update |= ATIME;
|
|
|
|
break;
|
|
|
|
case UTIME_OMIT: /* do not touch */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* cases fs_m_in.REQ_ACNSEC < 0 || fs_m_in.REQ_ACNSEC >= 1E9
|
|
|
|
* are caught by VFS to cooperate with old instances of MFS
|
|
|
|
*/
|
|
|
|
rip->i_atime = fs_m_in.REQ_ACTIME;
|
|
|
|
/*
|
|
|
|
* MFS does not support better than second resolution,
|
|
|
|
* so we discard REQ_ACNSEC to round down
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(fs_m_in.REQ_MODNSEC) {
|
|
|
|
case UTIME_NOW:
|
|
|
|
rip->i_update |= MTIME;
|
|
|
|
break;
|
|
|
|
case UTIME_OMIT: /* do not touch */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* cases fs_m_in.REQ_MODNSEC < 0 || fs_m_in.REQ_MODNSEC >= 1E9
|
|
|
|
* are caught by VFS to cooperate with old instances of MFS
|
|
|
|
*/
|
|
|
|
rip->i_mtime = fs_m_in.REQ_MODTIME;
|
|
|
|
/*
|
|
|
|
* MFS does not support better than second resolution,
|
|
|
|
* so we discard REQ_MODNSEC to round down
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IN_MARKDIRTY(rip);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
put_inode(rip);
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|