Changeset View
Changeset View
Standalone View
Standalone View
head/sys/ufs/ffs/ffs_alloc.c
Show First 20 Lines • Show All 3,184 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct thread *td = curthread; | struct thread *td = curthread; | ||||
struct fsck_cmd cmd; | struct fsck_cmd cmd; | ||||
struct ufsmount *ump; | struct ufsmount *ump; | ||||
struct vnode *vp, *dvp, *fdvp; | struct vnode *vp, *dvp, *fdvp; | ||||
struct inode *ip, *dp; | struct inode *ip, *dp; | ||||
struct mount *mp; | struct mount *mp; | ||||
struct fs *fs; | struct fs *fs; | ||||
struct pwd *pwd; | |||||
ufs2_daddr_t blkno; | ufs2_daddr_t blkno; | ||||
long blkcnt, blksize; | long blkcnt, blksize; | ||||
u_long key; | u_long key; | ||||
struct file *fp, *vfp; | struct file *fp, *vfp; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int filetype, error; | int filetype, error; | ||||
static struct fileops *origops, bufferedops; | static struct fileops *origops, bufferedops; | ||||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | #endif /* DIAGNOSTIC */ | ||||
* to which ".." points. | * to which ".." points. | ||||
*/ | */ | ||||
error = ffs_vget(mp, (ino_t)cmd.value, LK_EXCLUSIVE, &fdvp); | error = ffs_vget(mp, (ino_t)cmd.value, LK_EXCLUSIVE, &fdvp); | ||||
if (error) | if (error) | ||||
break; | break; | ||||
/* | /* | ||||
* Now we get and lock the child directory containing "..". | * Now we get and lock the child directory containing "..". | ||||
*/ | */ | ||||
FILEDESC_SLOCK(td->td_proc->p_fd); | pwd = pwd_hold(td); | ||||
dvp = td->td_proc->p_fd->fd_cdir; | dvp = pwd->pwd_cdir; | ||||
FILEDESC_SUNLOCK(td->td_proc->p_fd); | |||||
if ((error = vget(dvp, LK_EXCLUSIVE, td)) != 0) { | if ((error = vget(dvp, LK_EXCLUSIVE, td)) != 0) { | ||||
vput(fdvp); | vput(fdvp); | ||||
pwd_drop(pwd); | |||||
break; | break; | ||||
} | } | ||||
dp = VTOI(dvp); | dp = VTOI(dvp); | ||||
dp->i_offset = 12; /* XXX mastertemplate.dot_reclen */ | dp->i_offset = 12; /* XXX mastertemplate.dot_reclen */ | ||||
error = ufs_dirrewrite(dp, VTOI(fdvp), (ino_t)cmd.size, | error = ufs_dirrewrite(dp, VTOI(fdvp), (ino_t)cmd.size, | ||||
DT_DIR, 0); | DT_DIR, 0); | ||||
cache_purge(fdvp); | cache_purge(fdvp); | ||||
cache_purge(dvp); | cache_purge(dvp); | ||||
vput(dvp); | vput(dvp); | ||||
vput(fdvp); | vput(fdvp); | ||||
pwd_drop(pwd); | |||||
break; | break; | ||||
case FFS_UNLINK: | case FFS_UNLINK: | ||||
#ifdef DIAGNOSTIC | #ifdef DIAGNOSTIC | ||||
if (fsckcmds) { | if (fsckcmds) { | ||||
char buf[32]; | char buf[32]; | ||||
if (copyinstr((char *)(intptr_t)cmd.value, buf,32,NULL)) | if (copyinstr((char *)(intptr_t)cmd.value, buf,32,NULL)) | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | buffered_write(fp, uio, active_cred, flags, td) | ||||
* on the application setting the current directory to a location | * on the application setting the current directory to a location | ||||
* within the filesystem being written. Yes, this is an ugly hack. | * within the filesystem being written. Yes, this is an ugly hack. | ||||
*/ | */ | ||||
devvp = fp->f_vnode; | devvp = fp->f_vnode; | ||||
if (!vn_isdisk(devvp, NULL)) | if (!vn_isdisk(devvp, NULL)) | ||||
return (EINVAL); | return (EINVAL); | ||||
fdp = td->td_proc->p_fd; | fdp = td->td_proc->p_fd; | ||||
FILEDESC_SLOCK(fdp); | FILEDESC_SLOCK(fdp); | ||||
vp = fdp->fd_cdir; | vp = fdp->fd_pwd->pwd_cdir; | ||||
vref(vp); | vref(vp); | ||||
FILEDESC_SUNLOCK(fdp); | FILEDESC_SUNLOCK(fdp); | ||||
vn_lock(vp, LK_SHARED | LK_RETRY); | vn_lock(vp, LK_SHARED | LK_RETRY); | ||||
/* | /* | ||||
* Check that the current directory vnode indeed belongs to | * Check that the current directory vnode indeed belongs to | ||||
* UFS before trying to dereference UFS-specific v_data fields. | * UFS before trying to dereference UFS-specific v_data fields. | ||||
*/ | */ | ||||
if (vp->v_op != &ffs_vnodeops1 && vp->v_op != &ffs_vnodeops2) { | if (vp->v_op != &ffs_vnodeops1 && vp->v_op != &ffs_vnodeops2) { | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |