2006-10-25 15:40:36 +02:00
|
|
|
/* This file contains the code for performing four system calls relating to
|
|
|
|
* status and directories.
|
|
|
|
*
|
|
|
|
* The entry points into this file are
|
|
|
|
* do_chdir: perform the CHDIR system call
|
|
|
|
* do_chroot: perform the CHROOT system call
|
- 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
|
|
|
* do_lstat: perform the LSTAT system call
|
2006-10-25 15:40:36 +02:00
|
|
|
* do_stat: perform the STAT system call
|
|
|
|
* do_fstat: perform the FSTAT system call
|
|
|
|
* do_fstatfs: perform the FSTATFS system call
|
2010-06-24 01:53:50 +02:00
|
|
|
* do_statvfs: perform the STATVFS system call
|
|
|
|
* do_fstatvfs: perform the FSTATVFS system call
|
2006-10-25 15:40:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statfs.h>
|
|
|
|
#include <minix/com.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/u64.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "file.h"
|
|
|
|
#include "fproc.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "path.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "param.h"
|
|
|
|
#include <minix/vfsif.h>
|
2011-07-01 21:35:54 +02:00
|
|
|
#include <minix/callnr.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "vnode.h"
|
|
|
|
#include "vmnt.h"
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int change_into(struct vnode **iip, struct vnode *vp);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_fchdir *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_fchdir()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Change directory on already-opened fd. */
|
|
|
|
struct filp *rfilp;
|
2012-04-13 14:50:38 +02:00
|
|
|
int r, rfd;
|
|
|
|
|
|
|
|
rfd = job_m_in.fd;
|
2009-04-29 18:59:18 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Is the file descriptor valid? */
|
2012-04-13 14:50:38 +02:00
|
|
|
if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
r = change_into(&fp->fp_wd, rfilp->filp_vno);
|
|
|
|
unlock_filp(rfilp);
|
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_chdir *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_chdir()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Perform the chdir(name) system call.
|
|
|
|
* syscall might provide 'name' embedded in the message.
|
|
|
|
*/
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
int r;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
vname = (vir_bytes) job_m_in.name;
|
|
|
|
vname_length = (size_t) job_m_in.name_length;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (copy_name(vname_length, fullpath) != OK) {
|
|
|
|
/* Direct copy failed, try fetching from user space */
|
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK)
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to open the directory */
|
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
|
|
|
|
|
|
|
r = change_into(&fp->fp_wd, vp);
|
|
|
|
|
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(vp);
|
|
|
|
|
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2012-04-13 14:50:38 +02:00
|
|
|
* do_chroot *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2012-04-13 14:50:38 +02:00
|
|
|
int do_chroot()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Perform the chroot(name) system call.
|
|
|
|
* syscall might provide 'name' embedded in the message.
|
|
|
|
*/
|
|
|
|
int r;
|
2007-01-05 17:36:55 +01:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length;
|
|
|
|
|
|
|
|
vname = (vir_bytes) job_m_in.name;
|
|
|
|
vname_length = (size_t) job_m_in.name_length;
|
|
|
|
|
|
|
|
if (!super_user) return(EPERM); /* only su may chroot() */
|
|
|
|
|
|
|
|
if (copy_name(vname_length, fullpath) != OK) {
|
|
|
|
/* Direct copy failed, try fetching from user space */
|
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK)
|
|
|
|
return(err_code);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Try to open the directory */
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2012-04-13 14:50:38 +02:00
|
|
|
|
|
|
|
r = change_into(&fp->fp_rd, vp);
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(vp);
|
2012-04-13 14:50:38 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* change_into *
|
|
|
|
*===========================================================================*/
|
2012-04-13 14:50:38 +02:00
|
|
|
static int change_into(struct vnode **result, struct vnode *vp)
|
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
|
|
|
int r;
|
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (*result == vp) return(OK); /* Nothing to do */
|
2012-02-13 16:28:04 +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
|
|
|
/* It must be a directory and also be searchable */
|
2012-04-25 14:44:42 +02:00
|
|
|
if (!S_ISDIR(vp->v_mode))
|
2012-02-13 16:28:04 +01:00
|
|
|
r = ENOTDIR;
|
- 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
|
|
|
else
|
2012-01-27 17:06:43 +01:00
|
|
|
r = forbidden(fp, vp, X_BIT); /* Check if dir is searchable*/
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) 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
|
|
|
/* Everything is OK. Make the change. */
|
2012-04-13 14:50:38 +02:00
|
|
|
put_vnode(*result); /* release the old directory */
|
2012-02-13 16:28:04 +01:00
|
|
|
dup_vnode(vp);
|
2012-04-13 14:50:38 +02:00
|
|
|
*result = vp; /* acquire the new one */
|
2006-10-25 15:40:36 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_stat *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_stat()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the stat(name, buf) system call. */
|
|
|
|
int r;
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2011-07-01 21:35:54 +02:00
|
|
|
int old_stat = 0;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, statbuf;
|
|
|
|
size_t vname1_length;
|
|
|
|
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = (size_t) job_m_in.name1_length;
|
|
|
|
statbuf = (vir_bytes) job_m_in.m1_p2;
|
2011-07-01 21:35:54 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (job_call_nr == PREV_STAT)
|
2011-07-01 21:35:54 +02:00
|
|
|
old_stat = 1;
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2012-04-18 15:44:33 +02:00
|
|
|
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf, old_stat);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
|
|
|
return r;
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_fstat *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_fstat()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the fstat(fd, buf) system call. */
|
|
|
|
register struct filp *rfilp;
|
2012-04-18 15:44:33 +02:00
|
|
|
int r, old_stat = 0, rfd;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes statbuf;
|
|
|
|
|
|
|
|
statbuf = (vir_bytes) job_m_in.buffer;
|
|
|
|
rfd = job_m_in.fd;
|
2011-07-01 21:35:54 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (job_call_nr == PREV_FSTAT)
|
2011-07-01 21:35:54 +02:00
|
|
|
old_stat = 1;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* Is the file descriptor valid? */
|
2012-04-13 14:50:38 +02:00
|
|
|
if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
r = req_stat(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr,
|
2012-04-18 15:44:33 +02:00
|
|
|
who_e, statbuf, old_stat);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_filp(rfilp);
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_fstatfs *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_fstatfs()
|
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
|
|
|
/* Perform the fstatfs(fd, buf) system call. */
|
|
|
|
struct filp *rfilp;
|
2012-04-13 14:50:38 +02:00
|
|
|
int r, rfd;
|
|
|
|
vir_bytes statbuf;
|
|
|
|
|
|
|
|
rfd = job_m_in.fd;
|
|
|
|
statbuf = (vir_bytes) job_m_in.buffer;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* Is the file descriptor valid? */
|
2012-04-13 14:50:38 +02:00
|
|
|
if( (rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
r = req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, statbuf);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_filp(rfilp);
|
|
|
|
|
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
2010-06-24 01:53:50 +02:00
|
|
|
/*===========================================================================*
|
2012-04-13 14:50:38 +02:00
|
|
|
* do_statvfs *
|
2010-06-24 01:53:50 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_statvfs()
|
2010-06-24 01:53:50 +02:00
|
|
|
{
|
|
|
|
/* Perform the stat(name, buf) system call. */
|
|
|
|
int r;
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, statbuf;
|
|
|
|
size_t vname1_length;
|
|
|
|
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = (size_t) job_m_in.name1_length;
|
|
|
|
statbuf = (vir_bytes) job_m_in.name2;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
2010-06-24 01:53:50 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2012-04-13 14:50:38 +02:00
|
|
|
r = req_statvfs(vp->v_fs_e, who_e, statbuf);
|
2010-06-24 01:53:50 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
|
2010-06-24 01:53:50 +02:00
|
|
|
put_vnode(vp);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_fstatvfs *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_fstatvfs()
|
2010-06-24 01:53:50 +02:00
|
|
|
{
|
|
|
|
/* Perform the fstat(fd, buf) system call. */
|
|
|
|
register struct filp *rfilp;
|
2012-04-13 14:50:38 +02:00
|
|
|
int r, rfd;
|
|
|
|
vir_bytes statbuf;
|
2010-06-24 01:53:50 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
rfd = job_m_in.fd;
|
|
|
|
statbuf = (vir_bytes) job_m_in.name2;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Is the file descriptor valid? */
|
|
|
|
if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
|
|
|
|
r = req_statvfs(rfilp->filp_vno->v_fs_e, who_e, statbuf);
|
2010-06-24 01:53:50 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_filp(rfilp);
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
2007-08-07 14:52:47 +02:00
|
|
|
* do_lstat *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_lstat()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the lstat(name, buf) system call. */
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
2006-10-25 15:40:36 +02:00
|
|
|
int r;
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2011-07-01 21:35:54 +02:00
|
|
|
int old_stat = 0;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, statbuf;
|
|
|
|
size_t vname1_length;
|
|
|
|
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = (size_t) job_m_in.name1_length;
|
|
|
|
statbuf = (vir_bytes) job_m_in.name2;
|
2011-07-01 21:35:54 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (job_call_nr == PREV_LSTAT)
|
2011-07-01 21:35:54 +02:00
|
|
|
old_stat = 1;
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2012-04-18 15:44:33 +02:00
|
|
|
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf, old_stat);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
- 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
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|