2006-10-25 15:40:36 +02:00
|
|
|
#include "fs.h"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statfs.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "buf.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include "super.h"
|
|
|
|
#include <minix/vfsif.h>
|
|
|
|
|
- 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
|
|
|
FORWARD _PROTOTYPE( int stat_inode, (struct inode *rip, int who_e,
|
|
|
|
cp_grant_id_t gid) );
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* stat_inode *
|
|
|
|
*===========================================================================*/
|
- 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
|
|
|
PRIVATE int stat_inode(rip, who_e, gid)
|
2006-10-25 15:40:36 +02:00
|
|
|
register struct inode *rip; /* pointer to inode to stat */
|
2007-01-05 17:36:55 +01:00
|
|
|
int who_e; /* Caller endpoint */
|
|
|
|
cp_grant_id_t gid; /* grant for the stat buf */
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Common code for stat and fstat system calls. */
|
|
|
|
|
|
|
|
struct stat statbuf;
|
|
|
|
mode_t mo;
|
|
|
|
int r, s;
|
|
|
|
|
|
|
|
/* Update the atime, ctime, and mtime fields in the inode, if need be. */
|
|
|
|
if (rip->i_update) update_times(rip);
|
|
|
|
|
|
|
|
/* Fill in the statbuf struct. */
|
|
|
|
mo = rip->i_mode & I_TYPE;
|
|
|
|
|
|
|
|
/* true iff special */
|
|
|
|
s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL);
|
|
|
|
|
|
|
|
statbuf.st_dev = rip->i_dev;
|
|
|
|
statbuf.st_ino = rip->i_num;
|
|
|
|
statbuf.st_mode = rip->i_mode;
|
|
|
|
statbuf.st_nlink = rip->i_nlinks;
|
|
|
|
statbuf.st_uid = rip->i_uid;
|
|
|
|
statbuf.st_gid = rip->i_gid;
|
|
|
|
statbuf.st_rdev = (dev_t) (s ? rip->i_zone[0] : NO_DEV);
|
|
|
|
statbuf.st_size = rip->i_size;
|
|
|
|
statbuf.st_atime = rip->i_atime;
|
|
|
|
statbuf.st_mtime = rip->i_mtime;
|
|
|
|
statbuf.st_ctime = rip->i_ctime;
|
|
|
|
|
|
|
|
/* Copy the struct to user space. */
|
2007-01-05 17:36:55 +01:00
|
|
|
r = sys_safecopyto(who_e, gid, 0, (vir_bytes) &statbuf,
|
|
|
|
(phys_bytes) sizeof(statbuf), D);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_fstatfs *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int fs_fstatfs()
|
|
|
|
{
|
|
|
|
struct statfs st;
|
|
|
|
struct inode *rip;
|
|
|
|
int r;
|
2007-01-05 17:36:55 +01:00
|
|
|
|
- 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((rip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE)
|
|
|
|
return(EINVAL);
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
st.f_bsize = rip->i_sp->s_block_size;
|
|
|
|
|
|
|
|
/* Copy the struct to user space. */
|
- 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
|
|
|
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0, (vir_bytes) &st,
|
|
|
|
(phys_bytes) sizeof(st), D);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
- 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
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
2007-01-05 17:36:55 +01:00
|
|
|
* fs_stat *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2007-01-05 17:36:55 +01:00
|
|
|
PUBLIC int fs_stat()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
register int r; /* return value */
|
|
|
|
register struct inode *rip; /* target inode */
|
|
|
|
|
- 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 ((rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE)
|
|
|
|
return(EINVAL);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
- 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
|
|
|
r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT);
|
2006-10-25 15:40:36 +02:00
|
|
|
put_inode(rip); /* release the inode */
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|