2006-10-25 15:40:36 +02:00
|
|
|
/* lookup() is the main routine that controls the path name lookup. It
|
|
|
|
* handles mountpoints and symbolic links. The actual lookup requests
|
|
|
|
* are sent through the req_lookup wrapper function.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/keymap.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#include <unistd.h>
|
2010-03-29 13:39:54 +02:00
|
|
|
#include <assert.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
2010-08-30 15:44:07 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <dirent.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "fproc.h"
|
|
|
|
#include "vmnt.h"
|
|
|
|
#include "vnode.h"
|
|
|
|
#include "param.h"
|
|
|
|
|
2007-08-08 13:40:47 +02:00
|
|
|
/* Set to following define to 1 if you really want to use the POSIX definition
|
|
|
|
* (IEEE Std 1003.1, 2004) of pathname resolution. POSIX requires pathnames
|
|
|
|
* with a traling slash (and that do not entirely consist of slash characters)
|
|
|
|
* to be treated as if a single dot is appended. This means that for example
|
|
|
|
* mkdir("dir/", ...) and rmdir("dir/") will fail because the call tries to
|
|
|
|
* create or remove the directory '.'. Historically, Unix systems just ignore
|
|
|
|
* trailing slashes.
|
|
|
|
*/
|
|
|
|
#define DO_POSIX_PATHNAME_RES 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
|
|
|
FORWARD _PROTOTYPE( int lookup, (struct vnode *dirp, int flags,
|
2010-08-30 15:44:07 +02:00
|
|
|
node_details_t *node, struct fproc *rfp));
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* advance *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2010-08-30 15:44:07 +02:00
|
|
|
PUBLIC struct vnode *advance(dirp, flags, rfp)
|
- 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 *dirp;
|
2007-08-07 14:52:47 +02:00
|
|
|
int flags;
|
2010-08-30 15:44:07 +02:00
|
|
|
struct fproc *rfp;
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Resolve a pathname (in user_fullpath) starting at dirp to a vnode. */
|
|
|
|
int r;
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *new_vp, *vp;
|
2006-10-25 15:40:36 +02:00
|
|
|
struct vmnt *vmp;
|
2010-11-23 20:34:56 +01:00
|
|
|
struct node_details res = {0,0,0,0,0,0,0};
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-03-29 13:39:54 +02:00
|
|
|
assert(dirp);
|
|
|
|
|
- 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
|
|
|
/* Get a free vnode */
|
2010-05-10 15:26:00 +02:00
|
|
|
if((new_vp = get_free_vnode()) == NULL) return(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
|
|
|
|
|
|
|
/* Lookup vnode belonging to the file. */
|
2010-08-30 15:44:07 +02:00
|
|
|
if ((r = lookup(dirp, flags, &res, rfp)) != 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
|
|
|
err_code = r;
|
2010-05-10 15:26:00 +02:00
|
|
|
return(NULL);
|
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
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Check whether vnode is already in use or not */
|
2010-05-10 15:26:00 +02:00
|
|
|
if ((vp = find_vnode(res.fs_e, res.inode_nr)) != 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
|
|
|
dup_vnode(vp);
|
|
|
|
vp->v_fs_count++; /* We got a reference from the FS */
|
|
|
|
return(vp);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Fill in the free vnode's fields */
|
|
|
|
new_vp->v_fs_e = res.fs_e;
|
|
|
|
new_vp->v_inode_nr = res.inode_nr;
|
|
|
|
new_vp->v_mode = res.fmode;
|
|
|
|
new_vp->v_size = res.fsize;
|
|
|
|
new_vp->v_uid = res.uid;
|
|
|
|
new_vp->v_gid = res.gid;
|
|
|
|
new_vp->v_sdev = res.dev;
|
- 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
|
|
|
|
2010-05-10 15:26:00 +02:00
|
|
|
if( (vmp = find_vmnt(new_vp->v_fs_e)) == NULL)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("VFS advance: vmnt not found");
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
new_vp->v_vmnt = vmp;
|
|
|
|
new_vp->v_dev = vmp->m_dev;
|
|
|
|
new_vp->v_fs_count = 1;
|
|
|
|
new_vp->v_ref_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
|
|
|
|
|
|
|
return(new_vp);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
* eat_path *
|
2007-08-07 14:52:47 +02:00
|
|
|
*===========================================================================*/
|
2010-08-30 15:44:07 +02:00
|
|
|
PUBLIC struct vnode *eat_path(flags, rfp)
|
2007-08-07 14:52:47 +02:00
|
|
|
int flags;
|
2010-08-30 15:44:07 +02:00
|
|
|
struct fproc *rfp;
|
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
|
|
|
/* Resolve 'user_fullpath' to a vnode. advance does the actual work. */
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *vp;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
vp = (user_fullpath[0] == '/' ? rfp->fp_rd : rfp->fp_wd);
|
|
|
|
return advance(vp, flags, rfp);
|
2007-01-05 17:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2010-08-30 15:44:07 +02:00
|
|
|
* last_dir *
|
2007-01-05 17:36:55 +01:00
|
|
|
*===========================================================================*/
|
2010-08-30 15:44:07 +02:00
|
|
|
PUBLIC struct vnode *last_dir(rfp)
|
|
|
|
struct fproc *rfp;
|
2007-01-05 17:36:55 +01:00
|
|
|
{
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Parse a path, 'user_fullpath', as far as the last directory, fetch the vnode
|
|
|
|
* for the last directory into the vnode table, and return a pointer to the
|
|
|
|
* vnode. In addition, return the final component of the path in 'string'. If
|
2010-05-10 15:26:00 +02:00
|
|
|
* the last directory can't be opened, return NULL and the reason for
|
- 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
|
|
|
* failure in 'err_code'. We can't parse component by component as that would
|
|
|
|
* be too expensive. Alternatively, we cut off the last component of the path,
|
|
|
|
* and parse the path up to the penultimate component.
|
|
|
|
*/
|
|
|
|
|
|
|
|
size_t len;
|
|
|
|
char *cp;
|
|
|
|
char dir_entry[PATH_MAX+1];
|
|
|
|
struct vnode *vp, *res;
|
|
|
|
|
|
|
|
/* Is the path absolute or relative? Initialize 'vp' accordingly. */
|
2010-08-30 15:44:07 +02:00
|
|
|
vp = (user_fullpath[0] == '/' ? rfp->fp_rd : rfp->fp_wd);
|
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
|
|
|
len = strlen(user_fullpath);
|
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
|
|
|
/* If path is empty, return ENOENT. */
|
|
|
|
if (len == 0) {
|
|
|
|
err_code = ENOENT;
|
2010-05-10 15:26:00 +02:00
|
|
|
return(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
|
|
|
}
|
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
|
|
|
#if !DO_POSIX_PATHNAME_RES
|
|
|
|
/* Remove trailing slashes */
|
|
|
|
while (len > 1 && user_fullpath[len-1] == '/') {
|
|
|
|
len--;
|
|
|
|
user_fullpath[len]= '\0';
|
|
|
|
}
|
|
|
|
#endif
|
2007-01-05 17:36:55 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
cp = strrchr(user_fullpath, '/');
|
|
|
|
if (cp == NULL) {
|
|
|
|
/* Just one entry in the current working directory */
|
|
|
|
dup_vnode(vp);
|
|
|
|
return(vp);
|
|
|
|
} else if (cp[1] == '\0') {
|
|
|
|
/* Path ends in a slash. The directory entry is '.' */
|
|
|
|
strcpy(dir_entry, ".");
|
|
|
|
} else {
|
|
|
|
/* A path name for the directory and a directory entry */
|
|
|
|
strcpy(dir_entry, cp+1);
|
|
|
|
cp[1]= '\0';
|
|
|
|
}
|
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
|
|
|
/* Remove trailing slashes */
|
|
|
|
while(cp > user_fullpath && cp[0] == '/') {
|
|
|
|
cp[0]= '\0';
|
|
|
|
cp--;
|
2009-04-29 18:59:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
res = advance(vp, PATH_NOFLAGS, rfp);
|
2010-05-10 15:26:00 +02:00
|
|
|
if (res == NULL) return(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
|
|
|
|
|
|
|
/* Copy the directory entry back to user_fullpath */
|
|
|
|
strcpy(user_fullpath, dir_entry);
|
|
|
|
|
|
|
|
return(res);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2007-01-05 17:36:55 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
* lookup *
|
2007-08-07 14:52:47 +02:00
|
|
|
*===========================================================================*/
|
2010-08-30 15:44:07 +02:00
|
|
|
PRIVATE int lookup(start_node, flags, node, rfp)
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *start_node;
|
|
|
|
int flags;
|
|
|
|
node_details_t *node;
|
2010-08-30 15:44:07 +02:00
|
|
|
struct fproc *rfp;
|
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
|
|
|
/* Resolve a pathname (in user_fullpath) relative to start_node. */
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
int r, symloop;
|
|
|
|
endpoint_t 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
|
|
|
size_t path_off, path_left_len;
|
2007-08-07 14:52:47 +02:00
|
|
|
ino_t dir_ino, root_ino;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
struct vnode *dir_vp;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
struct lookup_res res;
|
2009-09-21 16:49:26 +02:00
|
|
|
|
2007-01-05 17:36:55 +01:00
|
|
|
/* Empty (start) path? */
|
2007-08-07 14:52:47 +02:00
|
|
|
if (user_fullpath[0] == '\0') {
|
|
|
|
node->inode_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
|
|
|
return(ENOENT);
|
2007-01-05 17:36:55 +01:00
|
|
|
}
|
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
if(!rfp->fp_rd || !rfp->fp_wd) {
|
|
|
|
printf("VFS: lookup_rel %d: no rd/wd\n", rfp->fp_endpoint);
|
- 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(ENOENT);
|
2009-04-29 18:59:18 +02:00
|
|
|
}
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
fs_e = start_node->v_fs_e;
|
|
|
|
dir_ino = start_node->v_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
|
|
|
|
2007-01-05 17:36:55 +01:00
|
|
|
/* Is the process' root directory on the same partition?,
|
|
|
|
* if so, set the chroot directory too. */
|
2010-08-30 15:44:07 +02:00
|
|
|
if (rfp->fp_rd->v_dev == rfp->fp_wd->v_dev)
|
|
|
|
root_ino = rfp->fp_rd->v_inode_nr;
|
2007-01-05 17:36:55 +01:00
|
|
|
else
|
- 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
|
|
|
root_ino = 0;
|
2007-01-05 17:36:55 +01:00
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Set user and group ids according to the system call */
|
2010-08-30 15:44:07 +02:00
|
|
|
uid = (call_nr == ACCESS ? rfp->fp_realuid : rfp->fp_effuid);
|
|
|
|
gid = (call_nr == ACCESS ? rfp->fp_realgid : rfp->fp_effgid);
|
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
|
|
|
symloop = 0; /* Number of symlinks seen so far */
|
2007-01-05 17:36:55 +01:00
|
|
|
|
|
|
|
/* Issue the request */
|
2010-08-30 15:44:07 +02:00
|
|
|
r = req_lookup(fs_e, dir_ino, root_ino, uid, gid, flags, &res, rfp);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
if (r != OK && r != EENTERMOUNT && r != ELEAVEMOUNT && r != ESYMLINK)
|
- 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); /* i.e., an error occured */
|
2007-01-05 17:36:55 +01:00
|
|
|
|
|
|
|
/* While the response is related to mount control set the
|
|
|
|
* new requests respectively */
|
- 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
|
|
|
while(r == EENTERMOUNT || r == ELEAVEMOUNT || r == ESYMLINK) {
|
|
|
|
/* Update user_fullpath to reflect what's left to be parsed. */
|
|
|
|
path_off = res.char_processed;
|
|
|
|
path_left_len = strlen(&user_fullpath[path_off]);
|
|
|
|
memmove(user_fullpath, &user_fullpath[path_off], path_left_len);
|
|
|
|
user_fullpath[path_left_len] = '\0'; /* terminate string */
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
/* Update the current value of the symloop counter */
|
|
|
|
symloop += res.symloop;
|
|
|
|
if (symloop > SYMLOOP_MAX)
|
- 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(ELOOP);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
/* Symlink encountered with absolute path */
|
|
|
|
if (r == ESYMLINK) {
|
2010-08-30 15:44:07 +02:00
|
|
|
dir_vp = rfp->fp_rd;
|
- 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 (r == EENTERMOUNT) {
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Entering a new partition */
|
|
|
|
dir_vp = 0;
|
|
|
|
/* Start node is now the mounted partition's root node */
|
|
|
|
for (vmp = &vmnt[0]; vmp != &vmnt[NR_MNTS]; ++vmp) {
|
2010-03-29 13:39:54 +02:00
|
|
|
if (vmp->m_dev != NO_DEV && vmp->m_mounted_on) {
|
- 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 (vmp->m_mounted_on->v_inode_nr == res.inode_nr &&
|
|
|
|
vmp->m_mounted_on->v_fs_e == res.fs_e) {
|
2007-08-07 14:52:47 +02:00
|
|
|
dir_vp = vmp->m_root_node;
|
|
|
|
break;
|
2009-09-21 16:49:26 +02:00
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
}
|
2010-03-29 13:39:54 +02:00
|
|
|
assert(dir_vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
} else {
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Climbing up mount */
|
|
|
|
/* Find the vmnt that represents the partition on
|
|
|
|
* which we "climb up". */
|
2010-05-10 15:26:00 +02:00
|
|
|
if ((vmp = find_vmnt(res.fs_e)) == NULL) {
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("VFS lookup: can't find parent vmnt");
|
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
|
|
|
|
|
|
|
/* Make sure that the child FS does not feed a bogus path
|
|
|
|
* to the parent FS. That is, when we climb up the tree, we
|
|
|
|
* must've encountered ".." in the path, and that is exactly
|
|
|
|
* what we're going to feed to the parent */
|
2010-03-08 23:05:27 +01:00
|
|
|
if(strncmp(user_fullpath, "..", 2) != 0 ||
|
|
|
|
(user_fullpath[2] != '\0' && user_fullpath[2] != '/')) {
|
- 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
|
|
|
printf("VFS: bogus path: %s\n", user_fullpath);
|
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Start node is the vnode on which the partition is
|
|
|
|
* mounted */
|
|
|
|
dir_vp = vmp->m_mounted_on;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the starting directories inode number and FS endpoint */
|
|
|
|
fs_e = dir_vp->v_fs_e;
|
|
|
|
dir_ino = dir_vp->v_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
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Is the process' root directory on the same partition?,
|
|
|
|
* if so, set the chroot directory too. */
|
2010-08-30 15:44:07 +02:00
|
|
|
if(dir_vp->v_dev == rfp->fp_rd->v_dev)
|
|
|
|
root_ino = rfp->fp_rd->v_inode_nr;
|
2007-08-07 14:52:47 +02:00
|
|
|
else
|
|
|
|
root_ino = 0;
|
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
r = req_lookup(fs_e, dir_ino, root_ino, uid, gid, flags, &res, rfp);
|
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
|
|
|
if(r != OK && r != EENTERMOUNT && r != ELEAVEMOUNT && r != ESYMLINK)
|
|
|
|
return(r);
|
2007-01-05 17:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in response fields */
|
|
|
|
node->inode_nr = res.inode_nr;
|
|
|
|
node->fmode = res.fmode;
|
|
|
|
node->fsize = res.fsize;
|
|
|
|
node->dev = res.dev;
|
|
|
|
node->fs_e = res.fs_e;
|
|
|
|
node->uid = res.uid;
|
|
|
|
node->gid = res.gid;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
2010-08-30 15:44:07 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* get_name *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int get_name(dirp, entry, ename)
|
|
|
|
struct vnode *dirp;
|
|
|
|
struct vnode *entry;
|
|
|
|
char ename[NAME_MAX + 1];
|
|
|
|
{
|
2010-11-12 19:38:10 +01:00
|
|
|
u64_t pos, new_pos;
|
2010-08-30 15:44:07 +02:00
|
|
|
int r, consumed, totalbytes;
|
|
|
|
char buf[(sizeof(struct dirent) + NAME_MAX) * 8];
|
|
|
|
struct dirent *cur;
|
|
|
|
|
2010-11-12 19:38:10 +01:00
|
|
|
pos = make64(0, 0);
|
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
if ((dirp->v_mode & I_TYPE) != I_DIRECTORY) {
|
|
|
|
return(EBADF);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
r = req_getdents(dirp->v_fs_e, dirp->v_inode_nr, pos,
|
|
|
|
buf, sizeof(buf), &new_pos, 1);
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return(ENOENT); /* end of entries -- matching inode !found */
|
|
|
|
} else if (r < 0) {
|
|
|
|
return(r); /* error */
|
|
|
|
}
|
|
|
|
|
|
|
|
consumed = 0; /* bytes consumed */
|
|
|
|
totalbytes = r; /* number of bytes to consume */
|
|
|
|
|
|
|
|
do {
|
|
|
|
cur = (struct dirent *) (buf + consumed);
|
|
|
|
if (entry->v_inode_nr == cur->d_ino) {
|
|
|
|
/* found the entry we were looking for */
|
|
|
|
strncpy(ename, cur->d_name, NAME_MAX);
|
|
|
|
ename[NAME_MAX] = '\0';
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not a match -- move on to the next dirent */
|
|
|
|
consumed += cur->d_reclen;
|
|
|
|
} while (consumed < totalbytes);
|
|
|
|
|
|
|
|
pos = new_pos;
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* canonical_path *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int canonical_path(orig_path, canon_path, rfp)
|
|
|
|
char *orig_path;
|
|
|
|
char *canon_path; /* should have length PATH_MAX+1 */
|
|
|
|
struct fproc *rfp;
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
int r, symloop = 0;
|
|
|
|
struct vnode *dir_vp, *parent_dir;
|
|
|
|
char component[NAME_MAX+1];
|
|
|
|
char link_path[PATH_MAX+1];
|
|
|
|
|
|
|
|
dir_vp = NULL;
|
|
|
|
strncpy(user_fullpath, orig_path, PATH_MAX);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (dir_vp) put_vnode(dir_vp);
|
|
|
|
|
|
|
|
/* Resolve to the last directory holding the socket file */
|
|
|
|
if ((dir_vp = last_dir(rfp)) == NULL) {
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dir_vp points to dir and user_fullpath now contains only the
|
|
|
|
* filename.
|
|
|
|
*/
|
|
|
|
strcpy(canon_path, user_fullpath); /* Store file name */
|
|
|
|
|
|
|
|
/* check if the file is a symlink, if so resolve it */
|
|
|
|
r = rdlink_direct(canon_path, link_path, rfp);
|
|
|
|
if (r <= 0) {
|
|
|
|
strcpy(user_fullpath, canon_path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* encountered a symlink -- loop again */
|
|
|
|
strcpy(user_fullpath, link_path);
|
|
|
|
|
|
|
|
symloop++;
|
|
|
|
} while (symloop < SYMLOOP_MAX);
|
|
|
|
|
|
|
|
if (symloop >= SYMLOOP_MAX) {
|
|
|
|
if (dir_vp) put_vnode(dir_vp);
|
|
|
|
return ELOOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(dir_vp != rfp->fp_rd) {
|
|
|
|
|
|
|
|
strcpy(user_fullpath, "..");
|
|
|
|
|
|
|
|
/* check if we're at the root node of the file system */
|
|
|
|
if (dir_vp->v_vmnt->m_root_node == dir_vp) {
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
dir_vp = dir_vp->v_vmnt->m_mounted_on;
|
|
|
|
dup_vnode(dir_vp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((parent_dir = advance(dir_vp, PATH_NOFLAGS, rfp)) == NULL) {
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we have to retrieve the name of the parent directory */
|
|
|
|
if (get_name(parent_dir, dir_vp, component) != OK) {
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
put_vnode(parent_dir);
|
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
len += strlen(component) + 1;
|
|
|
|
if (len > PATH_MAX) {
|
|
|
|
/* adding the component to canon_path would exceed PATH_MAX */
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
put_vnode(parent_dir);
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store result of component in canon_path */
|
|
|
|
|
|
|
|
/* first make space by moving the contents of canon_path to
|
|
|
|
* the right. Move strlen + 1 bytes to include the terminating '\0'.
|
|
|
|
*/
|
|
|
|
memmove(canon_path+strlen(component)+1, canon_path,
|
|
|
|
strlen(canon_path) + 1);
|
|
|
|
|
|
|
|
/* Copy component into canon_path */
|
|
|
|
memmove(canon_path, component, strlen(component));
|
|
|
|
|
|
|
|
/* Put slash into place */
|
|
|
|
canon_path[strlen(component)] = '/';
|
|
|
|
|
|
|
|
/* Store parent_dir result, and continue the loop once more */
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
dir_vp = parent_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
put_vnode(dir_vp);
|
|
|
|
|
|
|
|
/* add the leading slash */
|
|
|
|
if (strlen(canon_path) >= PATH_MAX) return(ENAMETOOLONG);
|
|
|
|
memmove(canon_path+1, canon_path, strlen(canon_path));
|
|
|
|
canon_path[0] = '/';
|
|
|
|
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* check_perms *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int check_perms(ep, io_gr, pathlen)
|
|
|
|
endpoint_t ep;
|
|
|
|
cp_grant_id_t io_gr;
|
|
|
|
int pathlen;
|
|
|
|
{
|
|
|
|
int r, i;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct fproc *rfp;
|
|
|
|
char orig_path[PATH_MAX+1];
|
|
|
|
char canon_path[PATH_MAX+1];
|
|
|
|
|
|
|
|
i = _ENDPOINT_P(ep);
|
|
|
|
if (pathlen < UNIX_PATH_MAX || pathlen > PATH_MAX || i < 0 || i >= NR_PROCS) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
rfp = &(fproc[i]);
|
|
|
|
|
|
|
|
memset(canon_path, '\0', PATH_MAX+1);
|
|
|
|
|
|
|
|
r = sys_safecopyfrom(PFS_PROC_NR, io_gr, (vir_bytes) 0,
|
|
|
|
(vir_bytes) &user_fullpath, pathlen, D);
|
|
|
|
if (r != OK) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
user_fullpath[pathlen] = '\0';
|
|
|
|
|
|
|
|
/* save path from pfs before permissions checking modifies it */
|
|
|
|
memcpy(orig_path, user_fullpath, PATH_MAX+1);
|
|
|
|
|
|
|
|
/* get the canonical path to the socket file */
|
|
|
|
r = canonical_path(orig_path, canon_path, rfp);
|
|
|
|
if (r != OK) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(canon_path) >= pathlen) {
|
|
|
|
return ENAMETOOLONG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy canon_path back to PFS */
|
|
|
|
r = sys_safecopyto(PFS_PROC_NR, (cp_grant_id_t) io_gr, (vir_bytes) 0,
|
|
|
|
(vir_bytes) canon_path, strlen(canon_path)+1,
|
|
|
|
D);
|
|
|
|
if (r != OK) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload user_fullpath for permissions checking */
|
|
|
|
memcpy(user_fullpath, orig_path, PATH_MAX+1);
|
|
|
|
if ((vp = eat_path(PATH_NOFLAGS, rfp)) == NULL) {
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check permissions */
|
|
|
|
r = forbidden(vp, (R_BIT | W_BIT));
|
|
|
|
|
|
|
|
put_vnode(vp);
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_check_perms *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_check_perms(void)
|
|
|
|
{
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
return check_perms(m_in.USER_ENDPT, (cp_grant_id_t) m_in.IO_GRANT,
|
|
|
|
m_in.COUNT);
|
2010-08-30 15:44:07 +02:00
|
|
|
}
|