2006-10-25 15:40:36 +02:00
|
|
|
/* This file handles the LINK and UNLINK system calls. It also deals with
|
|
|
|
* deallocating the storage used by a file when the last UNLINK is done to a
|
|
|
|
* file and the blocks must be returned to the free block pool.
|
|
|
|
*
|
|
|
|
* The entry points into this file are
|
|
|
|
* do_link: perform the LINK system call
|
|
|
|
* do_unlink: perform the UNLINK and RMDIR system calls
|
|
|
|
* do_rename: perform the RENAME system call
|
|
|
|
* do_truncate: perform the TRUNCATE system call
|
|
|
|
* do_ftruncate: perform the FTRUNCATE system call
|
|
|
|
* do_rdlink: perform the RDLNK system call
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/callnr.h>
|
2012-02-13 16:28:04 +01:00
|
|
|
#include <minix/vfsif.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <dirent.h>
|
2012-02-13 16:28:04 +01:00
|
|
|
#include <assert.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "file.h"
|
|
|
|
#include "fproc.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "path.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "vnode.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "param.h"
|
2012-04-13 14:50:38 +02:00
|
|
|
#include "scratchpad.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_link *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_link()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the link(name1, name2) system call. */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
int r = OK;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vnode *vp = NULL, *dirp = NULL;
|
|
|
|
struct vmnt *vmp1 = NULL, *vmp2 = NULL;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, vname2;
|
|
|
|
size_t vname1_length, vname2_length;
|
|
|
|
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = job_m_in.name1_length;
|
|
|
|
vname2 = (vir_bytes) job_m_in.name2;
|
|
|
|
vname2_length = job_m_in.name2_length;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp1, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_WRITE;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
|
|
|
/* See if 'name1' (file to be linked to) exists. */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* Does the final directory of 'name2' exist? */
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp2, &dirp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname2, vname2_length, fullpath) != OK)
|
2012-02-13 16:28:04 +01:00
|
|
|
r = err_code;
|
|
|
|
else if ((dirp = last_dir(&resolve, fp)) == 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
|
|
|
r = err_code;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (r != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp1);
|
|
|
|
put_vnode(vp);
|
|
|
|
return(r);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Check for links across devices. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vp->v_fs_e != dirp->v_fs_e)
|
|
|
|
r = EXDEV;
|
|
|
|
else
|
|
|
|
r = forbidden(fp, dirp, W_BIT | X_BIT);
|
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
|
|
|
if (r == OK)
|
2012-02-13 16:28:04 +01:00
|
|
|
r = req_link(vp->v_fs_e, dirp->v_inode_nr, fullpath,
|
- 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_inode_nr);
|
2007-08-08 17:26:47 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vnode(dirp);
|
|
|
|
if (vmp2 != NULL) unlock_vmnt(vmp2);
|
|
|
|
unlock_vmnt(vmp1);
|
- 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
|
|
|
put_vnode(vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
put_vnode(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
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_unlink *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_unlink()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the unlink(name) or rmdir(name) system call. The code for these two
|
|
|
|
* is almost the same. They differ only in some condition testing. Unlink()
|
|
|
|
* may be used by the superuser to do dangerous things; rmdir() may not.
|
2012-04-13 14:50:38 +02:00
|
|
|
* The syscall might provide 'name' embedded in the message.
|
2006-10-25 15:40:36 +02:00
|
|
|
*/
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
struct vnode *dirp, *dirp_l, *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp, *vmp2;
|
2006-10-25 15:40:36 +02:00
|
|
|
int r;
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
struct lookup resolve, stickycheck;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length;
|
|
|
|
|
|
|
|
vname = (vir_bytes) job_m_in.name;
|
|
|
|
vname_length = job_m_in.name_length;
|
|
|
|
if (copy_name(vname_length, fullpath) != OK) {
|
|
|
|
/* Direct copy failed, try fetching from user space */
|
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK)
|
|
|
|
return(err_code);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &dirp_l);
|
2012-02-13 16:28:04 +01:00
|
|
|
resolve.l_vmnt_lock = VMNT_WRITE;
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Get the last directory in the path. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((dirp = last_dir(&resolve, fp)) == NULL) return(err_code);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2007-08-08 16:01:36 +02:00
|
|
|
/* Make sure that the object is a directory */
|
2012-04-25 14:44:42 +02:00
|
|
|
if (!S_ISDIR(dirp->v_mode)) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(dirp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(dirp);
|
|
|
|
return(ENOTDIR);
|
2007-08-08 16:01:36 +02:00
|
|
|
}
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* The caller must have both search and execute permission */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = forbidden(fp, dirp, X_BIT | W_BIT)) != OK) {
|
|
|
|
unlock_vnode(dirp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(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
|
|
|
return(r);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Also, if the sticky bit is set, only the owner of the file or a privileged
|
|
|
|
user is allowed to unlink */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((dirp->v_mode & S_ISVTX) == S_ISVTX) {
|
- 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
|
|
|
/* Look up inode of file to unlink to retrieve owner */
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
lookup_init(&stickycheck, resolve.l_path, PATH_RET_SYMLINK, &vmp2, &vp);
|
|
|
|
stickycheck.l_vmnt_lock = VMNT_READ;
|
|
|
|
stickycheck.l_vnode_lock = VNODE_READ;
|
|
|
|
vp = advance(dirp, &stickycheck, fp);
|
2012-02-13 16:28:04 +01:00
|
|
|
assert(vmp2 == NULL);
|
2010-05-10 15:26:00 +02:00
|
|
|
if (vp != NULL) {
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = EPERM;
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
put_vnode(vp);
|
|
|
|
} else
|
|
|
|
r = err_code;
|
|
|
|
if (r != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(dirp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(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
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
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
|
|
|
upgrade_vmnt_lock(vmp);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (job_call_nr == UNLINK)
|
2012-02-13 16:28:04 +01:00
|
|
|
r = req_unlink(dirp->v_fs_e, dirp->v_inode_nr, fullpath);
|
|
|
|
else
|
|
|
|
r = req_rmdir(dirp->v_fs_e, dirp->v_inode_nr, fullpath);
|
|
|
|
unlock_vnode(dirp);
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
put_vnode(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
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_rename *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_rename()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the rename(name1, name2) system call. */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
int r = OK, r1;
|
2013-01-11 13:46:44 +01:00
|
|
|
struct vnode *old_dirp = NULL, *new_dirp = NULL, *new_dirp_l = NULL, *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *oldvmp, *newvmp, *vmp2;
|
2011-09-12 11:00:24 +02:00
|
|
|
char old_name[PATH_MAX];
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
struct lookup resolve, stickycheck;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, vname2;
|
|
|
|
size_t vname1_length, vname2_length;
|
|
|
|
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = job_m_in.name1_length;
|
|
|
|
vname2 = (vir_bytes) job_m_in.name2;
|
|
|
|
vname2_length = job_m_in.name2_length;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-07-18 16:59:45 +02:00
|
|
|
lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &oldvmp, &old_dirp);
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Do not yet request exclusive lock on vmnt to prevent deadlocks later on */
|
|
|
|
resolve.l_vmnt_lock = VMNT_WRITE;
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* See if 'name1' (existing file) exists. Get dir and file inodes. */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
|
|
|
|
if ((old_dirp = last_dir(&resolve, fp)) == NULL) return(err_code);
|
- 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 the sticky bit is set, only the owner of the file or a privileged
|
|
|
|
user is allowed to rename */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((old_dirp->v_mode & S_ISVTX) == S_ISVTX) {
|
- 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
|
|
|
/* Look up inode of file to unlink to retrieve owner */
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
lookup_init(&stickycheck, resolve.l_path, PATH_RET_SYMLINK, &vmp2, &vp);
|
|
|
|
stickycheck.l_vmnt_lock = VMNT_READ;
|
|
|
|
stickycheck.l_vnode_lock = VNODE_READ;
|
|
|
|
vp = advance(old_dirp, &stickycheck, fp);
|
2012-02-13 16:28:04 +01:00
|
|
|
assert(vmp2 == NULL);
|
2010-05-10 15:26:00 +02:00
|
|
|
if (vp != NULL) {
|
2012-02-13 16:28:04 +01:00
|
|
|
if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = EPERM;
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
put_vnode(vp);
|
|
|
|
} else
|
|
|
|
r = err_code;
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) {
|
|
|
|
unlock_vnode(old_dirp);
|
|
|
|
unlock_vmnt(oldvmp);
|
- 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
|
|
|
put_vnode(old_dirp);
|
|
|
|
return(r);
|
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
/* Save the last component of the old name */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (strlen(fullpath) >= sizeof(old_name)) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(old_dirp);
|
|
|
|
unlock_vmnt(oldvmp);
|
- 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
|
|
|
put_vnode(old_dirp);
|
|
|
|
return(ENAMETOOLONG);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2012-07-13 18:08:06 +02:00
|
|
|
strlcpy(old_name, fullpath, PATH_MAX);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* See if 'name2' (new name) exists. Get dir inode */
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &newvmp, &new_dirp_l);
|
2012-02-13 16:28:04 +01:00
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname2, vname2_length, fullpath) != OK) r = err_code;
|
|
|
|
else if ((new_dirp = last_dir(&resolve, fp)) == NULL) r = err_code;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
/* We used a separate vnode pointer to see whether we obtained a lock on the
|
|
|
|
* new_dirp vnode. If the new directory and old directory are the same, then
|
|
|
|
* the VNODE_WRITE lock on new_dirp will fail. In that case, new_dirp_l will
|
|
|
|
* be NULL, but new_dirp will not.
|
|
|
|
*/
|
|
|
|
if (new_dirp == old_dirp) assert(new_dirp_l == 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
|
|
|
if (r != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(old_dirp);
|
|
|
|
unlock_vmnt(oldvmp);
|
|
|
|
put_vnode(old_dirp);
|
|
|
|
return(r);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Both parent directories must be on the same device. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (old_dirp->v_fs_e != new_dirp->v_fs_e) r = EXDEV;
|
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
|
|
|
/* Parent dirs must be writable, searchable and on a writable device */
|
2012-01-27 17:06:43 +01:00
|
|
|
if ((r1 = forbidden(fp, old_dirp, W_BIT|X_BIT)) != OK ||
|
|
|
|
(r1 = forbidden(fp, new_dirp, W_BIT|X_BIT)) != OK) r = r1;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
if (r == OK) {
|
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
|
|
|
upgrade_vmnt_lock(oldvmp); /* Upgrade to exclusive access */
|
2012-02-13 16:28:04 +01:00
|
|
|
r = req_rename(old_dirp->v_fs_e, old_dirp->v_inode_nr, old_name,
|
|
|
|
new_dirp->v_inode_nr, fullpath);
|
|
|
|
}
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(old_dirp);
|
|
|
|
unlock_vmnt(oldvmp);
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
if (new_dirp_l) unlock_vnode(new_dirp_l);
|
2012-02-13 16:28:04 +01:00
|
|
|
if (newvmp) unlock_vmnt(newvmp);
|
|
|
|
|
- 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
|
|
|
put_vnode(old_dirp);
|
|
|
|
put_vnode(new_dirp);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_truncate *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_truncate()
|
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
|
|
|
/* truncate_vnode() does the actual work of do_truncate() and do_ftruncate().
|
2006-10-25 15:40:36 +02:00
|
|
|
* do_truncate() and do_ftruncate() have to get hold of the inode, either
|
|
|
|
* by name or fd, do checks on it, and call truncate_inode() to do the
|
|
|
|
* work.
|
|
|
|
*/
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
2006-10-25 15:40:36 +02:00
|
|
|
int r;
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
off_t length;
|
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length;
|
|
|
|
|
|
|
|
vname = (vir_bytes) job_m_in.m2_p1;
|
|
|
|
vname_length = job_m_in.m2_i1;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
2012-02-13 16:28:04 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2007-01-05 17:36:55 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
length = (off_t) job_m_in.flength;
|
|
|
|
if (length < 0) return(EINVAL);
|
2010-02-09 09:12:37 +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
|
|
|
/* Temporarily open file */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
|
|
|
|
- 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
|
|
|
/* Ask FS to truncate the file */
|
2012-04-20 11:12:04 +02:00
|
|
|
if ((r = forbidden(fp, vp, W_BIT)) == OK) {
|
|
|
|
/* If the file size does not change, do not make the actual call. This
|
|
|
|
* ensures that the file times are retained when the file size remains
|
|
|
|
* the same, which is a POSIX requirement.
|
|
|
|
*/
|
|
|
|
if (S_ISREG(vp->v_mode) && vp->v_size == length)
|
|
|
|
r = OK;
|
|
|
|
else
|
|
|
|
r = truncate_vnode(vp, length);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_ftruncate *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_ftruncate()
|
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
|
|
|
/* As with do_truncate(), truncate_vnode() does the actual work. */
|
2006-10-25 15:40:36 +02:00
|
|
|
struct filp *rfilp;
|
2012-04-20 11:12:04 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
int r;
|
2012-04-13 14:50:38 +02:00
|
|
|
off_t length;
|
|
|
|
|
|
|
|
scratch(fp).file.fd_nr = job_m_in.fd;
|
|
|
|
length = (off_t) job_m_in.flength;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (length < 0) return(EINVAL);
|
2010-02-09 09:12:37 +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
|
|
|
/* File is already opened; get a vnode pointer from filp */
|
2012-04-13 14:50:38 +02:00
|
|
|
if ((rfilp = get_filp(scratch(fp).file.fd_nr, VNODE_WRITE)) == NULL)
|
|
|
|
return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-20 11:12:04 +02:00
|
|
|
vp = rfilp->filp_vno;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (!(rfilp->filp_mode & W_BIT))
|
|
|
|
r = EBADF;
|
2012-04-20 11:12:04 +02:00
|
|
|
else if (S_ISREG(vp->v_mode) && vp->v_size == length)
|
|
|
|
/* If the file size does not change, do not make the actual call. This
|
|
|
|
* ensures that the file times are retained when the file size remains
|
|
|
|
* the same, which is a POSIX requirement.
|
|
|
|
*/
|
|
|
|
r = OK;
|
2012-02-13 16:28:04 +01:00
|
|
|
else
|
2012-04-20 11:12:04 +02:00
|
|
|
r = truncate_vnode(vp, length);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
unlock_filp(rfilp);
|
|
|
|
return(r);
|
2007-01-05 17:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* truncate_vnode *
|
2007-01-05 17:36:55 +01:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int truncate_vnode(vp, newsize)
|
2007-01-05 17:36:55 +01:00
|
|
|
struct vnode *vp;
|
|
|
|
off_t newsize;
|
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Truncate a regular file or a pipe */
|
2012-04-16 11:04:32 +02:00
|
|
|
int r;
|
2007-01-05 17:36:55 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
assert(tll_locked_by_me(&vp->v_lock));
|
2012-04-16 11:04:32 +02:00
|
|
|
if (!S_ISREG(vp->v_mode) && !S_ISFIFO(vp->v_mode)) return(EINVAL);
|
2012-04-20 11:12:04 +02:00
|
|
|
|
|
|
|
/* We must not compare the old and the new size here: this function may be
|
|
|
|
* called for open(2), which requires an update to the file times if O_TRUNC
|
|
|
|
* is given, even if the file size remains the same.
|
|
|
|
*/
|
- 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 = req_ftrunc(vp->v_fs_e, vp->v_inode_nr, newsize, 0)) == OK)
|
|
|
|
vp->v_size = newsize;
|
|
|
|
return(r);
|
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
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_slink *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_slink()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
|
|
|
/* Perform the symlink(name1, name2) system call. */
|
2010-04-01 15:25:05 +02:00
|
|
|
int r;
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname1, vname2;
|
|
|
|
size_t vname1_length, vname2_length;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_WRITE;
|
VFS: change locking to ease concurrent FSes
This patch uses stricter locking for REQ_LINK, REQ_MKDIR, REQ_MKNOD,
REQ_RENAME, REQ_RMDIR, REQ_SLINK and REQ_UNLINK. For all requests, VFS
locks the directory in which we add or remove an inode with VNODE_WRITE.
I.e., the operations have exclusive access to that directory.
Furthermore, REQ_CHOWN, REQ_CHMOD, and REQ_FTRUNC now lock the vmnt
VMNT_READ; VMNT_WRITE was unnecessary.
2012-12-21 16:30:37 +01:00
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = job_m_in.name1_length;
|
|
|
|
vname2 = (vir_bytes) job_m_in.name2;
|
|
|
|
vname2_length = job_m_in.name2_length;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
if (vname1_length <= 1) return(ENOENT);
|
|
|
|
if (vname1_length >= SYMLINK_MAX) return(ENAMETOOLONG);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Get dir inode of 'name2' */
|
|
|
|
if (fetch_name(vname2, vname2_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code);
|
2012-01-27 17:06:43 +01:00
|
|
|
if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
r = req_slink(vp->v_fs_e, vp->v_inode_nr, fullpath, who_e,
|
2012-04-13 14:50:38 +02:00
|
|
|
vname1, vname1_length - 1, fp->fp_effuid,
|
- 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
|
|
|
fp->fp_effgid);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* rdlink_direct *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int rdlink_direct(orig_path, link_path, rfp)
|
2010-08-30 15:44:07 +02:00
|
|
|
char *orig_path;
|
2012-02-13 16:28:04 +01:00
|
|
|
char link_path[PATH_MAX]; /* should have length PATH_MAX */
|
2010-08-30 15:44:07 +02:00
|
|
|
struct fproc *rfp;
|
|
|
|
{
|
|
|
|
/* Perform a readlink()-like call from within the VFS */
|
|
|
|
int r;
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
struct lookup resolve;
|
2010-08-30 15:44:07 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, link_path, PATH_RET_SYMLINK, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
|
|
|
/* Temporarily open the file containing the symbolic link. Use link_path
|
|
|
|
* for temporary storage to keep orig_path untouched. */
|
|
|
|
strncpy(link_path, orig_path, PATH_MAX); /* PATH_MAX includes '\0' */
|
|
|
|
link_path[PATH_MAX - 1] = '\0';
|
|
|
|
if ((vp = eat_path(&resolve, rfp)) == NULL) return(err_code);
|
2010-08-30 15:44:07 +02:00
|
|
|
|
|
|
|
/* Make sure this is a symbolic link */
|
2012-04-25 14:44:42 +02:00
|
|
|
if (!S_ISLNK(vp->v_mode))
|
2010-08-30 15:44:07 +02:00
|
|
|
r = EINVAL;
|
|
|
|
else
|
2012-04-13 14:50:38 +02:00
|
|
|
r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, NONE, (vir_bytes) link_path,
|
2012-02-13 16:28:04 +01:00
|
|
|
PATH_MAX - 1, 1);
|
|
|
|
|
|
|
|
if (r > 0) link_path[r] = '\0'; /* Terminate string when succesful */
|
2010-08-30 15:44:07 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
2010-08-30 15:44:07 +02:00
|
|
|
put_vnode(vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2010-08-30 15:44:07 +02:00
|
|
|
return r;
|
|
|
|
}
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
2012-02-13 16:28:04 +01:00
|
|
|
* do_rdlink *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_rdlink()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Perform the readlink(name, buf, bufsize) system call. */
|
2012-04-13 14:50:38 +02:00
|
|
|
int r;
|
2007-08-07 14:52:47 +02:00
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length, buf_size;
|
|
|
|
vir_bytes buf;
|
|
|
|
|
|
|
|
vname = (vir_bytes) job_m_in.name1;
|
|
|
|
vname_length = job_m_in.name1_length;
|
|
|
|
buf = (vir_bytes) job_m_in.name2;
|
|
|
|
buf_size = (size_t) job_m_in.nbytes;
|
|
|
|
if (buf_size > SSIZE_MAX) return(EINVAL);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
- 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
|
|
|
/* Temporarily open the file containing the symbolic link */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2009-05-20 11:46:06 +02:00
|
|
|
/* Make sure this is a symbolic link */
|
2012-04-25 14:44:42 +02:00
|
|
|
if (!S_ISLNK(vp->v_mode))
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = EINVAL;
|
|
|
|
else
|
2012-04-13 14:50:38 +02:00
|
|
|
r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, who_e, buf, buf_size, 0);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|