-/* $OpenBSD: ext2fs_vnops.c,v 1.84 2018/06/21 14:17:23 visa Exp $ */
+/* $OpenBSD: ext2fs_vnops.c,v 1.85 2018/09/06 11:50:54 jsg Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */
/*
goto abortit;
}
if ((ip->i_e2fs_mode & IFMT) == IFDIR) {
- error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
- if (!error && tvp)
- error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred,
+ error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
+ if (!error && tvp)
+ error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred,
tcnp->cn_proc);
- if (error) {
- VOP_UNLOCK(fvp);
- error = EACCES;
- goto abortit;
- }
+ if (error) {
+ VOP_UNLOCK(fvp);
+ error = EACCES;
+ goto abortit;
+ }
/*
* Avoid ".", "..", and aliases of "." for obvious reasons.
*/
* decrement the link count on the parent
* of the target directory.
*/
- if (doingdirectory && !newparent) {
+ if (doingdirectory && !newparent) {
dp->i_e2fs_nlink--;
dp->i_flag |= IN_CHANGE;
}
panic("ext2fs_mkdir: blksize"); /* XXX should grow with balloc() */
else {
error = ext2fs_setsize(ip, VTOI(dvp)->i_e2fs->e2fs_bsize);
- if (error) {
- dp->i_e2fs_nlink--;
- dp->i_flag |= IN_CHANGE;
- goto bad;
- }
+ if (error) {
+ dp->i_e2fs_nlink--;
+ dp->i_flag |= IN_CHANGE;
+ goto bad;
+ }
ip->i_flag |= IN_CHANGE;
}
-/* $OpenBSD: ufs_lookup.c,v 1.52 2018/05/02 02:24:56 visa Exp $ */
+/* $OpenBSD: ufs_lookup.c,v 1.53 2018/09/06 11:50:54 jsg Exp $ */
/* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */
/*
ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp,
struct componentname *cnp, struct buf *newdirbp)
{
- struct ucred *cr;
- struct proc *p;
- int newentrysize;
- struct inode *dp;
- struct buf *bp;
- u_int dsize;
- struct direct *ep, *nep;
+ struct ucred *cr;
+ struct proc *p;
+ int newentrysize;
+ struct inode *dp;
+ struct buf *bp;
+ u_int dsize;
+ struct direct *ep, *nep;
int error, ret, blkoff, loc, spacefree, flags;
- char *dirbuf;
+ char *dirbuf;
- error = 0;
- cr = cnp->cn_cred;
- p = cnp->cn_proc;
- dp = VTOI(dvp);
+ error = 0;
+ cr = cnp->cn_cred;
+ p = cnp->cn_proc;
+ dp = VTOI(dvp);
newentrysize = DIRSIZ(OFSFMT(dp), dirp);
if (dp->i_count == 0) {
* If dp->i_count is 0, then namei could find no
* space in the directory. Here, dp->i_offset will
* be on a directory block boundary and we will write the
- * new entry into a fresh block.
- */
- if (dp->i_offset & (DIRBLKSIZ - 1))
+ * new entry into a fresh block.
+ */
+ if (dp->i_offset & (DIRBLKSIZ - 1))
panic("ufs_direnter: newblk");
flags = B_CLRBUF;
if (!DOINGSOFTDEP(dvp))
DIP_ASSIGN(dp, size, dp->i_offset + DIRBLKSIZ);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
uvm_vnp_setsize(dvp, DIP(dp, size));
- dirp->d_reclen = DIRBLKSIZ;
+ dirp->d_reclen = DIRBLKSIZ;
blkoff = dp->i_offset &
(VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1);
memcpy(bp->b_data + blkoff, dirp, newentrysize);
return (error);
}
error = VOP_BWRITE(bp);
- ret = UFS_UPDATE(dp, !DOINGSOFTDEP(dvp));
- if (error == 0)
- return (ret);
- return (error);
- }
-
- /*
+ ret = UFS_UPDATE(dp, !DOINGSOFTDEP(dvp));
+ if (error == 0)
+ return (ret);
+ return (error);
+ }
+
+ /*
* If dp->i_count is non-zero, then namei found space for the new
* entry in the range dp->i_offset to dp->i_offset + dp->i_count
* in the directory. To use this space, we may have to compact
* the entries located there, by copying them together towards the
* beginning of the block, leaving the free space in one usable
* chunk at the end.
- */
-
- /*
+ */
+
+ /*
* Increase size of directory if entry eats into new space.
* This should never push the size past a new multiple of
* DIRBLKSIZE.
/*
* Get the block containing the space for the new directory entry.
*/
- if ((error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, &dirbuf, &bp))
+ if ((error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, &dirbuf, &bp))
!= 0) {
- if (DOINGSOFTDEP(dvp) && newdirbp != NULL)
- bdwrite(newdirbp);
- return (error);
- }
+ if (DOINGSOFTDEP(dvp) && newdirbp != NULL)
+ bdwrite(newdirbp);
+ return (error);
+ }
/*
* Find space for the new entry. In the simple case, the entry at
* offset base will have the space. If it does not, then namei
dp->i_offset + ((char *)nep - dirbuf),
dp->i_offset + ((char *)ep - dirbuf));
#endif
- if (DOINGSOFTDEP(dvp))
- softdep_change_directoryentry_offset(dp, dirbuf,
- (caddr_t)nep, (caddr_t)ep, dsize);
- else
- memmove(ep, nep, dsize);
+ if (DOINGSOFTDEP(dvp))
+ softdep_change_directoryentry_offset(dp, dirbuf,
+ (caddr_t)nep, (caddr_t)ep, dsize);
+ else
+ memmove(ep, nep, dsize);
}
/*
* Here, `ep' points to a directory entry containing `dsize' in-use
dp->i_offset & ~(DIRBLKSIZ - 1));
#endif
- if (DOINGSOFTDEP(dvp)) {
- (void)softdep_setup_directory_add(bp, dp,
- dp->i_offset + (caddr_t)ep - dirbuf,
+ if (DOINGSOFTDEP(dvp)) {
+ (void)softdep_setup_directory_add(bp, dp,
+ dp->i_offset + (caddr_t)ep - dirbuf,
dirp->d_ino, newdirbp, 0);
- bdwrite(bp);
- } else {
- error = VOP_BWRITE(bp);
- }
+ bdwrite(bp);
+ } else {
+ error = VOP_BWRITE(bp);
+ }
dp->i_flag |= IN_CHANGE | IN_UPDATE;
- /*
- * If all went well, and the directory can be shortened, proceed
- * with the truncation. Note that we have to unlock the inode for
- * the entry that we just entered, as the truncation may need to
- * lock other inodes which can lead to deadlock if we also hold a
- * lock on the newly entered node.
- */
+ /*
+ * If all went well, and the directory can be shortened, proceed
+ * with the truncation. Note that we have to unlock the inode for
+ * the entry that we just entered, as the truncation may need to
+ * lock other inodes which can lead to deadlock if we also hold a
+ * lock on the newly entered node.
+ */
if (error == 0 && dp->i_endoff && dp->i_endoff < DIP(dp, size)) {
if (tvp != NULL)
*/
ep->d_ino = 0;
} else {
- /*
- * Collapse new free space into previous entry.
- */
- ep->d_reclen += dp->i_reclen;
+ /*
+ * Collapse new free space into previous entry.
+ */
+ ep->d_reclen += dp->i_reclen;
}
#ifdef UFS_DIRHASH
if (dp->i_dirhash != NULL)
((dp->i_offset - dp->i_count) & (DIRBLKSIZ - 1)),
dp->i_offset & ~(DIRBLKSIZ - 1));
#endif
- if (DOINGSOFTDEP(dvp)) {
+ if (DOINGSOFTDEP(dvp)) {
if (ip) {
ip->i_effnlink--;
softdep_change_linkcnt(ip, 0);
return (error);
ep->d_ino = newinum;
if (!OFSFMT(dp))
- ep->d_type = newtype;
- oip->i_effnlink--;
- if (DOINGSOFTDEP(vdp)) {
+ ep->d_type = newtype;
+ oip->i_effnlink--;
+ if (DOINGSOFTDEP(vdp)) {
softdep_change_linkcnt(oip, 0);
- softdep_setup_directory_change(bp, dp, oip, newinum, isrmdir);
- bdwrite(bp);
- } else {
+ softdep_setup_directory_change(bp, dp, oip, newinum, isrmdir);
+ bdwrite(bp);
+ } else {
DIP_ADD(oip, nlink, -1);
oip->i_flag |= IN_CHANGE;
if (DOINGASYNC(vdp)) {
} else {
error = VOP_BWRITE(bp);
}
- }
+ }
dp->i_flag |= IN_CHANGE | IN_UPDATE;
return (error);
}