2005-04-21 16:53:53 +02:00
|
|
|
/* This file deals with the suspension and revival of processes. A process can
|
|
|
|
* be suspended because it wants to read or write from a pipe and can't, or
|
|
|
|
* because it wants to read or write from a special file and can't. When a
|
|
|
|
* process can't continue it is suspended, and revived later when it is able
|
|
|
|
* to continue.
|
|
|
|
*
|
|
|
|
* The entry points into this file are
|
2013-11-04 22:48:08 +01:00
|
|
|
* do_pipe2: perform the PIPE2 system call
|
2005-04-21 16:53:53 +02:00
|
|
|
* pipe_check: check to see that a read or write on a pipe is feasible now
|
|
|
|
* suspend: suspend a process that cannot do a requested read or write
|
2005-08-29 18:47:18 +02:00
|
|
|
* release: check to see if a suspended process can be released and do
|
|
|
|
* it
|
2005-04-21 16:53:53 +02:00
|
|
|
* revive: mark a suspended process as able to run again
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
* unsuspend_by_endpt: revive all processes blocking on a given process
|
2005-04-21 16:53:53 +02:00
|
|
|
* do_unpause: a signal has been sent to a process; see if it suspended
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
2013-04-12 18:41:23 +02:00
|
|
|
#include <string.h>
|
2006-06-20 12:12:09 +02:00
|
|
|
#include <assert.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/callnr.h>
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
#include <minix/endpoint.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/com.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/u64.h>
|
2005-06-17 15:41:12 +02:00
|
|
|
#include <sys/select.h>
|
2005-06-27 13:59:36 +02:00
|
|
|
#include <sys/time.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "file.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "scratchpad.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
|
|
|
#include "vnode.h"
|
|
|
|
#include "vmnt.h"
|
|
|
|
|
2013-02-25 15:45:22 +01:00
|
|
|
static int create_pipe(int fil_des[2], int flags);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2013-02-25 15:45:22 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_pipe2 *
|
|
|
|
*===========================================================================*/
|
2013-10-29 23:15:15 +01:00
|
|
|
int do_pipe2(void)
|
2013-02-25 15:45:22 +01:00
|
|
|
{
|
|
|
|
/* Perform the pipe2(fil_des[2], flags) system call. */
|
|
|
|
int r, flags;
|
|
|
|
int fil_des[2]; /* reply goes here */
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
flags = job_m_in.VFS_PIPE2_FLAGS;
|
2013-02-25 15:45:22 +01:00
|
|
|
|
|
|
|
r = create_pipe(fil_des, flags);
|
|
|
|
if (r == OK) {
|
2013-11-04 22:48:08 +01:00
|
|
|
job_m_out.VFS_PIPE2_FD0 = fil_des[0];
|
|
|
|
job_m_out.VFS_PIPE2_FD1 = fil_des[1];
|
2013-02-25 15:45:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* create_pipe *
|
|
|
|
*===========================================================================*/
|
|
|
|
static int create_pipe(int fil_des[2], int flags)
|
|
|
|
{
|
2005-04-21 16:53:53 +02:00
|
|
|
register struct fproc *rfp;
|
|
|
|
int r;
|
|
|
|
struct filp *fil_ptr0, *fil_ptr1;
|
2006-10-25 15:40:36 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
2006-10-25 15:40:36 +02:00
|
|
|
struct node_details res;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Get a lock on PFS */
|
|
|
|
if ((vmp = find_vmnt(PFS_PROC_NR)) == NULL) panic("PFS gone");
|
VFS: fix locking bugs
.sync and fsync used unnecessarily restrictive locking type
.fsync violated locking order by obtaining a vmnt lock after a filp lock
.fsync contained a TOCTOU bug
.new_node violated locking rules (didn't upgrade lock upon file creation)
.do_pipe used unnecessarily restrictive locking type
.always lock pipes exclusively; even a read operation might require to do
a write on a vnode object (update pipe size)
.when opening a file with O_TRUNC, upgrade vnode lock when truncating
.utime used unnecessarily restrictive locking type
.path parsing:
.always acquire VMNT_WRITE or VMNT_EXCL on vmnt and downgrade to
VMNT_READ if that was what was actually requested. This prevents the
following deadlock scenario:
thread A:
lock_vmnt(vmp, TLL_READSER);
lock_vnode(vp, TLL_READSER);
upgrade_vmnt_lock(vmp, TLL_WRITE);
thread B:
lock_vmnt(vmp, TLL_READ);
lock_vnode(vp, TLL_READSER);
thread A will be stuck in upgrade_vmnt_lock and thread B is stuck in
lock_vnode. This happens when, for example, thread A tries create a
new node (open.c:new_node) and thread B tries to do eat_path to
change dir (stadir.c:do_chdir). When the path is being resolved, a
vnode is always locked with VNODE_OPCL (TLL_READSER) and then
downgraded to VNODE_READ if read-only is actually requested. Thread
A locks the vmnt with VMNT_WRITE (TLL_READSER) which still allows
VMNT_READ locks. Thread B can't acquire a lock on the vnode because
thread A has it; Thread A can't upgrade its vmnt lock to VMNT_WRITE
(TLL_WRITE) because thread B has a VMNT_READ lock on it.
By serializing vmnt locks during path parsing, thread B can only
acquire a lock on vmp when thread A has completely finished its
operation.
2012-11-30 13:49:53 +01:00
|
|
|
if ((r = lock_vmnt(vmp, VMNT_READ)) != OK) return(r);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* See if a free vnode is available */
|
2012-04-23 15:45:14 +02:00
|
|
|
if ((vp = get_free_vnode()) == NULL) {
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
return(err_code);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
lock_vnode(vp, VNODE_OPCL);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Acquire two file descriptors. */
|
|
|
|
rfp = fp;
|
2013-05-07 14:41:07 +02:00
|
|
|
if ((r = get_fd(fp, 0, R_BIT, &fil_des[0], &fil_ptr0)) != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
return(r);
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
rfp->fp_filp[fil_des[0]] = fil_ptr0;
|
2012-02-13 16:28:04 +01:00
|
|
|
fil_ptr0->filp_count = 1; /* mark filp in use */
|
2013-05-07 14:41:07 +02:00
|
|
|
if ((r = get_fd(fp, 0, W_BIT, &fil_des[1], &fil_ptr1)) != OK) {
|
2010-05-10 15:26:00 +02:00
|
|
|
rfp->fp_filp[fil_des[0]] = NULL;
|
2012-02-13 16:28:04 +01:00
|
|
|
fil_ptr0->filp_count = 0; /* mark filp free */
|
|
|
|
unlock_filp(fil_ptr0);
|
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
- 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);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
rfp->fp_filp[fil_des[1]] = fil_ptr1;
|
|
|
|
fil_ptr1->filp_count = 1;
|
|
|
|
|
- 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
|
|
|
/* Create a named pipe inode on PipeFS */
|
|
|
|
r = req_newnode(PFS_PROC_NR, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE,
|
2010-05-06 11:32:40 +02:00
|
|
|
NO_DEV, &res);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
if (r != OK) {
|
2010-05-10 15:26:00 +02:00
|
|
|
rfp->fp_filp[fil_des[0]] = NULL;
|
- 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
|
|
|
fil_ptr0->filp_count = 0;
|
2010-05-10 15:26:00 +02:00
|
|
|
rfp->fp_filp[fil_des[1]] = NULL;
|
- 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
|
|
|
fil_ptr1->filp_count = 0;
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_filp(fil_ptr1);
|
|
|
|
unlock_filp(fil_ptr0);
|
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
- 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
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in vnode */
|
|
|
|
vp->v_fs_e = res.fs_e;
|
- 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
|
|
|
vp->v_mapfs_e = res.fs_e;
|
2012-02-13 16:28:04 +01:00
|
|
|
vp->v_inode_nr = res.inode_nr;
|
|
|
|
vp->v_mapinode_nr = res.inode_nr;
|
2006-10-25 15:40:36 +02:00
|
|
|
vp->v_mode = res.fmode;
|
2007-08-07 14:52:47 +02:00
|
|
|
vp->v_fs_count = 1;
|
- 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
|
|
|
vp->v_mapfs_count = 1;
|
2007-08-07 14:52:47 +02:00
|
|
|
vp->v_ref_count = 1;
|
2006-10-25 15:40:36 +02:00
|
|
|
vp->v_size = 0;
|
2012-02-13 16:28:04 +01:00
|
|
|
vp->v_vmnt = NULL;
|
- 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
|
|
|
vp->v_dev = NO_DEV;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Fill in filp objects */
|
|
|
|
fil_ptr0->filp_vno = vp;
|
2007-08-07 14:52:47 +02:00
|
|
|
dup_vnode(vp);
|
2006-10-25 15:40:36 +02:00
|
|
|
fil_ptr1->filp_vno = vp;
|
2013-02-25 15:45:22 +01:00
|
|
|
fil_ptr0->filp_flags = O_RDONLY | (flags & ~O_ACCMODE);
|
|
|
|
fil_ptr1->filp_flags = O_WRONLY | (flags & ~O_ACCMODE);
|
|
|
|
if (flags & O_CLOEXEC) {
|
|
|
|
FD_SET(fil_des[0], &rfp->fp_cloexec_set);
|
|
|
|
FD_SET(fil_des[1], &rfp->fp_cloexec_set);
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_filps(fil_ptr0, fil_ptr1);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
return(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
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* map_vnode *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int map_vnode(vp, map_to_fs_e)
|
- 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
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
endpoint_t map_to_fs_e;
|
- 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-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
- 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
|
|
|
struct node_details res;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if(vp->v_mapfs_e != NONE) return(OK); /* Already mapped; nothing to do. */
|
|
|
|
|
|
|
|
if ((vmp = find_vmnt(map_to_fs_e)) == NULL)
|
|
|
|
panic("Can't map to unknown endpoint");
|
|
|
|
if ((r = lock_vmnt(vmp, VMNT_WRITE)) != OK) {
|
|
|
|
if (r == EBUSY)
|
|
|
|
vmp = NULL; /* Already locked, do not unlock */
|
|
|
|
else
|
|
|
|
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
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Create a temporary mapping of this inode to another FS. Read and write
|
|
|
|
* operations on data will be handled by that FS. The rest by the 'original'
|
- 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
|
|
|
* FS that holds the inode. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = req_newnode(map_to_fs_e, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE,
|
- 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
|
|
|
vp->v_dev, &res)) == OK) {
|
|
|
|
vp->v_mapfs_e = res.fs_e;
|
2012-02-13 16:28:04 +01:00
|
|
|
vp->v_mapinode_nr = res.inode_nr;
|
- 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
|
|
|
vp->v_mapfs_count = 1;
|
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vmp) unlock_vmnt(vmp);
|
|
|
|
|
- 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);
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* pipe_check *
|
|
|
|
*===========================================================================*/
|
2012-12-11 20:46:09 +01:00
|
|
|
int pipe_check(
|
2013-02-25 12:36:29 +01:00
|
|
|
struct filp *filp, /* the filp of the pipe */
|
2012-12-11 20:46:09 +01:00
|
|
|
int rw_flag, /* READING or WRITING */
|
|
|
|
int oflags, /* flags set by open or fcntl */
|
|
|
|
int bytes, /* bytes to be read or written (all chunks) */
|
|
|
|
int notouch /* check only */
|
|
|
|
)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Pipes are a little different. If a process reads from an empty pipe for
|
|
|
|
* which a writer still exists, suspend the reader. If the pipe is empty
|
|
|
|
* and there is no writer, return 0 bytes. If a process is writing to a
|
|
|
|
* pipe and no one is reading from it, give a broken pipe error.
|
|
|
|
*/
|
2013-02-25 12:36:29 +01:00
|
|
|
struct vnode *vp;
|
2006-11-27 15:21:43 +01:00
|
|
|
off_t pos;
|
- 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 = OK;
|
2006-11-27 15:21:43 +01:00
|
|
|
|
2013-02-25 12:36:29 +01:00
|
|
|
vp = filp->filp_vno;
|
|
|
|
|
2012-12-11 20:46:09 +01:00
|
|
|
/* Reads start at the beginning; writes append to pipes */
|
2013-01-25 18:42:36 +01:00
|
|
|
if (notouch) /* In this case we don't actually care whether data transfer
|
|
|
|
* would succeed. See POSIX 1003.1-2008 */
|
2012-12-11 20:46:09 +01:00
|
|
|
pos = 0;
|
2013-01-25 18:42:36 +01:00
|
|
|
else if (rw_flag == READING)
|
|
|
|
pos = 0;
|
|
|
|
else {
|
2012-12-11 20:46:09 +01:00
|
|
|
pos = vp->v_size;
|
2013-01-25 18:42:36 +01:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* If reading, check for empty pipe. */
|
|
|
|
if (rw_flag == READING) {
|
2012-12-11 20:46:09 +01:00
|
|
|
if (vp->v_size == 0) {
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Process is reading from an empty pipe. */
|
2010-05-10 15:26:00 +02:00
|
|
|
if (find_filp(vp, W_BIT) != NULL) {
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Writer exists */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (oflags & O_NONBLOCK)
|
2005-04-21 16:53:53 +02:00
|
|
|
r = EAGAIN;
|
2012-02-13 16:28:04 +01:00
|
|
|
else
|
2005-04-21 16:53:53 +02:00
|
|
|
r = SUSPEND;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* If need be, activate sleeping writers. */
|
2006-06-14 15:17:41 +02:00
|
|
|
if (susp_count > 0)
|
2013-11-04 22:48:08 +01:00
|
|
|
release(vp, VFS_WRITE, susp_count);
|
2005-04-21 16:53:53 +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
|
|
|
return(bytes);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Process is writing to a pipe. */
|
2010-05-10 15:26:00 +02:00
|
|
|
if (find_filp(vp, R_BIT) == NULL) {
|
2007-08-07 14:52:47 +02:00
|
|
|
return(EPIPE);
|
|
|
|
}
|
2005-04-21 16:53:53 +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
|
|
|
/* Calculate how many bytes can be written. */
|
2007-08-07 14:52:47 +02:00
|
|
|
if (pos + bytes > PIPE_BUF) {
|
- 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 (oflags & O_NONBLOCK) {
|
2007-08-07 14:52:47 +02:00
|
|
|
if (bytes <= PIPE_BUF) {
|
|
|
|
/* Write has to be atomic */
|
2005-04-21 16:53:53 +02:00
|
|
|
return(EAGAIN);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
/* Compute available 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
|
|
|
bytes = PIPE_BUF - pos;
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
if (bytes > 0) {
|
|
|
|
/* Do a partial write. Need to wakeup reader */
|
|
|
|
if (!notouch)
|
2013-11-04 22:48:08 +01:00
|
|
|
release(vp, VFS_READ, susp_count);
|
2007-08-07 14:52:47 +02:00
|
|
|
return(bytes);
|
|
|
|
} else {
|
|
|
|
/* Pipe is full */
|
|
|
|
return(EAGAIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bytes > PIPE_BUF) {
|
|
|
|
/* Compute available 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
|
|
|
bytes = PIPE_BUF - pos;
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
if (bytes > 0) {
|
|
|
|
/* Do a partial write. Need to wakeup reader
|
|
|
|
* since we'll suspend ourself in read_write()
|
|
|
|
*/
|
|
|
|
if (!notouch)
|
2013-11-04 22:48:08 +01:00
|
|
|
release(vp, VFS_READ, susp_count);
|
2007-08-07 14:52:47 +02:00
|
|
|
return(bytes);
|
2005-04-21 16:53:53 +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
|
|
|
/* Pipe is full */
|
2007-08-07 14:52:47 +02:00
|
|
|
return(SUSPEND);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Writing to an empty pipe. Search for suspended reader. */
|
|
|
|
if (pos == 0 && !notouch)
|
2013-11-04 22:48:08 +01:00
|
|
|
release(vp, VFS_READ, susp_count);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
/* Requested amount fits */
|
- 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(bytes);
|
2005-04-21 16:53:53 +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
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* suspend *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void suspend(int why)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Take measures to suspend the processing of the present system call.
|
|
|
|
* Store the parameters to be used upon resuming in the process table.
|
|
|
|
* (Actually they are not used when a process is waiting for an I/O device,
|
|
|
|
* but they are needed for pipes, and it is not worth making the distinction.)
|
|
|
|
* The SUSPEND pseudo error should be returned after calling suspend().
|
|
|
|
*/
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (why == FP_BLOCKED_ON_POPEN || why == FP_BLOCKED_ON_PIPE)
|
|
|
|
/* #procs susp'ed on pipe*/
|
|
|
|
susp_count++;
|
2009-09-22 23:48:26 +02:00
|
|
|
|
|
|
|
fp->fp_blocked_on = why;
|
2008-02-22 15:47:40 +01:00
|
|
|
assert(fp->fp_grant == GRANT_INVALID || !GRANT_VALID(fp->fp_grant));
|
2012-04-13 14:50:38 +02:00
|
|
|
fp->fp_block_callnr = job_call_nr;
|
2005-04-21 16:53:53 +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
|
|
|
/*===========================================================================*
|
|
|
|
* wait_for *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void wait_for(endpoint_t who)
|
2009-09-22 23:48:26 +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
|
|
|
if(who == NONE || who == ANY)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("suspend on NONE or ANY");
|
- 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
|
|
|
suspend(FP_BLOCKED_ON_OTHER);
|
|
|
|
fp->fp_task = who;
|
2009-09-22 23:48:26 +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
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/*===========================================================================*
|
2012-04-13 14:50:38 +02:00
|
|
|
* pipe_suspend *
|
2007-08-07 14:52:47 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void pipe_suspend(filp, buf, size)
|
2012-02-13 16:28:04 +01:00
|
|
|
struct filp *filp;
|
2007-08-07 14:52:47 +02:00
|
|
|
char *buf;
|
|
|
|
size_t size;
|
|
|
|
{
|
|
|
|
/* Take measures to suspend the processing of the present system call.
|
|
|
|
* Store the parameters to be used upon resuming in the process table.
|
|
|
|
*/
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
scratch(fp).file.filp = filp;
|
|
|
|
scratch(fp).io.io_buffer = buf;
|
|
|
|
scratch(fp).io.io_nbytes = size;
|
|
|
|
suspend(FP_BLOCKED_ON_PIPE);
|
2007-08-07 14:52:47 +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
|
|
|
|
2005-10-12 17:01:23 +02:00
|
|
|
/*===========================================================================*
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
* unsuspend_by_endpt *
|
2005-10-12 17:01:23 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void unsuspend_by_endpt(endpoint_t proc_e)
|
2005-10-12 17:01:23 +02:00
|
|
|
{
|
2011-04-13 15:25:34 +02:00
|
|
|
/* Revive processes waiting for drivers (SUSPENDed) that have disappeared with
|
|
|
|
* return code EAGAIN.
|
|
|
|
*/
|
2005-10-12 17:01:23 +02:00
|
|
|
struct fproc *rp;
|
|
|
|
|
2011-04-13 15:25:34 +02:00
|
|
|
for (rp = &fproc[0]; rp < &fproc[NR_PROCS]; rp++) {
|
2012-02-13 16:28:04 +01:00
|
|
|
if (rp->fp_pid == PID_FREE) continue;
|
|
|
|
if (rp->fp_blocked_on == FP_BLOCKED_ON_OTHER && rp->fp_task == proc_e)
|
2013-09-10 16:06:37 +02:00
|
|
|
revive(rp->fp_endpoint, EIO);
|
2011-04-13 15:25:34 +02:00
|
|
|
}
|
2005-10-20 21:39:32 +02:00
|
|
|
|
2011-04-13 15:25:34 +02:00
|
|
|
/* Revive processes waiting in drivers on select()s with EAGAIN too */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
select_unsuspend_by_endpt(proc_e);
|
2005-10-12 17:01:23 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* release *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void release(vp, op, count)
|
2006-10-25 15:40:36 +02:00
|
|
|
register struct vnode *vp; /* inode of pipe */
|
2013-11-04 22:48:08 +01:00
|
|
|
int op; /* VFS_READ, VFS_WRITE, or VFS_OPEN */
|
2005-04-21 16:53:53 +02:00
|
|
|
int count; /* max number of processes to release */
|
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Check to see if any process is hanging on vnode 'vp'. If one is, and it
|
2013-11-04 22:48:08 +01:00
|
|
|
* was trying to perform the call indicated by 'op', release it.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
register struct fproc *rp;
|
2005-06-17 15:41:12 +02:00
|
|
|
struct filp *f;
|
2012-02-13 16:28:04 +01:00
|
|
|
int selop;
|
2005-06-17 15:41:12 +02:00
|
|
|
|
|
|
|
/* Trying to perform the call also includes SELECTing on it with that
|
|
|
|
* operation.
|
|
|
|
*/
|
2013-11-04 22:48:08 +01:00
|
|
|
if (op == VFS_READ || op == VFS_WRITE) {
|
|
|
|
if (op == VFS_READ)
|
2012-02-13 16:28:04 +01:00
|
|
|
selop = SEL_RD;
|
|
|
|
else
|
|
|
|
selop = SEL_WR;
|
|
|
|
|
|
|
|
for (f = &filp[0]; f < &filp[NR_FILPS]; f++) {
|
|
|
|
if (f->filp_count < 1 || !(f->filp_pipe_select_ops & selop) ||
|
|
|
|
f->filp_vno != vp)
|
|
|
|
continue;
|
|
|
|
select_callback(f, selop);
|
|
|
|
f->filp_pipe_select_ops &= ~selop;
|
|
|
|
}
|
2005-06-17 15:41:12 +02:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Search the proc table. */
|
2009-04-02 13:44:26 +02:00
|
|
|
for (rp = &fproc[0]; rp < &fproc[NR_PROCS] && count > 0; rp++) {
|
2009-09-22 23:48:26 +02:00
|
|
|
if (rp->fp_pid != PID_FREE && fp_is_blocked(rp) &&
|
2012-02-13 16:28:04 +01:00
|
|
|
!(rp->fp_flags & FP_REVIVED) && rp->fp_block_callnr == op) {
|
|
|
|
/* Find the vnode. Depending on the reason the process was
|
|
|
|
* suspended, there are different ways of finding it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (rp->fp_blocked_on == FP_BLOCKED_ON_POPEN ||
|
|
|
|
rp->fp_blocked_on == FP_BLOCKED_ON_LOCK ||
|
|
|
|
rp->fp_blocked_on == FP_BLOCKED_ON_OTHER) {
|
2013-09-10 16:06:37 +02:00
|
|
|
f = rp->fp_filp[scratch(rp).file.fd_nr];
|
|
|
|
if (f == NULL || f->filp_mode == FILP_CLOSED)
|
2012-02-13 16:28:04 +01:00
|
|
|
continue;
|
|
|
|
if (rp->fp_filp[scratch(rp).file.fd_nr]->filp_vno != vp)
|
|
|
|
continue;
|
|
|
|
} else if (rp->fp_blocked_on == FP_BLOCKED_ON_PIPE) {
|
|
|
|
if (scratch(rp).file.filp == NULL)
|
|
|
|
continue;
|
|
|
|
if (scratch(rp).file.filp->filp_vno != vp)
|
|
|
|
continue;
|
|
|
|
} else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* We found the vnode. Revive process. */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
revive(rp->fp_endpoint, 0);
|
2005-04-21 16:53:53 +02:00
|
|
|
susp_count--; /* keep track of who is suspended */
|
2009-04-02 13:44:26 +02:00
|
|
|
if(susp_count < 0)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("susp_count now negative: %d", susp_count);
|
2005-04-21 16:53:53 +02:00
|
|
|
if (--count == 0) return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- 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
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* revive *
|
|
|
|
*===========================================================================*/
|
2012-04-13 14:50:38 +02:00
|
|
|
void revive(endpoint_t proc_e, int returned)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Revive a previously blocked process. When a process hangs on tty, this
|
2013-08-30 13:42:51 +02:00
|
|
|
* is the way it is eventually released. For processes blocked on _SELECT and
|
|
|
|
* _OTHER, this function MUST NOT block its calling thread.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2012-04-13 14:50:38 +02:00
|
|
|
struct fproc *rfp;
|
2009-09-22 23:48:26 +02:00
|
|
|
int blocked_on;
|
2012-02-13 16:28:04 +01:00
|
|
|
int fd_nr, slot;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (proc_e == NONE || isokendpt(proc_e, &slot) != OK) return;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
rfp = &fproc[slot];
|
|
|
|
if (!fp_is_blocked(rfp) || (rfp->fp_flags & FP_REVIVED)) return;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* The 'reviving' flag only applies to pipes. Processes waiting for TTY get
|
|
|
|
* a message right away. The revival process is different for TTY and pipes.
|
2005-06-17 15:41:12 +02:00
|
|
|
* For select and TTY revival, the work is already done, for pipes it is not:
|
2012-02-13 16:28:04 +01:00
|
|
|
* the proc must be restarted so it can try again.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2009-09-22 23:48:26 +02:00
|
|
|
blocked_on = rfp->fp_blocked_on;
|
2012-02-13 16:28:04 +01:00
|
|
|
fd_nr = scratch(rfp).file.fd_nr;
|
2009-09-22 23:48:26 +02:00
|
|
|
if (blocked_on == FP_BLOCKED_ON_PIPE || blocked_on == FP_BLOCKED_ON_LOCK) {
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Revive a process suspended on a pipe or lock. */
|
2012-02-13 16:28:04 +01:00
|
|
|
rfp->fp_flags |= FP_REVIVED;
|
2005-04-21 16:53:53 +02:00
|
|
|
reviving++; /* process was waiting on pipe or lock */
|
- 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 {
|
2009-09-22 23:48:26 +02:00
|
|
|
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
|
2012-02-13 16:28:04 +01:00
|
|
|
scratch(rfp).file.fd_nr = 0;
|
- 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 (blocked_on == FP_BLOCKED_ON_POPEN) {
|
2009-09-22 23:48:26 +02:00
|
|
|
/* process blocked in open or create */
|
2013-04-12 18:41:23 +02:00
|
|
|
replycode(proc_e, fd_nr);
|
- 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 if (blocked_on == FP_BLOCKED_ON_SELECT) {
|
2013-04-12 18:41:23 +02:00
|
|
|
replycode(proc_e, returned);
|
- 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-02-13 16:28:04 +01:00
|
|
|
/* Revive a process suspended on TTY or other device.
|
2006-06-20 12:12:09 +02:00
|
|
|
* Pretend it wants only what there is.
|
|
|
|
*/
|
2012-02-13 16:28:04 +01:00
|
|
|
scratch(rfp).io.io_nbytes = returned;
|
2006-06-20 12:12:09 +02:00
|
|
|
/* If a grant has been issued by FS for this I/O, revoke
|
|
|
|
* it again now that I/O is done.
|
|
|
|
*/
|
2012-02-13 16:28:04 +01:00
|
|
|
if (GRANT_VALID(rfp->fp_grant)) {
|
2006-06-20 12:12:09 +02:00
|
|
|
if(cpf_revoke(rfp->fp_grant)) {
|
2012-02-13 16:28:04 +01:00
|
|
|
panic("VFS: revoke failed for grant: %d",
|
2006-06-20 12:12:09 +02:00
|
|
|
rfp->fp_grant);
|
2012-02-13 16:28:04 +01:00
|
|
|
}
|
2006-06-20 12:12:09 +02:00
|
|
|
rfp->fp_grant = GRANT_INVALID;
|
|
|
|
}
|
2013-04-12 18:41:23 +02:00
|
|
|
replycode(proc_e, returned);/* unblock the process */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* unpause *
|
|
|
|
*===========================================================================*/
|
2013-08-30 14:00:50 +02:00
|
|
|
void unpause(void)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
2005-04-21 16:53:53 +02:00
|
|
|
/* A signal has been sent to a user who is paused on the file system.
|
|
|
|
* Abort the system call with the EINTR error message.
|
|
|
|
*/
|
2013-08-30 14:00:50 +02:00
|
|
|
int blocked_on, fild, status = EINTR;
|
2005-04-21 16:53:53 +02:00
|
|
|
struct filp *f;
|
|
|
|
dev_t dev;
|
2009-05-08 15:56:41 +02:00
|
|
|
int wasreviving = 0;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2013-08-30 14:00:50 +02:00
|
|
|
if (!fp_is_blocked(fp)) return;
|
|
|
|
blocked_on = fp->fp_blocked_on;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
2013-08-30 14:00:50 +02:00
|
|
|
/* Clear the block status now. The procedure below might make blocking calls
|
2013-09-10 20:25:01 +02:00
|
|
|
* and it is imperative that while at least cdev_cancel() is executing, other
|
2013-08-30 14:00:50 +02:00
|
|
|
* parts of VFS do not perceive this process as blocked on something.
|
|
|
|
*/
|
|
|
|
fp->fp_blocked_on = FP_BLOCKED_ON_NONE;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2013-08-30 14:00:50 +02:00
|
|
|
if (fp->fp_flags & FP_REVIVED) {
|
|
|
|
fp->fp_flags &= ~FP_REVIVED;
|
2006-05-15 13:43:06 +02:00
|
|
|
reviving--;
|
2009-05-08 15:56:41 +02:00
|
|
|
wasreviving = 1;
|
2006-06-14 15:17:41 +02:00
|
|
|
}
|
2006-05-15 13:43:06 +02:00
|
|
|
|
2009-09-22 23:48:26 +02:00
|
|
|
switch (blocked_on) {
|
|
|
|
case FP_BLOCKED_ON_PIPE:/* process trying to read or write a pipe */
|
2013-08-28 13:08:16 +02:00
|
|
|
/* If the operation succeeded partially, return the bytes
|
|
|
|
* processed so far, and clear the remembered state. Otherwise,
|
|
|
|
* return EINTR as usual.
|
|
|
|
*/
|
|
|
|
if (fp->fp_cum_io_partial > 0) {
|
|
|
|
status = fp->fp_cum_io_partial;
|
|
|
|
|
|
|
|
fp->fp_cum_io_partial = 0;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
|
2009-09-22 23:48:26 +02:00
|
|
|
case FP_BLOCKED_ON_LOCK:/* process trying to set a lock with FCNTL */
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
|
2009-09-22 23:48:26 +02:00
|
|
|
case FP_BLOCKED_ON_SELECT:/* process blocking on select() */
|
2013-08-25 00:26:38 +02:00
|
|
|
select_forget();
|
2005-06-17 15:41:12 +02:00
|
|
|
break;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
case FP_BLOCKED_ON_POPEN: /* process trying to open a fifo */
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
case FP_BLOCKED_ON_OTHER:/* process trying to do device I/O (e.g. tty)*/
|
2013-08-30 14:00:50 +02:00
|
|
|
fild = scratch(fp).file.fd_nr;
|
2005-06-01 16:31:00 +02:00
|
|
|
if (fild < 0 || fild >= OPEN_MAX)
|
2012-02-13 16:28:04 +01:00
|
|
|
panic("file descriptor out-of-range");
|
2013-08-30 14:00:50 +02:00
|
|
|
f = fp->fp_filp[fild];
|
2013-06-11 01:47:42 +02:00
|
|
|
if(!f) {
|
2013-09-21 00:58:46 +02:00
|
|
|
sys_diagctl_stacktrace(fp->fp_endpoint);
|
2013-06-11 01:47:42 +02:00
|
|
|
panic("process %d blocked on empty fd %d",
|
2013-08-30 14:00:50 +02:00
|
|
|
fp->fp_endpoint, fild);
|
2013-06-11 01:47:42 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
dev = (dev_t) f->filp_vno->v_sdev; /* device hung on */
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2013-09-10 20:25:01 +02:00
|
|
|
status = cdev_cancel(dev);
|
2008-02-22 15:47:40 +01:00
|
|
|
|
2009-09-22 23:48:26 +02:00
|
|
|
break;
|
|
|
|
default :
|
2012-02-13 16:28:04 +01:00
|
|
|
panic("VFS: unknown block reason: %d", blocked_on);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((blocked_on == FP_BLOCKED_ON_PIPE || blocked_on == FP_BLOCKED_ON_POPEN)&&
|
|
|
|
!wasreviving) {
|
2009-05-08 15:56:41 +02:00
|
|
|
susp_count--;
|
|
|
|
}
|
|
|
|
|
2013-08-30 14:00:50 +02:00
|
|
|
replycode(fp->fp_endpoint, status); /* signal interrupted call */
|
2005-06-17 15:41:12 +02:00
|
|
|
}
|