2006-10-25 15:40:36 +02:00
|
|
|
/* This file performs the MOUNT and UMOUNT system calls.
|
|
|
|
*
|
|
|
|
* The entry points into this file are
|
2012-02-13 16:28:04 +01:00
|
|
|
* do_fsready: perform the FS_READY system call
|
2010-01-13 00:08:50 +01:00
|
|
|
* do_mount: perform the MOUNT system call
|
|
|
|
* do_umount: perform the UMOUNT system call
|
|
|
|
* unmount: unmount a file system
|
2006-10-25 15:40:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/keymap.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#include <minix/syslib.h>
|
2010-01-13 00:08:50 +01:00
|
|
|
#include <minix/bitmap.h>
|
|
|
|
#include <minix/ds.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h>
|
2010-01-13 00:08:50 +01:00
|
|
|
#include <sys/mount.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 "dmap.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
|
|
|
#include "vnode.h"
|
|
|
|
#include "vmnt.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "path.h"
|
|
|
|
#include "param.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* Allow the root to be replaced before the first 'real' mount. */
|
2012-03-25 20:25:53 +02:00
|
|
|
static int have_root = 0;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
/* Bitmap of in-use "none" pseudo devices. */
|
2012-03-25 20:25:53 +02:00
|
|
|
static bitchunk_t nonedev[BITMAP_CHUNKS(NR_NONEDEVS)] = { 0 };
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
#define alloc_nonedev(dev) SET_BIT(nonedev, minor(dev) - 1)
|
|
|
|
#define free_nonedev(dev) UNSET_BIT(nonedev, minor(dev) - 1)
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static dev_t name_to_dev(int allow_mountpt, char path[PATH_MAX]);
|
|
|
|
static dev_t find_free_nonedev(void);
|
|
|
|
static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e);
|
2011-03-25 11:56:43 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* update_bspec *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e)
|
2011-03-25 11:56:43 +01:00
|
|
|
{
|
|
|
|
/* Update all block special files for a certain device, to use a new FS endpt
|
|
|
|
* to route raw block I/O requests through.
|
|
|
|
*/
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct dmap *dp;
|
|
|
|
int r, major;
|
2011-03-25 11:56:43 +01:00
|
|
|
|
|
|
|
for (vp = &vnode[0]; vp < &vnode[NR_VNODES]; ++vp)
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vp->v_ref_count > 0 && S_ISBLK(vp->v_mode) && vp->v_sdev == dev) {
|
2011-03-25 11:56:43 +01:00
|
|
|
vp->v_bfs_e = fs_e;
|
2012-02-13 16:28:04 +01:00
|
|
|
if (send_drv_e) {
|
|
|
|
major = major(dev);
|
|
|
|
if (major < 0 || major >= NR_DEVICES) {
|
|
|
|
/* Can't update for out-of-range major */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dp = &dmap[major(dev)];
|
|
|
|
if (dp->dmap_driver == NONE) {
|
|
|
|
/* Can't update for vanished driver */
|
|
|
|
printf("VFS: can't send new driver label\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((r = req_newdriver(fs_e, vp->v_sdev,
|
|
|
|
dp->dmap_label)) != OK) {
|
|
|
|
printf("VFS: Failed to send new driver label"
|
|
|
|
" for moved block special file to %d\n",
|
|
|
|
fs_e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-25 11:56:43 +01:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
2012-02-13 16:28:04 +01:00
|
|
|
* do_fsready *
|
2006-10-25 15:40:36 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_fsready()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2010-11-23 20:34:56 +01:00
|
|
|
/* deprecated */
|
|
|
|
return(SUSPEND);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_mount *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_mount()
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Perform the mount(name, mfile, mount_flags) system call. */
|
2010-04-08 15:41:35 +02:00
|
|
|
endpoint_t fs_e;
|
2012-02-13 16:28:04 +01:00
|
|
|
int r, slot, rdonly, nodev;
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
char mount_label[LABEL_MAX];
|
|
|
|
dev_t dev;
|
2012-04-13 14:50:38 +02:00
|
|
|
int mflags;
|
|
|
|
vir_bytes label, vname1, vname2;
|
|
|
|
size_t vname1_length, vname2_length;
|
|
|
|
|
|
|
|
mflags = job_m_in.mount_flags;
|
|
|
|
label = (vir_bytes) job_m_in.fs_label;
|
|
|
|
vname1 = (vir_bytes) job_m_in.name1;
|
|
|
|
vname1_length = (size_t) job_m_in.name1_length;
|
|
|
|
vname2 = (vir_bytes) job_m_in.name2;
|
|
|
|
vname2_length = (size_t) job_m_in.name2_length;
|
2007-01-16 14:57:35 +01:00
|
|
|
|
|
|
|
/* Only the super-user may do MOUNT. */
|
|
|
|
if (!super_user) return(EPERM);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2012-04-13 14:50:38 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* FS process' endpoint number */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (mflags & MS_LABEL16) {
|
2010-01-13 00:08:50 +01:00
|
|
|
/* Get the label from the caller, and ask DS for the endpoint. */
|
2012-04-13 14:50:38 +02:00
|
|
|
r = sys_datacopy(who_e, label, SELF, (vir_bytes) mount_label,
|
|
|
|
sizeof(mount_label));
|
2010-01-13 00:08:50 +01:00
|
|
|
if (r != OK) return(r);
|
|
|
|
|
|
|
|
mount_label[sizeof(mount_label)-1] = 0;
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
r = ds_retrieve_label_endpt(mount_label, &fs_e);
|
2010-01-13 00:08:50 +01:00
|
|
|
if (r != OK) return(r);
|
|
|
|
} else {
|
|
|
|
/* Legacy support: get the endpoint from the request itself. */
|
2012-04-13 14:50:38 +02:00
|
|
|
fs_e = (endpoint_t) label;
|
2010-01-13 00:08:50 +01:00
|
|
|
mount_label[0] = 0;
|
|
|
|
}
|
2006-11-27 15:21:43 +01:00
|
|
|
|
2007-01-16 14:57:35 +01:00
|
|
|
/* Sanity check on process number. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (isokendpt(fs_e, &slot) != OK) return(EINVAL);
|
2009-01-20 14:43:00 +01:00
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
/* Should the file system be mounted read-only? */
|
2012-04-13 14:50:38 +02:00
|
|
|
rdonly = (mflags & MS_RDONLY);
|
2010-01-13 00:08:50 +01:00
|
|
|
|
|
|
|
/* A null string for block special device means don't use a device at all. */
|
2012-04-13 14:50:38 +02:00
|
|
|
nodev = (vname1_length == 0);
|
2010-01-13 00:08:50 +01:00
|
|
|
if (!nodev) {
|
|
|
|
/* If 'name' is not for a block special file, return error. */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname1, vname1_length, fullpath) != OK)
|
2010-01-13 00:08:50 +01:00
|
|
|
return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((dev = name_to_dev(FALSE /*allow_mountpt*/, fullpath)) == NO_DEV)
|
2010-01-13 00:08:50 +01:00
|
|
|
return(err_code);
|
|
|
|
} else {
|
|
|
|
/* Find a free pseudo-device as substitute for an actual device. */
|
|
|
|
if ((dev = find_free_nonedev()) == NO_DEV)
|
|
|
|
return(err_code);
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Fetch the name of the mountpoint */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (fetch_name(vname2, vname2_length, fullpath) != OK) return(err_code);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
/* Do the actual job */
|
|
|
|
return mount_fs(dev, fullpath, fs_e, rdonly, mount_label);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* mount_fs *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int mount_fs(
|
2012-02-13 16:28:04 +01:00
|
|
|
dev_t dev,
|
|
|
|
char mountpoint[PATH_MAX],
|
|
|
|
endpoint_t fs_e,
|
|
|
|
int rdonly,
|
|
|
|
char mount_label[LABEL_MAX] )
|
|
|
|
{
|
|
|
|
int rdir, mdir; /* TRUE iff {root|mount} file is dir */
|
|
|
|
int i, r = OK, found, isroot, mount_root, con_reqs, slot;
|
|
|
|
struct fproc *tfp, *rfp;
|
|
|
|
struct dmap *dp;
|
|
|
|
struct vnode *root_node, *vp = NULL;
|
|
|
|
struct vmnt *new_vmp, *parent_vmp;
|
|
|
|
char *label;
|
|
|
|
struct node_details res;
|
|
|
|
struct lookup resolve;
|
|
|
|
|
|
|
|
/* Look up block device driver label when dev is not a pseudo-device */
|
|
|
|
label = "";
|
|
|
|
if (!is_nonedev(dev)) {
|
|
|
|
/* Get driver process' endpoint */
|
|
|
|
dp = &dmap[major(dev)];
|
|
|
|
if (dp->dmap_driver == NONE) {
|
|
|
|
printf("VFS: no driver for dev %d\n", dev);
|
|
|
|
return(EINVAL);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
label = dp->dmap_label;
|
|
|
|
assert(strlen(label) > 0);
|
2006-10-25 15:40:36 +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
|
|
|
/* Scan vmnt table to see if dev already mounted. If not, find a free slot.*/
|
2012-02-13 16:28:04 +01:00
|
|
|
found = FALSE;
|
2006-10-25 15:40:36 +02:00
|
|
|
for (i = 0; i < NR_MNTS; ++i) {
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vmnt[i].m_dev == dev) found = TRUE;
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
if (found) {
|
2012-02-13 16:28:04 +01:00
|
|
|
return(EBUSY);
|
|
|
|
} else if ((new_vmp = get_free_vmnt()) == NULL) {
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = lock_vmnt(new_vmp, VMNT_EXCL)) != OK) return(r);
|
|
|
|
|
|
|
|
isroot = (strcmp(mountpoint, "/") == 0);
|
|
|
|
mount_root = (isroot && have_root < 2); /* Root can be mounted twice:
|
|
|
|
* 1: ramdisk
|
|
|
|
* 2: boot disk (e.g., harddisk)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!mount_root) {
|
|
|
|
/* Get vnode of mountpoint */
|
|
|
|
lookup_init(&resolve, mountpoint, PATH_NOFLAGS, &parent_vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_EXCL;
|
|
|
|
resolve.l_vnode_lock = VNODE_WRITE;
|
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL)
|
|
|
|
r = err_code;
|
|
|
|
else if (vp->v_ref_count == 1) {
|
|
|
|
/*Tell FS on which vnode it is mounted (glue into mount tree)*/
|
|
|
|
r = req_mountpoint(vp->v_fs_e, vp->v_inode_nr);
|
|
|
|
} else
|
|
|
|
r = EBUSY;
|
|
|
|
|
|
|
|
if (vp != NULL) {
|
|
|
|
/* Quickly unlock to allow back calls (from e.g. FUSE) to
|
|
|
|
* relock */
|
|
|
|
unlock_vmnt(parent_vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (r != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
if (vp != NULL) {
|
|
|
|
unlock_vnode(vp);
|
|
|
|
put_vnode(vp);
|
|
|
|
}
|
|
|
|
unlock_vmnt(new_vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* We'll need a vnode for the root inode */
|
|
|
|
if ((root_node = get_free_vnode()) == NULL) {
|
|
|
|
if (vp != NULL) {
|
|
|
|
unlock_vnode(vp);
|
2011-03-25 11:56:43 +01:00
|
|
|
put_vnode(vp);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vmnt(new_vmp);
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
lock_vnode(root_node, VNODE_OPCL);
|
2010-06-11 13:41:56 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Record process as a system process */
|
|
|
|
if (isokendpt(fs_e, &slot) != OK) {
|
|
|
|
if (vp != NULL) {
|
|
|
|
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);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(root_node);
|
|
|
|
unlock_vmnt(new_vmp);
|
|
|
|
return(EINVAL);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
rfp = &fproc[slot];
|
|
|
|
rfp->fp_flags |= FP_SYS_PROC; /* Process is an FS */
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Store some essential vmnt data first */
|
|
|
|
new_vmp->m_fs_e = fs_e;
|
|
|
|
new_vmp->m_dev = dev;
|
|
|
|
if (rdonly) new_vmp->m_flags |= VMNT_READONLY;
|
|
|
|
else new_vmp->m_flags &= ~VMNT_READONLY;
|
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
|
|
|
/* Tell FS which device to mount */
|
2012-02-13 16:28:04 +01:00
|
|
|
new_vmp->m_flags |= VMNT_MOUNTING;
|
|
|
|
r = req_readsuper(fs_e, label, dev, rdonly, isroot, &res, &con_reqs);
|
|
|
|
new_vmp->m_flags &= ~VMNT_MOUNTING;
|
|
|
|
|
|
|
|
if (r != OK) {
|
2012-02-22 14:54:35 +01:00
|
|
|
mark_vmnt_free(new_vmp);
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(root_node);
|
|
|
|
if (vp != NULL) {
|
|
|
|
unlock_vnode(vp);
|
|
|
|
put_vnode(vp);
|
|
|
|
}
|
|
|
|
unlock_vmnt(new_vmp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lock_bsf();
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Fill in root node's fields */
|
2007-08-10 15:01:38 +02:00
|
|
|
root_node->v_fs_e = res.fs_e;
|
|
|
|
root_node->v_inode_nr = res.inode_nr;
|
|
|
|
root_node->v_mode = res.fmode;
|
|
|
|
root_node->v_uid = res.uid;
|
|
|
|
root_node->v_gid = res.gid;
|
|
|
|
root_node->v_size = res.fsize;
|
2006-10-25 15:40:36 +02:00
|
|
|
root_node->v_sdev = NO_DEV;
|
2007-08-07 14:52:47 +02:00
|
|
|
root_node->v_fs_count = 1;
|
2007-01-05 17:36:55 +01:00
|
|
|
root_node->v_ref_count = 1;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Root node is indeed on the partition */
|
2012-02-13 16:28:04 +01:00
|
|
|
root_node->v_vmnt = new_vmp;
|
|
|
|
root_node->v_dev = new_vmp->m_dev;
|
|
|
|
if (con_reqs == 0)
|
|
|
|
new_vmp->m_comm.c_max_reqs = 1; /* Default if FS doesn't tell us */
|
|
|
|
else
|
|
|
|
new_vmp->m_comm.c_max_reqs = con_reqs;
|
|
|
|
new_vmp->m_comm.c_cur_reqs = 0;
|
|
|
|
|
|
|
|
if (mount_root) {
|
|
|
|
/* Superblock and root node already 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
|
|
|
* Nothing else can go wrong. Perform the mount. */
|
2012-02-13 16:28:04 +01:00
|
|
|
new_vmp->m_root_node = root_node;
|
|
|
|
new_vmp->m_mounted_on = NULL;
|
|
|
|
strcpy(new_vmp->m_label, mount_label);
|
|
|
|
if (is_nonedev(dev)) alloc_nonedev(dev);
|
|
|
|
update_bspec(dev, fs_e, 0 /* Don't send new driver endpoint */);
|
2008-12-11 15:45:31 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
ROOT_DEV = dev;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
ROOT_FS_E = fs_e;
|
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
|
|
|
/* Replace all root and working directories */
|
2012-02-13 16:28:04 +01:00
|
|
|
for (i = 0, tfp = fproc; i < NR_PROCS; i++, tfp++) {
|
- 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 (tfp->fp_pid == PID_FREE)
|
|
|
|
continue;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
#define MAKEROOT(what) { \
|
|
|
|
if (what) put_vnode(what); \
|
|
|
|
dup_vnode(root_node); \
|
|
|
|
what = root_node; \
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
MAKEROOT(tfp->fp_rd);
|
|
|
|
MAKEROOT(tfp->fp_wd);
|
- 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
|
|
|
}
|
2008-12-11 15:45:31 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(root_node);
|
|
|
|
unlock_vmnt(new_vmp);
|
|
|
|
have_root++; /* We have a (new) root */
|
|
|
|
unlock_bsf();
|
- 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(OK);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* File types may not conflict. */
|
2010-01-13 00:08:50 +01:00
|
|
|
mdir = ((vp->v_mode & I_TYPE) == I_DIRECTORY); /*TRUE iff dir*/
|
|
|
|
rdir = ((root_node->v_mode & I_TYPE) == I_DIRECTORY);
|
|
|
|
if (!mdir && rdir) r = EISDIR;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* If error, return the super block and both inodes; release the vmnt. */
|
|
|
|
if (r != OK) {
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vnode(root_node);
|
2012-02-22 14:54:35 +01:00
|
|
|
mark_vmnt_free(new_vmp);
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vmnt(new_vmp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
put_vnode(vp);
|
|
|
|
put_vnode(root_node);
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_bsf();
|
- 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
|
|
|
}
|
|
|
|
|
|
|
|
/* Nothing else can go wrong. Perform the mount. */
|
2012-02-13 16:28:04 +01:00
|
|
|
new_vmp->m_mounted_on = vp;
|
|
|
|
new_vmp->m_root_node = root_node;
|
|
|
|
strcpy(new_vmp->m_label, mount_label);
|
2010-01-13 00:08:50 +01:00
|
|
|
|
|
|
|
/* Allocate the pseudo device that was found, if not using a real device. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (is_nonedev(dev)) alloc_nonedev(dev);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2011-03-25 11:56:43 +01:00
|
|
|
/* The new FS will handle block I/O requests for its device now. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (!(new_vmp->m_flags & VMNT_FORCEROOTBSF))
|
|
|
|
update_bspec(dev, fs_e, 0 /* Don't send new driver endpoint */);
|
|
|
|
|
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vnode(root_node);
|
|
|
|
unlock_vmnt(new_vmp);
|
|
|
|
unlock_bsf();
|
- 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
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* mount_pfs *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void mount_pfs(void)
|
2012-02-13 16:28:04 +01:00
|
|
|
{
|
|
|
|
/* Mount the Pipe File Server. It's not really mounted onto the file system,
|
|
|
|
but it's necessary it has a vmnt entry to make locking easier */
|
|
|
|
|
|
|
|
dev_t dev;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
struct fproc *rfp;
|
|
|
|
|
|
|
|
if ((dev = find_free_nonedev()) == NO_DEV)
|
|
|
|
panic("VFS: no nonedev to initialize PFS");
|
|
|
|
|
|
|
|
if ((vmp = get_free_vmnt()) == NULL)
|
|
|
|
panic("VFS: no vmnt to initialize PFS");
|
|
|
|
|
|
|
|
alloc_nonedev(dev);
|
|
|
|
|
|
|
|
vmp->m_dev = dev;
|
|
|
|
vmp->m_fs_e = PFS_PROC_NR;
|
|
|
|
strcpy(vmp->m_label, "pfs");
|
|
|
|
|
|
|
|
rfp = &fproc[_ENDPOINT_P(PFS_PROC_NR)];
|
|
|
|
rfp->fp_flags |= FP_SYS_PROC; /* PFS is a driver and an FS */
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_umount *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_umount(void)
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2012-04-13 14:50:38 +02:00
|
|
|
/* Perform the umount(name) system call.
|
|
|
|
* syscall might provide 'name' embedded in the message.
|
|
|
|
*/
|
2010-01-13 00:08:50 +01:00
|
|
|
char label[LABEL_MAX];
|
2006-10-25 15:40:36 +02:00
|
|
|
dev_t dev;
|
2010-01-13 00:08:50 +01:00
|
|
|
int r;
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
2012-04-13 14:50:38 +02:00
|
|
|
vir_bytes vname;
|
|
|
|
size_t vname_length;
|
|
|
|
|
|
|
|
vname = (vir_bytes) job_m_in.name;
|
|
|
|
vname_length = (size_t) job_m_in.name_length;
|
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
|
|
|
/* Only the super-user may do umount. */
|
2006-10-25 15:40:36 +02:00
|
|
|
if (!super_user) return(EPERM);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
/* If 'name' is not for a block special file or mountpoint, return error. */
|
2012-04-13 14:50:38 +02:00
|
|
|
if (copy_name(vname_length, fullpath) != OK) {
|
|
|
|
/* Direct copy failed, try fetching from user space */
|
|
|
|
if (fetch_name(vname, vname_length, fullpath) != OK)
|
|
|
|
return(err_code);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((dev = name_to_dev(TRUE /*allow_mountpt*/, fullpath)) == NO_DEV)
|
|
|
|
return(err_code);
|
2010-01-13 00:08:50 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = unmount(dev, label)) != OK) return(r);
|
2010-01-13 00:08:50 +01:00
|
|
|
|
|
|
|
/* Return the label of the mounted file system, so that the caller
|
|
|
|
* can shut down the corresponding server process.
|
|
|
|
*/
|
|
|
|
if (strlen(label) >= M3_LONG_STRING) /* should never evaluate to true */
|
|
|
|
label[M3_LONG_STRING-1] = 0;
|
|
|
|
strcpy(m_out.umount_label, label);
|
|
|
|
return(OK);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* unmount *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int unmount(
|
2010-04-13 12:58:41 +02:00
|
|
|
dev_t dev, /* block-special device */
|
|
|
|
char *label /* buffer to retrieve label, or NULL */
|
|
|
|
)
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2010-04-01 15:25:05 +02:00
|
|
|
struct vnode *vp;
|
2007-01-16 14:57:35 +01:00
|
|
|
struct vmnt *vmp_i = NULL, *vmp = NULL;
|
2012-02-13 16:28:04 +01:00
|
|
|
int count, locks, 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
|
|
|
/* Find vmnt that is to be unmounted */
|
2012-02-13 16:28:04 +01:00
|
|
|
for (vmp_i = &vmnt[0]; vmp_i < &vmnt[NR_MNTS]; ++vmp_i) {
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (vmp_i->m_dev == dev) {
|
2010-03-05 16:05:11 +01:00
|
|
|
if(vmp) panic("device mounted more than once: %d", dev);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
vmp = vmp_i;
|
|
|
|
}
|
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
|
|
|
/* Did we find the vmnt (i.e., was dev a mounted device)? */
|
|
|
|
if(!vmp) return(EINVAL);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
if ((r = lock_vmnt(vmp, VMNT_EXCL)) != OK) return(r);
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* See if the mounted device is busy. Only 1 vnode using it should be
|
- 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
|
|
|
* open -- the root vnode -- and that inode only 1 time. */
|
2012-02-13 16:28:04 +01:00
|
|
|
locks = count = 0;
|
|
|
|
for (vp = &vnode[0]; vp < &vnode[NR_VNODES]; vp++)
|
|
|
|
if (vp->v_ref_count > 0 && vp->v_dev == dev) {
|
|
|
|
count += vp->v_ref_count;
|
|
|
|
if (is_vnode_locked(vp)) locks++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count > 1 || locks > 1 || tll_haspendinglock(&vmp->m_lock)) {
|
|
|
|
unlock_vmnt(vmp);
|
|
|
|
return(EBUSY); /* can't umount a busy file system */
|
|
|
|
}
|
2009-01-26 18:43:59 +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
|
|
|
/* Tell FS to drop all inode references for root inode except 1. */
|
2007-01-05 17:36:55 +01:00
|
|
|
vnode_clean_refs(vmp->m_root_node);
|
2010-01-13 00:08:50 +01:00
|
|
|
|
2009-01-26 18:43:59 +01:00
|
|
|
if (vmp->m_mounted_on) {
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
put_vnode(vmp->m_mounted_on);
|
2010-05-10 15:26:00 +02:00
|
|
|
vmp->m_mounted_on = NULL;
|
2009-01-26 18:43:59 +01:00
|
|
|
}
|
2010-01-13 00:08:50 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
vmp->m_comm.c_max_reqs = 1; /* Force max concurrent reqs to just one, so
|
|
|
|
* we won't send any messages after the
|
|
|
|
* unmount request */
|
2009-01-26 18:43:59 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Tell FS to unmount */
|
- 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_unmount(vmp->m_fs_e)) != OK) /* Not recoverable. */
|
2012-02-13 16:28:04 +01:00
|
|
|
printf("VFS: ignoring failed umount attempt FS endpoint: %d (%d)\n",
|
|
|
|
vmp->m_fs_e, r);
|
|
|
|
|
|
|
|
if (is_nonedev(vmp->m_dev)) free_nonedev(vmp->m_dev);
|
|
|
|
|
|
|
|
if (label != NULL) strcpy(label, vmp->m_label);
|
|
|
|
|
|
|
|
if (vmp->m_root_node) { /* PFS lacks a root node */
|
|
|
|
vmp->m_root_node->v_ref_count = 0;
|
|
|
|
vmp->m_root_node->v_fs_count = 0;
|
|
|
|
vmp->m_root_node->v_sdev = NO_DEV;
|
|
|
|
vmp->m_root_node = NULL;
|
|
|
|
}
|
2012-02-22 14:54:35 +01:00
|
|
|
mark_vmnt_free(vmp);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vmnt(vmp);
|
|
|
|
|
|
|
|
/* The root FS will handle block I/O requests for this device now. */
|
|
|
|
lock_bsf();
|
|
|
|
update_bspec(dev, ROOT_FS_E, 1 /* send new driver endpoint */);
|
|
|
|
unlock_bsf();
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* unmount_all *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void unmount_all(void)
|
2012-02-13 16:28:04 +01:00
|
|
|
{
|
|
|
|
/* Unmount all filesystems. File systems are mounted on other file systems,
|
|
|
|
* so you have to pull off the loose bits repeatedly to get it all undone.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int i;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
|
|
|
|
/* Now unmount the rest */
|
|
|
|
for (i = 0; i < NR_MNTS; i++) {
|
|
|
|
/* Unmount at least one. */
|
|
|
|
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; vmp++) {
|
|
|
|
if (vmp->m_dev != NO_DEV)
|
|
|
|
unmount(vmp->m_dev, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
check_vnode_locks();
|
|
|
|
check_vmnt_locks();
|
|
|
|
check_filp_locks();
|
|
|
|
check_bsf_lock();
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* name_to_dev *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static dev_t name_to_dev(int allow_mountpt, char path[PATH_MAX])
|
2006-10-25 15:40:36 +02:00
|
|
|
{
|
2010-01-13 00:08:50 +01:00
|
|
|
/* Convert the block special file in 'user_fullpath' to a device number.
|
|
|
|
* If the given path is not a block special file, but 'allow_mountpt' is set
|
|
|
|
* and the path is the root node of a mounted file system, return that device
|
|
|
|
* number. In all other cases, return NO_DEV and an error code in 'err_code'.
|
|
|
|
*/
|
2007-08-07 14:52:47 +02:00
|
|
|
dev_t dev;
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
|
|
|
struct lookup resolve;
|
|
|
|
|
|
|
|
lookup_init(&resolve, path, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Request lookup */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) return(NO_DEV);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
if ((vp->v_mode & I_TYPE) == I_BLOCK_SPECIAL) {
|
|
|
|
dev = vp->v_sdev;
|
|
|
|
} else if (allow_mountpt && vp->v_vmnt->m_root_node == vp) {
|
|
|
|
dev = vp->v_dev;
|
|
|
|
} else {
|
2012-02-13 16:28:04 +01:00
|
|
|
err_code = ENOTBLK;
|
- 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
|
|
|
dev = NO_DEV;
|
2010-01-13 00:08:50 +01:00
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vnode(vp);
|
|
|
|
unlock_vmnt(vmp);
|
2007-08-07 14:52:47 +02:00
|
|
|
put_vnode(vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(dev);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
2010-01-13 00:08:50 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* is_nonedev *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int is_nonedev(dev_t dev)
|
2010-01-13 00:08:50 +01:00
|
|
|
{
|
|
|
|
/* Return whether the given device is a "none" pseudo device.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return (major(dev) == NONE_MAJOR &&
|
|
|
|
minor(dev) > 0 && minor(dev) <= NR_NONEDEVS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* find_free_nonedev *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static dev_t find_free_nonedev(void)
|
2010-01-13 00:08:50 +01:00
|
|
|
{
|
|
|
|
/* Find a free "none" pseudo device. Do not allocate it yet.
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NR_NONEDEVS; i++)
|
|
|
|
if (!GET_BIT(nonedev, i))
|
|
|
|
return makedev(NONE_MAJOR, i + 1);
|
|
|
|
|
|
|
|
err_code = EMFILE;
|
|
|
|
return NO_DEV;
|
|
|
|
}
|