diff --git a/servers/vfs/comm.c b/servers/vfs/comm.c index 41760827f..1b6dd6c40 100644 --- a/servers/vfs/comm.c +++ b/servers/vfs/comm.c @@ -121,15 +121,16 @@ int drv_sendrec(endpoint_t drv_e, message *reqmp) /*===========================================================================* * fs_sendrec * *===========================================================================*/ -int fs_sendrec(endpoint_t fs_e, message *reqmp) +int fs_sendrec(struct vmnt *vmp, message *reqmp) { - struct vmnt *vmp; + endpoint_t fs_e; int r; - if ((vmp = find_vmnt(fs_e)) == NULL) { - printf("Trying to talk to non-existent FS endpoint %d\n", fs_e); + if (vmp == NULL) { + printf("Trying to talk to non-existent FS\n"); return(EIO); } + fs_e = vmp->m_fs_e; if (fs_e == fp->fp_endpoint) return(EDEADLK); self->w_fs_sendrec = reqmp; /* Where to store request and reply */ diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 2ef5c9bf0..48691cdc5 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -908,8 +908,9 @@ int clone_opcl( dev = makedev(major(dev), minor(dev_mess.REP_STATUS)); /* Issue request */ - r = req_newnode(PFS_PROC_NR, fp->fp_effuid, fp->fp_effgid, - ALL_MODES | I_CHAR_SPECIAL, dev, &res); + r = req_newnode(find_vmnt(PFS_PROC_NR), fp->fp_effuid, + fp->fp_effgid, ALL_MODES | I_CHAR_SPECIAL, dev, + &res); if (r != OK) { (void) clone_opcl(DEV_CLOSE, dev, proc_e, 0); return r; @@ -925,9 +926,8 @@ int clone_opcl( put_vnode(fp->fp_filp[scratch(fp).file.fd_nr]->filp_vno); vp->v_fs_e = res.fs_e; - vp->v_vmnt = NULL; + vp->v_vmnt = find_vmnt(vp->v_fs_e); vp->v_dev = NO_DEV; - vp->v_fs_e = res.fs_e; vp->v_inode_nr = res.inode_nr; vp->v_mode = res.fmode; vp->v_sdev = dev; @@ -985,7 +985,7 @@ void bdev_up(int maj) if (major(vmp->m_dev) != maj) continue; /* Send the driver label to the mounted file system. */ - if (OK != req_newdriver(vmp->m_fs_e, vmp->m_dev, label)) + if (OK != req_newdriver(vmp, vmp->m_dev, label)) printf("VFS dev_up: error sending new driver label to %d\n", vmp->m_fs_e); } @@ -996,7 +996,7 @@ void bdev_up(int maj) * because it is more work to check for that case. */ if (found) { - if (OK != req_newdriver(ROOT_FS_E, makedev(maj, 0), label)) + if (OK != req_newdriver(find_vmnt(ROOT_FS_E), makedev(maj, 0), label)) printf("VFSdev_up: error sending new driver label to %d\n", ROOT_FS_E); } diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index daad6a2fb..38b0cccaf 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -155,7 +155,7 @@ static int get_read_vp(struct vfs_exec_info *execi, else if ((r = forbidden(fp, execi->vp, X_BIT)) != OK) return r; else - r = req_stat(execi->vp->v_fs_e, execi->vp->v_inode_nr, + r = req_stat(execi->vp->v_vmnt, execi->vp->v_inode_nr, VFS_PROC_NR, (vir_bytes) &(execi->sb)); if (r != OK) return r; @@ -499,7 +499,7 @@ char path[PATH_MAX]; /* path to script file */ pos = 0; /* Read from the start of the file */ /* Issue request */ - r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(pos), READING, + r = req_readwrite(vp->v_vmnt, vp->v_inode_nr, cvul64(pos), READING, VFS_PROC_NR, buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io); if (r != OK) return(r); @@ -624,11 +624,11 @@ static int read_seg(struct exec_info *execi, off_t off, off_t seg_addr, size_t s if (off + seg_bytes > LONG_MAX) return(EIO); if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO); - if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(off), READING, + if ((r = req_readwrite(vp->v_vmnt, vp->v_inode_nr, cvul64(off), READING, execi->proc_e, (char*)seg_addr, seg_bytes, &new_pos, &cum_io)) != OK) { - printf("VFS: read_seg: req_readwrite failed (data)\n"); - return(r); + printf("VFS: read_seg: req_readwrite failed (data)\n"); + return(r); } if (r == OK && cum_io != seg_bytes) @@ -670,7 +670,7 @@ static int map_header(struct vfs_exec_info *execi) execi->args.hdr_len = MIN(execi->vp->v_size, sizeof(hdr)); execi->args.hdr = hdr; - r = req_readwrite(execi->vp->v_fs_e, execi->vp->v_inode_nr, + r = req_readwrite(execi->vp->v_vmnt, execi->vp->v_inode_nr, cvul64(pos), READING, VFS_PROC_NR, hdr, execi->args.hdr_len, &new_pos, &cum_io); if (r != OK) { diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index 1ccdb8eb9..f4aad67ab 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -631,7 +631,7 @@ struct filp *f; * mounted. Assume that the root filesystem's * is open only for fsck. */ - req_flush(vp->v_bfs_e, dev); + req_flush(find_vmnt(vp->v_bfs_e), dev); } unlock_bsf(); diff --git a/servers/vfs/link.c b/servers/vfs/link.c index 8ffc03ee0..fbbadf765 100644 --- a/servers/vfs/link.c +++ b/servers/vfs/link.c @@ -76,7 +76,7 @@ int do_link(message *UNUSED(m_out)) r = forbidden(fp, dirp, W_BIT | X_BIT); if (r == OK) - r = req_link(vp->v_fs_e, dirp->v_inode_nr, fullpath, + r = req_link(vp->v_vmnt, dirp->v_inode_nr, fullpath, vp->v_inode_nr); unlock_vnode(vp); @@ -164,9 +164,10 @@ int do_unlink(message *UNUSED(m_out)) upgrade_vmnt_lock(vmp); if (job_call_nr == UNLINK) - r = req_unlink(dirp->v_fs_e, dirp->v_inode_nr, fullpath); + r = req_unlink(dirp->v_vmnt, dirp->v_inode_nr, fullpath); else - r = req_rmdir(dirp->v_fs_e, dirp->v_inode_nr, fullpath); + r = req_rmdir(dirp->v_vmnt, dirp->v_inode_nr, fullpath); + unlock_vnode(dirp); unlock_vmnt(vmp); put_vnode(dirp); @@ -265,7 +266,7 @@ int do_rename(message *UNUSED(m_out)) if (r == OK) { upgrade_vmnt_lock(oldvmp); /* Upgrade to exclusive access */ - r = req_rename(old_dirp->v_fs_e, old_dirp->v_inode_nr, old_name, + r = req_rename(old_dirp->v_vmnt, old_dirp->v_inode_nr, old_name, new_dirp->v_inode_nr, fullpath); } @@ -386,7 +387,7 @@ off_t newsize; * 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. */ - if ((r = req_ftrunc(vp->v_fs_e, vp->v_inode_nr, newsize, 0)) == OK) + if ((r = req_ftrunc(vp->v_vmnt, vp->v_inode_nr, newsize, 0)) == OK) vp->v_size = newsize; return(r); } @@ -422,7 +423,7 @@ int do_slink(message *UNUSED(m_out)) if (fetch_name(vname2, vname2_length, fullpath) != OK) return(err_code); if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code); if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) { - r = req_slink(vp->v_fs_e, vp->v_inode_nr, fullpath, who_e, + r = req_slink(vp->v_vmnt, vp->v_inode_nr, fullpath, who_e, vname1, vname1_length - 1, fp->fp_effuid, fp->fp_effgid); } @@ -462,7 +463,7 @@ struct fproc *rfp; if (!S_ISLNK(vp->v_mode)) r = EINVAL; else - r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, NONE, (vir_bytes) link_path, + r = req_rdlink(vp->v_vmnt, vp->v_inode_nr, NONE, (vir_bytes) link_path, PATH_MAX - 1, 1); if (r > 0) link_path[r] = '\0'; /* Terminate string when succesful */ @@ -507,7 +508,7 @@ int do_rdlink(message *UNUSED(m_out)) if (!S_ISLNK(vp->v_mode)) r = EINVAL; else - r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, who_e, buf, buf_size, 0); + r = req_rdlink(vp->v_vmnt, vp->v_inode_nr, who_e, buf, buf_size, 0); unlock_vnode(vp); unlock_vmnt(vmp); diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 78c5dd599..7afefd9da 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -225,7 +225,7 @@ int do_fcntl(message *UNUSED(m_out)) } if (r != OK) break; - r = req_ftrunc(f->filp_vno->v_fs_e, f->filp_vno->v_inode_nr,start,end); + r = req_ftrunc(f->filp_vno->v_vmnt, f->filp_vno->v_inode_nr,start,end); if (r == OK && flock_arg.l_len == 0) f->filp_vno->v_size = start; @@ -261,7 +261,7 @@ sync_fses(void) break; if (vmp->m_dev != NO_DEV && vmp->m_fs_e != NONE && vmp->m_root_node != NULL) { - req_sync(vmp->m_fs_e); + req_sync(vmp); } unlock_vmnt(vmp); } @@ -303,7 +303,7 @@ int do_fsync(message *UNUSED(m_out)) if (vmp->m_dev != NO_DEV && vmp->m_dev == dev && vmp->m_fs_e != NONE && vmp->m_root_node != NULL) { - req_sync(vmp->m_fs_e); + req_sync(vmp); } unlock_vmnt(vmp); } diff --git a/servers/vfs/mount.c b/servers/vfs/mount.c index 51517ef46..23d809d44 100644 --- a/servers/vfs/mount.c +++ b/servers/vfs/mount.c @@ -73,7 +73,7 @@ static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e) continue; } - if ((r = req_newdriver(fs_e, vp->v_sdev, + if ((r = req_newdriver(find_vmnt(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", @@ -210,8 +210,14 @@ char mount_label[LABEL_MAX] ) } if ((r = lock_vmnt(new_vmp, VMNT_EXCL)) != OK) return(r); + /* 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; strlcpy(new_vmp->m_mount_path, mount_path, PATH_MAX); strlcpy(new_vmp->m_mount_dev, mount_dev, PATH_MAX); + isroot = (strcmp(mount_path, "/") == 0); mount_root = (isroot && have_root < 2); /* Root can be mounted twice: * 1: ramdisk @@ -227,7 +233,7 @@ char mount_label[LABEL_MAX] ) 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); + r = req_mountpoint(vp->v_vmnt, vp->v_inode_nr); } else r = EBUSY; @@ -271,15 +277,9 @@ char mount_label[LABEL_MAX] ) rfp = &fproc[slot]; rfp->fp_flags |= FP_SRV_PROC; /* File Servers are also services */ - /* 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; - /* Tell FS which device to mount */ new_vmp->m_flags |= VMNT_MOUNTING; - r = req_readsuper(fs_e, label, dev, rdonly, isroot, &res, &con_reqs); + r = req_readsuper(new_vmp, label, dev, rdonly, isroot, &res, &con_reqs); new_vmp->m_flags &= ~VMNT_MOUNTING; if (r != OK) { @@ -505,7 +505,7 @@ int unmount( * unmount request */ /* Tell FS to unmount */ - if ((r = req_unmount(vmp->m_fs_e)) != OK) /* Not recoverable. */ + if ((r = req_unmount(vmp)) != OK) /* Not recoverable. */ printf("VFS: ignoring failed umount attempt FS endpoint: %d (%d)\n", vmp->m_fs_e, r); diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 36b722660..6a6e0676a 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -205,7 +205,7 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode) break; } - if (req_newdriver(vp->v_bfs_e, vp->v_sdev, + if (req_newdriver(find_vmnt(vp->v_bfs_e), vp->v_sdev, dp->dmap_label) != OK) { printf("VFS: error sending driver label\n"); bdev_close(dev); @@ -349,7 +349,7 @@ static struct vnode *new_node(struct lookup *resolve, int oflags, mode_t bits) upgrade_vmnt_lock(dir_vmp); /* Creating file, need exclusive access */ if ((r = forbidden(fp, dirp, W_BIT|X_BIT)) != OK || - (r = req_create(dirp->v_fs_e, dirp->v_inode_nr,bits, fp->fp_effuid, + (r = req_create(dirp->v_vmnt, dirp->v_inode_nr,bits, fp->fp_effuid, fp->fp_effgid, path, &res)) != OK ) { /* Can't create inode either due to permissions or some other * problem. In case r is EEXIST, we might be dealing with a @@ -371,7 +371,7 @@ static struct vnode *new_node(struct lookup *resolve, int oflags, mode_t bits) if (S_ISLNK(slp->v_mode)) { /* Get contents of link */ - r = req_rdlink(slp->v_fs_e, + r = req_rdlink(slp->v_vmnt, slp->v_inode_nr, VFS_PROC_NR, (vir_bytes) path, @@ -535,7 +535,7 @@ int do_mknod(message *UNUSED(m_out)) if (!S_ISDIR(vp->v_mode)) { r = ENOTDIR; } else if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) { - r = req_mknod(vp->v_fs_e, vp->v_inode_nr, fullpath, fp->fp_effuid, + r = req_mknod(vp->v_vmnt, vp->v_inode_nr, fullpath, fp->fp_effuid, fp->fp_effgid, bits, dev); } @@ -577,7 +577,7 @@ int do_mkdir(message *UNUSED(m_out)) if (!S_ISDIR(vp->v_mode)) { r = ENOTDIR; } else if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) { - r = req_mkdir(vp->v_fs_e, vp->v_inode_nr, fullpath, fp->fp_effuid, + r = req_mkdir(vp->v_vmnt, vp->v_inode_nr, fullpath, fp->fp_effuid, fp->fp_effgid, bits); } @@ -637,7 +637,7 @@ int do_lseek(message *m_out) rfilp->filp_pos = newpos; /* Inhibit read ahead request */ - r = req_inhibread(rfilp->filp_vno->v_fs_e, + r = req_inhibread(rfilp->filp_vno->v_vmnt, rfilp->filp_vno->v_inode_nr); } } @@ -695,7 +695,7 @@ int do_llseek(message *m_out) rfilp->filp_pos = newpos; /* Inhibit read ahead request */ - r = req_inhibread(rfilp->filp_vno->v_fs_e, + r = req_inhibread(rfilp->filp_vno->v_vmnt, rfilp->filp_vno->v_inode_nr); } } diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 3d94215db..5df38e10c 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -280,7 +280,7 @@ struct fproc *rfp; break; } - r = req_rdlink(sym_vp->v_fs_e, sym_vp->v_inode_nr, NONE, + r = req_rdlink(sym_vp->v_vmnt, sym_vp->v_inode_nr, NONE, (vir_bytes) resolve->l_path, PATH_MAX - 1, 1); if (r < 0) { @@ -406,7 +406,7 @@ struct fproc *rfp; uid_t uid; gid_t gid; struct vnode *dir_vp; - struct vmnt *vmp, *vmpres; + struct vmnt *vmp, *vmpres, *sendvmp; struct lookup_res res; tll_access_t mnt_lock_type; @@ -428,7 +428,7 @@ struct fproc *rfp; fs_e = start_node->v_fs_e; dir_ino = start_node->v_inode_nr; - vmpres = find_vmnt(fs_e); + sendvmp = vmpres = find_vmnt(fs_e); if (vmpres == NULL) return(EIO); /* mountpoint vanished? */ @@ -460,7 +460,7 @@ struct fproc *rfp; *(resolve->l_vmp) = vmpres; /* Issue the request */ - r = req_lookup(fs_e, dir_ino, root_ino, uid, gid, resolve, &res, rfp); + r = req_lookup(sendvmp, dir_ino, root_ino, uid, gid, resolve, &res, rfp); if (r != OK && r != EENTERMOUNT && r != ELEAVEMOUNT && r != ESYMLINK) { if (vmpres) unlock_vmnt(vmpres); @@ -546,7 +546,7 @@ struct fproc *rfp; /* Unlock a previously locked vmnt if locked and lock new vmnt */ if (vmpres) unlock_vmnt(vmpres); - vmpres = find_vmnt(fs_e); + sendvmp = vmpres = find_vmnt(fs_e); if (vmpres == NULL) return(EIO); /* mount point vanished? */ if ((r = lock_vmnt(vmpres, mnt_lock_type)) != OK) { if (r == EBUSY) @@ -556,7 +556,7 @@ struct fproc *rfp; } *(resolve->l_vmp) = vmpres; - r = req_lookup(fs_e, dir_ino, root_ino, uid, gid, resolve, &res, rfp); + r = req_lookup(sendvmp, dir_ino, root_ino, uid, gid, resolve, &res,rfp); if (r != OK && r != EENTERMOUNT && r != ELEAVEMOUNT && r != ESYMLINK) { if (vmpres) unlock_vmnt(vmpres); @@ -625,7 +625,7 @@ char ename[NAME_MAX + 1]; if (!S_ISDIR(dirp->v_mode)) return(EBADF); do { - r = req_getdents(dirp->v_fs_e, dirp->v_inode_nr, pos, buf, sizeof(buf), + r = req_getdents(dirp->v_vmnt, dirp->v_inode_nr, pos, buf, sizeof(buf), &new_pos, 1); if (r == 0) { diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index a6cc0f9e0..e6dcfc8e4 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -123,7 +123,7 @@ static int create_pipe(int fil_des[2], int flags) fil_ptr1->filp_count = 1; /* Create a named pipe inode on PipeFS */ - r = req_newnode(PFS_PROC_NR, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE, + r = req_newnode(vmp, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE, NO_DEV, &res); if (r != OK) { @@ -150,7 +150,8 @@ static int create_pipe(int fil_des[2], int flags) vp->v_mapfs_count = 1; vp->v_ref_count = 1; vp->v_size = 0; - vp->v_vmnt = NULL; + vp->v_vmnt = find_vmnt(res.fs_e); + assert(vp->v_vmnt == find_vmnt(PFS_PROC_NR)); vp->v_dev = NO_DEV; /* Fill in filp objects */ @@ -178,7 +179,7 @@ int map_vnode(vp, map_to_fs_e) struct vnode *vp; endpoint_t map_to_fs_e; { - int r; + int r, do_unlock = 1; struct vmnt *vmp; struct node_details res; @@ -188,7 +189,7 @@ endpoint_t map_to_fs_e; panic("Can't map to unknown endpoint"); if ((r = lock_vmnt(vmp, VMNT_WRITE)) != OK) { if (r == EBUSY) - vmp = NULL; /* Already locked, do not unlock */ + do_unlock = 0; /* Already locked, do not unlock */ else return(r); @@ -197,14 +198,14 @@ endpoint_t map_to_fs_e; /* Create a temporary mapping of this inode to another FS. Read and write * operations on data will be handled by that FS. The rest by the 'original' * FS that holds the inode. */ - if ((r = req_newnode(map_to_fs_e, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE, + if ((r = req_newnode(vmp, fp->fp_effuid, fp->fp_effgid, I_NAMED_PIPE, vp->v_dev, &res)) == OK) { vp->v_mapfs_e = res.fs_e; vp->v_mapinode_nr = res.inode_nr; vp->v_mapfs_count = 1; } - if (vmp) unlock_vmnt(vmp); + if (do_unlock) unlock_vmnt(vmp); return(r); } diff --git a/servers/vfs/protect.c b/servers/vfs/protect.c index 4f76bc9e2..b0925927b 100644 --- a/servers/vfs/protect.c +++ b/servers/vfs/protect.c @@ -83,7 +83,7 @@ int do_chmod(message *UNUSED(m_out)) if (fp->fp_effuid != SU_UID && vp->v_gid != fp->fp_effgid) new_mode &= ~I_SET_GID_BIT; - r = req_chmod(vp->v_fs_e, vp->v_inode_nr, new_mode, &result_mode); + r = req_chmod(vp->v_vmnt, vp->v_inode_nr, new_mode, &result_mode); if (r == OK) vp->v_mode = result_mode; } @@ -163,7 +163,7 @@ int do_chown(message *UNUSED(m_out)) if (new_uid > UID_MAX || new_gid > GID_MAX) r = EINVAL; - else if ((r = req_chown(vp->v_fs_e, vp->v_inode_nr, new_uid, new_gid, + else if ((r = req_chown(vp->v_vmnt, vp->v_inode_nr, new_uid, new_gid, &new_mode)) == OK) { vp->v_uid = new_uid; vp->v_gid = new_gid; diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 8ea43dc5d..d53b48317 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -24,7 +24,7 @@ typedef struct filp * filp_id_t; /* comm.c */ int drv_sendrec(endpoint_t drv_e, message *reqm); void fs_cancel(struct vmnt *vmp); -int fs_sendrec(endpoint_t fs_e, message *reqm); +int fs_sendrec(struct vmnt *vmp, message *reqm); void fs_sendmore(struct vmnt *vmp); void send_work(void); @@ -219,53 +219,54 @@ int rw_pipe(int rw_flag, endpoint_t usr, struct filp *f, char *buf, size_t req_size); /* request.c */ -int req_breadwrite(endpoint_t fs_e, endpoint_t user_e, dev_t dev, u64_t pos, +int req_breadwrite(struct vmnt *vmp, endpoint_t user_e, dev_t dev, u64_t pos, unsigned int num_of_bytes, char *user_addr, int rw_flag, u64_t *new_posp, unsigned int *cum_iop); -int req_chmod(int fs_e, ino_t inode_nr, mode_t rmode, mode_t *new_modep); -int req_chown(endpoint_t fs_e, ino_t inode_nr, uid_t newuid, gid_t newgid, +int req_chmod(struct vmnt *vmp, ino_t inode_nr, mode_t rmode, mode_t *newmodep); +int req_chown(struct vmnt *vmp, ino_t inode_nr, uid_t newuid, gid_t newgid, mode_t *new_modep); -int req_create(int fs_e, ino_t inode_nr, int omode, uid_t uid, gid_t gid, - char *path, node_details_t *res); -int req_flush(endpoint_t fs_e, dev_t dev); -int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf); -int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf); -int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end); -int req_getdents(endpoint_t fs_e, ino_t inode_nr, u64_t pos, char *buf, +int req_create(struct vmnt *vmp, ino_t inode_nr, int omode, uid_t uid, + gid_t gid, char *path, node_details_t *res); +int req_flush(struct vmnt *vmp, dev_t dev); +int req_fstatfs(struct vmnt *vmp, endpoint_t proc_e, vir_bytes buf); +int req_statvfs(struct vmnt *vmp, endpoint_t proc_e, vir_bytes buf); +int req_ftrunc(struct vmnt *vmp, ino_t inode_nr, off_t start, off_t end); +int req_getdents(struct vmnt *vmp, ino_t inode_nr, u64_t pos, char *buf, size_t size, u64_t *new_pos, int direct); -int req_inhibread(endpoint_t fs_e, ino_t inode_nr); -int req_link(endpoint_t fs_e, ino_t link_parent, char *lastc, +int req_inhibread(struct vmnt *vmp, ino_t inode_nr); +int req_link(struct vmnt *vmp, ino_t link_parent, char *lastc, ino_t linked_file); -int req_lookup(endpoint_t fs_e, ino_t dir_ino, ino_t root_ino, uid_t uid, +int req_lookup(struct vmnt *vmp, ino_t dir_ino, ino_t root_ino, uid_t uid, gid_t gid, struct lookup *resolve, lookup_res_t *res, struct fproc *rfp); -int req_mkdir(endpoint_t fs_e, ino_t inode_nr, char *lastc, uid_t uid, +int req_mkdir(struct vmnt *vmp, ino_t inode_nr, char *lastc, uid_t uid, gid_t gid, mode_t dmode); -int req_mknod(endpoint_t fs_e, ino_t inode_nr, char *lastc, uid_t uid, +int req_mknod(struct vmnt *vmp, ino_t inode_nr, char *lastc, uid_t uid, gid_t gid, mode_t dmode, dev_t dev); -int req_mountpoint(endpoint_t fs_e, ino_t inode_nr); -int req_newnode(endpoint_t fs_e, uid_t uid, gid_t gid, mode_t dmode, dev_t dev, +int req_mountpoint(struct vmnt *vmp, ino_t inode_nr); +int req_newnode(struct vmnt *vmp, uid_t uid, gid_t gid, mode_t dmode, dev_t dev, struct node_details *res); -int req_putnode(int fs_e, ino_t inode_nr, int count); -int req_rdlink(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, +int req_putnode(struct vmnt *vmp, ino_t inode_nr, int count); +int req_rdlink(struct vmnt *vmp, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf, size_t len, int direct); -int req_readsuper(endpoint_t fs_e, char *driver_name, dev_t dev, int readonly, +int req_readsuper(struct vmnt *vmp, char *driver_name, dev_t dev, int readonly, int isroot, struct node_details *res_nodep, int *con_reqs); -int req_readwrite(endpoint_t fs_e, ino_t inode_nr, u64_t pos, int rw_flag, +int req_readwrite(struct vmnt *vmp, ino_t inode_nr, u64_t pos, int rw_flag, endpoint_t user_e, char *user_addr, unsigned int num_of_bytes, u64_t *new_posp, unsigned int *cum_iop); -int req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir, +int req_rename(struct vmnt *vmp, ino_t old_dir, char *old_name, ino_t new_dir, char *new_name); -int req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc); -int req_slink(endpoint_t fs_e, ino_t inode_nr, char *lastc, endpoint_t proc_e, +int req_rmdir(struct vmnt *vmp, ino_t inode_nr, char *lastc); +int req_slink(struct vmnt *vmp, ino_t inode_nr, char *lastc, endpoint_t proc_e, vir_bytes path_addr, size_t path_length, uid_t uid, gid_t gid); -int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf); -int req_sync(endpoint_t fs_e); -int req_unlink(endpoint_t fs_e, ino_t inode_nr, char *lastc); -int req_unmount(endpoint_t fs_e); -int req_utime(endpoint_t fs_e, ino_t inode_nr, struct timespec * actv, +int req_stat(struct vmnt *vmp, ino_t inode_nr, endpoint_t proc_e, + vir_bytes buf); +int req_sync(struct vmnt *vmp); +int req_unlink(struct vmnt *vmp, ino_t inode_nr, char *lastc); +int req_unmount(struct vmnt *vmp); +int req_utime(struct vmnt *vmp, ino_t inode_nr, struct timespec * actv, struct timespec * modtv); -int req_newdriver(endpoint_t fs_e, dev_t dev, char *label); +int req_newdriver(struct vmnt *vmp, dev_t dev, char *label); /* stadir.c */ int do_chdir(message *m_out); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index b278738f0..c81d0c8a7 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -174,8 +174,8 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, lock_bsf(); - r = req_breadwrite(vp->v_bfs_e, for_e, vp->v_sdev, position, size, - buf, rw_flag, &res_pos, &res_cum_io); + r = req_breadwrite(find_vmnt(vp->v_bfs_e), for_e, vp->v_sdev, position, + size, buf, rw_flag, &res_pos, &res_cum_io); if (r == OK) { position = res_pos; cum_io += res_cum_io; @@ -189,7 +189,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, } /* Issue request */ - r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, position, rw_flag, for_e, + r = req_readwrite(vp->v_vmnt, vp->v_inode_nr, position, rw_flag, for_e, buf, size, &new_pos, &cum_io_incr); if (r >= 0) { @@ -257,7 +257,7 @@ int do_getdents(message *UNUSED(m_out)) if (ex64hi(rfilp->filp_pos) != 0) panic("do_getdents: can't handle large offsets"); - r = req_getdents(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr, + r = req_getdents(rfilp->filp_vno->v_vmnt, rfilp->filp_vno->v_inode_nr, rfilp->filp_pos, scratch(fp).io.io_buffer, scratch(fp).io.io_nbytes, &new_pos,0); @@ -312,8 +312,8 @@ size_t req_size; if (vp->v_mapfs_e == 0) panic("unmapped pipe"); - r = req_readwrite(vp->v_mapfs_e, vp->v_mapinode_nr, position, rw_flag, usr_e, - buf, size, &new_pos, &cum_io_incr); + r = req_readwrite(find_vmnt(vp->v_mapfs_e), vp->v_mapinode_nr, position, + rw_flag, usr_e, buf, size, &new_pos, &cum_io_incr); if (r != OK) { return(r); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 4eab2791e..a73a650d6 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -29,7 +29,7 @@ * req_breadwrite * *===========================================================================*/ int req_breadwrite( - endpoint_t fs_e, + struct vmnt *vmp, endpoint_t user_e, dev_t dev, u64_t pos, @@ -44,8 +44,8 @@ int req_breadwrite( cp_grant_id_t grant_id; message m; - grant_id = cpf_grant_magic(fs_e, user_e, (vir_bytes) user_addr, num_of_bytes, - (rw_flag == READING ? CPF_WRITE : CPF_READ)); + grant_id = cpf_grant_magic(vmp->m_fs_e, user_e, (vir_bytes) user_addr, + num_of_bytes, (rw_flag == READING ? CPF_WRITE : CPF_READ)); if(grant_id == -1) panic("req_breadwrite: cpf_grant_magic failed"); @@ -58,7 +58,7 @@ int req_breadwrite( m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if (r != OK) return(r); @@ -74,7 +74,7 @@ int req_breadwrite( * req_chmod * *===========================================================================*/ int req_chmod( - int fs_e, + struct vmnt *vmp, ino_t inode_nr, mode_t rmode, mode_t *new_modep @@ -89,7 +89,7 @@ int req_chmod( m.REQ_MODE = rmode; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); /* Copy back actual mode. */ *new_modep = m.RES_MODE; @@ -102,7 +102,7 @@ int req_chmod( * req_chown * *===========================================================================*/ int req_chown( - endpoint_t fs_e, + struct vmnt *vmp, ino_t inode_nr, uid_t newuid, gid_t newgid, @@ -119,7 +119,7 @@ int req_chown( m.REQ_GID = newgid; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); /* Return new mode to caller. */ *new_modep = m.RES_MODE; @@ -132,7 +132,7 @@ int req_chown( * req_create * *===========================================================================*/ int req_create( - int fs_e, + struct vmnt *vmp, ino_t inode_nr, int omode, uid_t uid, @@ -150,7 +150,7 @@ int req_create( panic("req_create: filename starts with '/'"); len = strlen(path) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) path, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) path, len, CPF_READ); if (grant_id == -1) panic("req_create: cpf_grant_direct failed"); @@ -164,7 +164,7 @@ int req_create( m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if (r != OK) return(r); @@ -184,7 +184,7 @@ int req_create( /*===========================================================================* * req_flush * *===========================================================================*/ -int req_flush(endpoint_t fs_e, dev_t dev) +int req_flush(struct vmnt *vmp, dev_t dev) { message m; @@ -193,20 +193,20 @@ int req_flush(endpoint_t fs_e, dev_t dev) m.REQ_DEV = dev; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } /*===========================================================================* * req_fstatfs * *===========================================================================*/ -int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) +int req_fstatfs(struct vmnt *vmp, endpoint_t proc_e, vir_bytes buf) { int r; cp_grant_id_t grant_id; message m; - grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct statfs), + grant_id = cpf_grant_magic(vmp->m_fs_e, proc_e, buf, sizeof(struct statfs), CPF_WRITE); if (grant_id == GRANT_INVALID) panic("req_fstatfs: cpf_grant_magic failed"); @@ -216,7 +216,7 @@ int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) m.REQ_GRANT = grant_id; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -226,13 +226,13 @@ int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) /*===========================================================================* * req_statvfs * *===========================================================================*/ -int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) +int req_statvfs(struct vmnt *vmp, endpoint_t proc_e, vir_bytes buf) { int r; cp_grant_id_t grant_id; message m; - grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct statvfs), + grant_id = cpf_grant_magic(vmp->m_fs_e, proc_e, buf, sizeof(struct statvfs), CPF_WRITE); if(grant_id == GRANT_INVALID) panic("req_statvfs: cpf_grant_magic failed"); @@ -242,7 +242,7 @@ int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) m.REQ_GRANT = grant_id; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -252,7 +252,7 @@ int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) /*===========================================================================* * req_ftrunc * *===========================================================================*/ -int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end) +int req_ftrunc(struct vmnt *vmp, ino_t inode_nr, off_t start, off_t end) { message m; @@ -265,7 +265,7 @@ int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end) m.REQ_TRC_END_HI = 0; /* Not used for now, so clear it. */ /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } @@ -273,7 +273,7 @@ int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end) * req_getdents * *===========================================================================*/ int req_getdents( - endpoint_t fs_e, + struct vmnt *vmp, ino_t inode_nr, u64_t pos, char *buf, @@ -287,10 +287,10 @@ int req_getdents( cp_grant_id_t grant_id; if (direct) { - grant_id = cpf_grant_direct(fs_e, (vir_bytes) buf, size, + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) buf, size, CPF_WRITE); } else { - grant_id = cpf_grant_magic(fs_e, who_e, (vir_bytes) buf, size, + grant_id = cpf_grant_magic(vmp->m_fs_e, who_e, (vir_bytes) buf, size, CPF_WRITE); } @@ -305,7 +305,7 @@ int req_getdents( m.REQ_SEEK_POS_LO = ex64lo(pos); m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if (r == OK) { @@ -319,7 +319,7 @@ int req_getdents( /*===========================================================================* * req_inhibread * *===========================================================================*/ -int req_inhibread(endpoint_t fs_e, ino_t inode_nr) +int req_inhibread(struct vmnt *vmp, ino_t inode_nr) { message m; @@ -328,7 +328,7 @@ int req_inhibread(endpoint_t fs_e, ino_t inode_nr) m.REQ_INODE_NR = inode_nr; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } @@ -336,7 +336,7 @@ int req_inhibread(endpoint_t fs_e, ino_t inode_nr) * req_link * *===========================================================================*/ int req_link( - endpoint_t fs_e, + struct vmnt *vmp, ino_t link_parent, char *lastc, ino_t linked_file @@ -347,7 +347,7 @@ int req_link( const size_t len = strlen(lastc) + 1; message m; - grant_id = cpf_grant_direct(fs_e, (vir_bytes)lastc, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes)lastc, len, CPF_READ); if(grant_id == -1) panic("req_link: cpf_grant_direct failed"); @@ -359,7 +359,7 @@ int req_link( m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -370,7 +370,7 @@ int req_link( * req_lookup * *===========================================================================*/ int req_lookup( - endpoint_t fs_e, + struct vmnt *vmp, ino_t dir_ino, ino_t root_ino, uid_t uid, @@ -387,8 +387,8 @@ int req_lookup( vfs_ucred_t credentials; int flags; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) resolve->l_path, PATH_MAX, - CPF_READ | CPF_WRITE); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) resolve->l_path, + PATH_MAX, CPF_READ | CPF_WRITE); if(grant_id == -1) panic("req_lookup: cpf_grant_direct failed"); @@ -413,7 +413,7 @@ int req_lookup( for (i = 0; i < rfp->fp_ngroups; i++) credentials.vu_sgroups[i] = rfp->fp_sgroups[i]; - grant_id2 = cpf_grant_direct(fs_e, (vir_bytes) &credentials, + grant_id2 = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) &credentials, sizeof(credentials), CPF_READ); if(grant_id2 == -1) panic("req_lookup: cpf_grant_direct failed"); @@ -431,7 +431,7 @@ int req_lookup( m.REQ_FLAGS = flags; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if(rfp->fp_ngroups > 0) cpf_revoke(grant_id2); @@ -472,7 +472,7 @@ int req_lookup( * req_mkdir * *===========================================================================*/ int req_mkdir( - endpoint_t fs_e, + struct vmnt *vmp, ino_t inode_nr, char *lastc, uid_t uid, @@ -486,7 +486,7 @@ int req_mkdir( message m; len = strlen(lastc) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes)lastc, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes)lastc, len, CPF_READ); if(grant_id == -1) panic("req_mkdir: cpf_grant_direct failed"); @@ -500,7 +500,7 @@ int req_mkdir( m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -511,7 +511,7 @@ int req_mkdir( * req_mknod * *===========================================================================*/ int req_mknod( - endpoint_t fs_e, + struct vmnt *vmp, ino_t inode_nr, char *lastc, uid_t uid, @@ -526,7 +526,7 @@ int req_mknod( message m; len = strlen(lastc) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes)lastc, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes)lastc, len, CPF_READ); if(grant_id == -1) panic("req_mknod: cpf_grant_direct failed"); @@ -541,7 +541,7 @@ int req_mknod( m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -551,7 +551,7 @@ int req_mknod( /*===========================================================================* * req_mountpoint * *===========================================================================*/ -int req_mountpoint(endpoint_t fs_e, ino_t inode_nr) +int req_mountpoint(struct vmnt *vmp, ino_t inode_nr) { message m; @@ -560,7 +560,7 @@ int req_mountpoint(endpoint_t fs_e, ino_t inode_nr) m.REQ_INODE_NR = inode_nr; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } @@ -568,7 +568,7 @@ int req_mountpoint(endpoint_t fs_e, ino_t inode_nr) * req_newnode * *===========================================================================*/ int req_newnode( - endpoint_t fs_e, + struct vmnt *vmp, uid_t uid, gid_t gid, mode_t dmode, @@ -587,7 +587,7 @@ int req_newnode( m.REQ_GID = gid; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); res->fs_e = m.m_source; res->inode_nr = m.RES_INODE_NR; @@ -605,7 +605,7 @@ int req_newnode( * req_newdriver * *===========================================================================*/ int req_newdriver( - endpoint_t fs_e, + struct vmnt *vmp, dev_t dev, char *label ) @@ -617,7 +617,7 @@ int req_newdriver( /* Grant access to label */ len = strlen(label) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) label, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) label, len, CPF_READ); if (grant_id == -1) panic("req_newdriver: cpf_grant_direct failed"); @@ -628,7 +628,7 @@ int req_newdriver( m.REQ_PATH_LEN = len; /* Issue request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); @@ -639,10 +639,7 @@ int req_newdriver( /*===========================================================================* * req_putnode * *===========================================================================*/ -int req_putnode(fs_e, inode_nr, count) -int fs_e; -ino_t inode_nr; -int count; +int req_putnode(struct vmnt *vmp, ino_t inode_nr, int count) { message m; @@ -652,29 +649,29 @@ int count; m.REQ_COUNT = count; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } /*===========================================================================* * req_rdlink * *===========================================================================*/ -int req_rdlink(fs_e, inode_nr, proc_e, buf, len, direct) -endpoint_t fs_e; -ino_t inode_nr; -endpoint_t proc_e; -vir_bytes buf; -size_t len; -int direct; /* set to 1 to use direct grants instead of magic grants */ -{ +int req_rdlink( +struct vmnt *vmp, +ino_t inode_nr, +endpoint_t proc_e, +vir_bytes buf, +size_t len, +int direct /* set to 1 to use direct grants instead of magic grants */ +) { message m; int r; cp_grant_id_t grant_id; if (direct) { - grant_id = cpf_grant_direct(fs_e, buf, len, CPF_WRITE); + grant_id = cpf_grant_direct(vmp->m_fs_e, buf, len, CPF_WRITE); } else { - grant_id = cpf_grant_magic(fs_e, proc_e, buf, len, CPF_WRITE); + grant_id = cpf_grant_magic(vmp->m_fs_e, proc_e, buf, len, CPF_WRITE); } if (grant_id == -1) panic("req_rdlink: cpf_grant_magic failed"); @@ -686,7 +683,7 @@ int direct; /* set to 1 to use direct grants instead of magic grants */ m.REQ_MEM_SIZE = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if (r == OK) r = m.RES_NBYTES; @@ -699,7 +696,7 @@ int direct; /* set to 1 to use direct grants instead of magic grants */ * req_readsuper * *===========================================================================*/ int req_readsuper( - endpoint_t fs_e, + struct vmnt *vmp, char *label, dev_t dev, int readonly, @@ -714,7 +711,7 @@ int req_readsuper( message m; len = strlen(label)+1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) label, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) label, len, CPF_READ); if (grant_id == -1) panic("req_readsuper: cpf_grant_direct failed"); @@ -728,7 +725,7 @@ int req_readsuper( m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if(r == OK) { @@ -749,18 +746,17 @@ int req_readsuper( /*===========================================================================* * req_readwrite * *===========================================================================*/ -int req_readwrite(fs_e, inode_nr, pos, rw_flag, user_e, - user_addr, num_of_bytes, new_posp, cum_iop) -endpoint_t fs_e; -ino_t inode_nr; -u64_t pos; -int rw_flag; -endpoint_t user_e; -char *user_addr; -unsigned int num_of_bytes; -u64_t *new_posp; -unsigned int *cum_iop; -{ +int req_readwrite( +struct vmnt *vmp, +ino_t inode_nr, +u64_t pos, +int rw_flag, +endpoint_t user_e, +char *user_addr, +unsigned int num_of_bytes, +u64_t *new_posp, +unsigned int *cum_iop +) { int r; cp_grant_id_t grant_id = -1; message m; @@ -785,8 +781,8 @@ unsigned int *cum_iop; /* fallthrough */ case WRITING: if(type < 0) { type = REQ_WRITE; grantflag = CPF_READ; } - grant_id = cpf_grant_magic(fs_e, user_e, (vir_bytes) user_addr, - num_of_bytes, grantflag); + grant_id = cpf_grant_magic(vmp->m_fs_e, user_e, + (vir_bytes) user_addr, num_of_bytes, grantflag); if (grant_id == -1) panic("req_readwrite: cpf_grant_magic failed"); break; @@ -806,7 +802,7 @@ unsigned int *cum_iop; m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); if (r == OK) { @@ -822,25 +818,27 @@ unsigned int *cum_iop; /*===========================================================================* * req_rename * *===========================================================================*/ -int req_rename(fs_e, old_dir, old_name, new_dir, new_name) -endpoint_t fs_e; -ino_t old_dir; -char *old_name; -ino_t new_dir; -char *new_name; -{ +int req_rename( +struct vmnt *vmp, +ino_t old_dir, +char *old_name, +ino_t new_dir, +char *new_name +) { int r; cp_grant_id_t gid_old, gid_new; size_t len_old, len_new; message m; len_old = strlen(old_name) + 1; - gid_old = cpf_grant_direct(fs_e, (vir_bytes) old_name, len_old, CPF_READ); + gid_old = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) old_name, len_old, + CPF_READ); if(gid_old == -1) panic("req_rename: cpf_grant_direct failed"); len_new = strlen(new_name) + 1; - gid_new = cpf_grant_direct(fs_e, (vir_bytes) new_name, len_new, CPF_READ); + gid_new = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) new_name, len_new, + CPF_READ); if(gid_new == -1) panic("req_rename: cpf_grant_direct failed"); @@ -854,7 +852,7 @@ char *new_name; m.REQ_REN_LEN_NEW = len_new; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(gid_old); cpf_revoke(gid_new); @@ -865,18 +863,18 @@ char *new_name; /*===========================================================================* * req_rmdir * *===========================================================================*/ -int req_rmdir(fs_e, inode_nr, lastc) -endpoint_t fs_e; -ino_t inode_nr; -char *lastc; -{ +int req_rmdir( +struct vmnt *vmp, +ino_t inode_nr, +char *lastc +) { int r; cp_grant_id_t grant_id; size_t len; message m; len = strlen(lastc) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) lastc, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) lastc, len, CPF_READ); if(grant_id == -1) panic("req_rmdir: cpf_grant_direct failed"); @@ -887,7 +885,7 @@ char *lastc; m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -898,7 +896,7 @@ char *lastc; * req_slink * *===========================================================================*/ int req_slink( - endpoint_t fs_e, + struct vmnt *vmp, ino_t inode_nr, char *lastc, endpoint_t proc_e, @@ -914,11 +912,12 @@ int req_slink( message m; len = strlen(lastc) + 1; - gid_name = cpf_grant_direct(fs_e, (vir_bytes) lastc, len, CPF_READ); + gid_name = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) lastc, len, CPF_READ); if (gid_name == GRANT_INVALID) panic("req_slink: cpf_grant_direct failed"); - gid_buf = cpf_grant_magic(fs_e, proc_e, path_addr, path_length, CPF_READ); + gid_buf = cpf_grant_magic(vmp->m_fs_e, proc_e, path_addr, path_length, + CPF_READ); if (gid_buf == GRANT_INVALID) { cpf_revoke(gid_name); panic("req_slink: cpf_grant_magic failed"); @@ -935,7 +934,7 @@ int req_slink( m.REQ_MEM_SIZE = path_length; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(gid_name); cpf_revoke(gid_buf); @@ -946,14 +945,15 @@ int req_slink( /*===========================================================================* * req_stat * *===========================================================================*/ -int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf) +int req_stat(struct vmnt *vmp, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf) { cp_grant_id_t grant_id; int r; message m; /* Grant FS access to copy straight into user provided buffer */ - grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct stat), CPF_WRITE); + grant_id = cpf_grant_magic(vmp->m_fs_e, proc_e, buf, sizeof(struct stat), + CPF_WRITE); if (grant_id < 0) panic("req_stat: cpf_grant_* failed"); @@ -964,7 +964,7 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf) m.REQ_GRANT = grant_id; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -974,8 +974,7 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf) /*===========================================================================* * req_sync * *===========================================================================*/ -int req_sync(fs_e) -endpoint_t fs_e; +int req_sync(struct vmnt *vmp) { message m; @@ -983,17 +982,14 @@ endpoint_t fs_e; m.m_type = REQ_SYNC; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } /*===========================================================================* * req_unlink * *===========================================================================*/ -int req_unlink(fs_e, inode_nr, lastc) -endpoint_t fs_e; -ino_t inode_nr; -char *lastc; +int req_unlink(struct vmnt *vmp, ino_t inode_nr, char *lastc) { cp_grant_id_t grant_id; size_t len; @@ -1001,7 +997,7 @@ char *lastc; message m; len = strlen(lastc) + 1; - grant_id = cpf_grant_direct(fs_e, (vir_bytes) lastc, len, CPF_READ); + grant_id = cpf_grant_direct(vmp->m_fs_e, (vir_bytes) lastc, len, CPF_READ); if(grant_id == -1) panic("req_unlink: cpf_grant_direct failed"); @@ -1012,7 +1008,7 @@ char *lastc; m.REQ_PATH_LEN = len; /* Send/rec request */ - r = fs_sendrec(fs_e, &m); + r = fs_sendrec(vmp, &m); cpf_revoke(grant_id); return(r); @@ -1022,8 +1018,7 @@ char *lastc; /*===========================================================================* * req_unmount * *===========================================================================*/ -int req_unmount(fs_e) -endpoint_t fs_e; +int req_unmount(struct vmnt *vmp) { message m; @@ -1031,14 +1026,14 @@ endpoint_t fs_e; m.m_type = REQ_UNMOUNT; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } /*===========================================================================* * req_utime * *===========================================================================*/ -int req_utime(endpoint_t fs_e, ino_t inode_nr, struct timespec * actimespec, +int req_utime(struct vmnt *vmp, ino_t inode_nr, struct timespec * actimespec, struct timespec * modtimespec) { message m; @@ -1055,5 +1050,5 @@ int req_utime(endpoint_t fs_e, ino_t inode_nr, struct timespec * actimespec, m.REQ_MODNSEC = modtimespec->tv_nsec; /* Send/rec request */ - return fs_sendrec(fs_e, &m); + return fs_sendrec(vmp, &m); } diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 09763f41b..a48745b3d 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -177,7 +177,7 @@ int do_stat(message *UNUSED(m_out)) if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf); + r = req_stat(vp->v_vmnt, vp->v_inode_nr, who_e, statbuf); unlock_vnode(vp); unlock_vmnt(vmp); @@ -202,7 +202,7 @@ int do_fstat(message *UNUSED(m_out)) /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); - r = req_stat(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr, + r = req_stat(rfilp->filp_vno->v_vmnt, rfilp->filp_vno->v_inode_nr, who_e, statbuf); unlock_filp(rfilp); @@ -226,7 +226,7 @@ int do_fstatfs(message *UNUSED(m_out)) /* Is the file descriptor valid? */ if( (rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); - r = req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, statbuf); + r = req_fstatfs(rfilp->filp_vno->v_vmnt, who_e, statbuf); unlock_filp(rfilp); @@ -257,7 +257,7 @@ int do_statvfs(message *UNUSED(m_out)) if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - r = req_statvfs(vp->v_fs_e, who_e, statbuf); + r = req_statvfs(vp->v_vmnt, who_e, statbuf); unlock_vnode(vp); unlock_vmnt(vmp); @@ -281,7 +281,7 @@ int do_fstatvfs(message *UNUSED(m_out)) /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); - r = req_statvfs(rfilp->filp_vno->v_fs_e, who_e, statbuf); + r = req_statvfs(rfilp->filp_vno->v_vmnt, who_e, statbuf); unlock_filp(rfilp); @@ -312,7 +312,7 @@ int do_lstat(message *UNUSED(m_out)) if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf); + r = req_stat(vp->v_vmnt, vp->v_inode_nr, who_e, statbuf); unlock_vnode(vp); unlock_vmnt(vmp); diff --git a/servers/vfs/time.c b/servers/vfs/time.c index d3b42669b..8b176e835 100644 --- a/servers/vfs/time.c +++ b/servers/vfs/time.c @@ -70,7 +70,7 @@ int do_utime(message *UNUSED(m_out)) newactim = actim; newmodtim = modtim; } - r = req_utime(vp->v_fs_e, vp->v_inode_nr, &newactim, &newmodtim); + r = req_utime(vp->v_vmnt, vp->v_inode_nr, &newactim, &newmodtim); } unlock_vnode(vp); @@ -201,7 +201,7 @@ int do_utimens(message *UNUSED(m_out)) if (r == OK) /* Issue request */ - r = req_utime(vp->v_fs_e, vp->v_inode_nr, &newactim, &newmodtim); + r = req_utime(vp->v_vmnt, vp->v_inode_nr, &newactim, &newmodtim); if (kind == UTIMENS_STYLE) { /* Close the temporary */ diff --git a/servers/vfs/vnode.c b/servers/vfs/vnode.c index 022711748..90c488866 100644 --- a/servers/vfs/vnode.c +++ b/servers/vfs/vnode.c @@ -279,7 +279,7 @@ void put_vnode(struct vnode *vp) panic("put_vnode failed: bad v_fs_count %d\n", vp->v_fs_count); /* Tell FS we don't need this inode to be open anymore. */ - r = req_putnode(vp->v_fs_e, vp->v_inode_nr, vp->v_fs_count); + r = req_putnode(vp->v_vmnt, vp->v_inode_nr, vp->v_fs_count); if (r != OK) { printf("VFS: putnode failed: %d\n", r); @@ -289,7 +289,8 @@ void put_vnode(struct vnode *vp) /* This inode could've been mapped. If so, tell mapped FS to close it as * well. If mapped onto same FS, this putnode is not needed. */ if (vp->v_mapfs_e != NONE && vp->v_mapfs_e != vp->v_fs_e) - req_putnode(vp->v_mapfs_e, vp->v_mapinode_nr, vp->v_mapfs_count); + req_putnode(find_vmnt(vp->v_mapfs_e), vp->v_mapinode_nr, + vp->v_mapfs_count); vp->v_fs_count = 0; vp->v_ref_count = 0; @@ -310,7 +311,7 @@ void vnode_clean_refs(struct vnode *vp) if (vp->v_fs_count <= 1) return; /* Nothing to do */ /* Drop all references except one */ - req_putnode(vp->v_fs_e, vp->v_inode_nr, vp->v_fs_count - 1); + req_putnode(vp->v_vmnt, vp->v_inode_nr, vp->v_fs_count - 1); vp->v_fs_count = 1; }