/*===========================================================================* * do_mknod * *===========================================================================*/ PUBLIC int do_mknod() { /* Perform the mknod(name, mode, addr) system call. */ register mode_t bits, mode_bits; int r; struct vnode *vp; /* Only the super_user may make nodes other than fifos. */ mode_bits = (mode_t) m_in.mk_mode; /* mode of the inode */ if(!super_user && (((mode_bits & I_TYPE) != I_NAMED_PIPE) && ((mode_bits & I_TYPE) != I_UNIX_SOCKET))) return(EPERM); bits = (mode_bits & I_TYPE) | (mode_bits & ALL_MODES & fp->fp_umask); /* Open directory that's going to hold the new node. */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if((vp = last_dir(fp)) == NULL) return(err_code); /* Make sure that the object is a directory */ if((vp->v_mode & I_TYPE) != I_DIRECTORY) { put_vnode(vp); return(ENOTDIR); } if ((r = forbidden(vp, W_BIT|X_BIT)) == OK) { r = req_mknod(vp->v_fs_e, vp->v_inode_nr, user_fullpath, fp->fp_effuid, fp->fp_effgid, bits, m_in.mk_z0); } put_vnode(vp); return(r); }
/*===========================================================================* * do_mknod * *===========================================================================*/ int do_mknod(void) { /* Perform the mknod(name, mode, addr) system call. */ register mode_t bits, mode_bits; int r; struct vnode *vp; struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; vir_bytes vname1; size_t vname1_length; dev_t dev; vname1 = job_m_in.m_lc_vfs_mknod.name; vname1_length = job_m_in.m_lc_vfs_mknod.len; mode_bits = job_m_in.m_lc_vfs_mknod.mode; dev = job_m_in.m_lc_vfs_mknod.device; /* If the path names a symbolic link, mknod() shall fail with EEXIST. */ lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; resolve.l_vnode_lock = VNODE_WRITE; /* Only the super_user may make nodes other than fifos. */ if (!super_user && !S_ISFIFO(mode_bits)) return(EPERM); bits = (mode_bits & S_IFMT) | (mode_bits & ACCESSPERMS & fp->fp_umask); /* Open directory that's going to hold the new node. */ if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code); /* Make sure that the object is a directory */ 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, fp->fp_effgid, bits, dev); } unlock_vnode(vp); unlock_vmnt(vmp); put_vnode(vp); return(r); }
/*===========================================================================* * do_mknod * *===========================================================================*/ int do_mknod() { /* Perform the mknod(name, mode, addr) system call. */ register mode_t bits, mode_bits; int r; struct vnode *vp; struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; vir_bytes vname1; size_t vname1_length; dev_t dev; vname1 = (vir_bytes) job_m_in.name1; vname1_length = (size_t) job_m_in.name1_length; mode_bits = (mode_t) job_m_in.mk_mode; /* mode of the inode */ dev = job_m_in.m1_i3; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; resolve.l_vnode_lock = VNODE_READ; /* Only the super_user may make nodes other than fifos. */ if (!super_user && (!S_ISFIFO(mode_bits) && !S_ISSOCK(mode_bits))) { return(EPERM); } bits = (mode_bits & S_IFMT) | (mode_bits & ACCESSPERMS & fp->fp_umask); /* Open directory that's going to hold the new node. */ if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code); /* Make sure that the object is a directory */ 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, fp->fp_effgid, bits, dev); } unlock_vnode(vp); unlock_vmnt(vmp); put_vnode(vp); return(r); }
/*===========================================================================* * do_mknod * *===========================================================================*/ PUBLIC int do_mknod() { /* Perform the mknod(name, mode, addr) system call. */ register mode_t bits, mode_bits; int r; struct vnode *vp; struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; resolve.l_vnode_lock = VNODE_READ; /* Only the super_user may make nodes other than fifos. */ mode_bits = (mode_t) m_in.mk_mode; /* mode of the inode */ if (!super_user && (((mode_bits & I_TYPE) != I_NAMED_PIPE) && ((mode_bits & I_TYPE) != I_UNIX_SOCKET))) { return(EPERM); } bits = (mode_bits & I_TYPE) | (mode_bits & ALL_MODES & fp->fp_umask); /* Open directory that's going to hold the new node. */ if (fetch_name(m_in.name1, m_in.name1_length, M1, fullpath) != OK) return(err_code); if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code); /* Make sure that the object is a directory */ if ((vp->v_mode & I_TYPE) != I_DIRECTORY) { r = ENOTDIR; } else if ((r = forbidden(vp, W_BIT|X_BIT)) == OK) { r = req_mknod(vp->v_fs_e, vp->v_inode_nr, fullpath, fp->fp_effuid, fp->fp_effgid, bits, m_in.mk_z0); } unlock_vnode(vp); unlock_vmnt(vmp); put_vnode(vp); return(r); }