Fixing age old cruft:

* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
  d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
  in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
  FS-specific checks littered throughout the code.  This may be used later to
  make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
  to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
This commit is contained in:
mycroft 2004-08-15 07:19:54 +00:00
parent c68c45c975
commit 45a21b76f0
25 changed files with 390 additions and 375 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls_43.c,v 1.27 2003/11/19 16:43:38 christos Exp $ */
/* $NetBSD: vfs_syscalls_43.c,v 1.28 2004/08/15 07:19:54 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.27 2003/11/19 16:43:38 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.28 2004/08/15 07:19:54 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "fs_union.h"
@ -389,7 +389,7 @@ unionread:
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
loff = auio.uio_offset = fp->f_offset;
# if (BYTE_ORDER != LITTLE_ENDIAN)
if (vp->v_mount->mnt_maxsymlinklen <= 0) {
if ((vp->v_mount->mnt_iflag & IMNT_DTYPE) == 0) {
error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
(off_t **)0, (int *)0);
fp->f_offset = auio.uio_offset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_vfsops.c,v 1.16 2004/07/05 07:28:45 pk Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.17 2004/08/15 07:19:54 mycroft Exp $ */
/*-
* Copyright (c) 1994
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.16 2004/07/05 07:28:45 pk Exp $");
__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.17 2004/08/15 07:19:54 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -421,7 +421,6 @@ iso_mountfs(devvp, mp, p, argp)
mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CD9660);
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_dev_bshift = iso_bsize;
mp->mnt_fs_bshift = isomp->im_bshift;

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecore_vfsops.c,v 1.14 2004/05/25 14:54:56 hannken Exp $ */
/* $NetBSD: filecore_vfsops.c,v 1.15 2004/08/15 07:19:54 mycroft Exp $ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.14 2004/05/25 14:54:56 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.15 2004/08/15 07:19:54 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -371,7 +371,6 @@ filecore_mountfs(devvp, mp, p, argp)
mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_FILECORE);
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_dev_bshift = fcdr->log2secsize;
mp->mnt_fs_bshift = fcmp->log2bsize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs_vfsops.c,v 1.23 2004/05/30 20:46:25 yamt Exp $ */
/* $NetBSD: ntfs_vfsops.c,v 1.24 2004/08/15 07:19:54 mycroft Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.23 2004/05/30 20:46:25 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.24 2004/08/15 07:19:54 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -621,7 +621,6 @@ ntfs_mountfs(devvp, mp, argsp, p)
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_NTFS);
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
#endif
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
devvp->v_specmountpoint = mp;
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_subr.c,v 1.231 2004/08/13 22:48:06 mycroft Exp $ */
/* $NetBSD: vfs_subr.c,v 1.232 2004/08/15 07:19:54 mycroft Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.231 2004/08/13 22:48:06 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.232 2004/08/15 07:19:54 mycroft Exp $");
#include "opt_inet.h"
#include "opt_ddb.h"
@ -3182,8 +3182,8 @@ vfs_mount_print(mp, full, pr)
(*pr)("vnodecovered = %p syncer = %p data = %p\n",
mp->mnt_vnodecovered,mp->mnt_syncer,mp->mnt_data);
(*pr)("fs_bshift %d dev_bshift = %d maxsymlinklen = %d\n",
mp->mnt_fs_bshift,mp->mnt_dev_bshift,mp->mnt_maxsymlinklen);
(*pr)("fs_bshift %d dev_bshift = %d\n",
mp->mnt_fs_bshift,mp->mnt_dev_bshift);
bitmask_snprintf(mp->mnt_flag, __MNT_FLAG_BITS, sbuf, sizeof(sbuf));
(*pr)("flag = %s\n", sbuf);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vfsops.c,v 1.142 2004/07/12 12:40:30 yamt Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.143 2004/08/15 07:19:54 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.142 2004/07/12 12:40:30 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.143 2004/08/15 07:19:54 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -718,13 +718,7 @@ mountnfs(argp, mp, nam, pth, hst, vpp, p)
#ifndef NFS_V2_ONLY
if (argp->flags & NFSMNT_NQNFS)
/*
* We have to set mnt_maxsymlink to a non-zero value so
* that COMPAT_43 routines will know that we are setting
* the d_type field in directories (and can zero it for
* unsuspecting binaries).
*/
mp->mnt_maxsymlinklen = 1;
mp->mnt_iflag |= IMNT_DTYPE;
#endif
#ifndef NFS_V2_ONLY

View File

@ -1,4 +1,4 @@
/* $NetBSD: fstypes.h,v 1.2 2004/04/21 02:21:49 christos Exp $ */
/* $NetBSD: fstypes.h,v 1.3 2004/08/15 07:19:54 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -178,6 +178,7 @@ typedef struct fhandle fhandle_t;
#define IMNT_SUSPEND 0x00000008 /* request upper write suspension */
#define IMNT_SUSPENDLOW 0x00000010 /* request lower write suspension */
#define IMNT_SUSPENDED 0x00000020 /* write operations are suspended */
#define IMNT_DTYPE 0x00000040 /* returns d_type fields */
#define __MNT_FLAGS \
__MNT_BASIC_FLAGS \
@ -222,6 +223,7 @@ typedef struct fhandle fhandle_t;
#define __IMNT_FLAG_BITS \
"\20" \
"\07IMNT_DTYPE" \
"\06IMNT_SUSPENDED" \
"\05IMNT_SUSPENDLOW" \
"\04IMNT_SUSPEND" \

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount.h,v 1.123 2004/07/01 10:03:32 hannken Exp $ */
/* $NetBSD: mount.h,v 1.124 2004/08/15 07:19:55 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -123,7 +123,6 @@ struct mount {
struct lock mnt_lock; /* mount structure lock */
int mnt_flag; /* flags */
int mnt_iflag; /* internal flags */
int mnt_maxsymlinklen; /* max size of short symlink */
int mnt_fs_bshift; /* offset shift for lblkno */
int mnt_dev_bshift; /* shift for device sectors */
struct statvfs mnt_stat; /* cache of filesystem stats */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_bmap.c,v 1.15 2004/03/22 19:23:08 bouyer Exp $ */
/* $NetBSD: ext2fs_bmap.c,v 1.16 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.15 2004/03/22 19:23:08 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.16 2004/08/15 07:19:56 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -157,7 +157,7 @@ ext2fs_bmaparray(vp, bn, bnp, ap, nump, runp)
ip = VTOI(vp);
mp = vp->v_mount;
ump = VFSTOUFS(mp);
ump = ip->i_ump;
#ifdef DIAGNOSTIC
if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
panic("ext2fs_bmaparray: invalid arguments");

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_inode.c,v 1.42 2004/08/14 14:32:04 mycroft Exp $ */
/* $NetBSD: ext2fs_inode.c,v 1.43 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.42 2004/08/14 14:32:04 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.43 2004/08/15 07:19:56 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -227,56 +227,61 @@ ext2fs_truncate(v)
} */ *ap = v;
struct vnode *ovp = ap->a_vp;
daddr_t lastblock;
struct inode *oip;
struct inode *oip = VTOI(ovp);
daddr_t bn, lastiblock[NIADDR], indir_lbn[NIADDR];
/* XXX ondisk32 */
int32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
off_t length = ap->a_length;
struct m_ext2fs *fs;
int offset, size, level;
long count, nblocks, blocksreleased = 0;
int i;
long count, blocksreleased = 0;
int i, ioflag, nblocks;
int error, allerror = 0;
off_t osize;
int sync;
struct ufsmount *ump = oip->i_ump;
if (length < 0)
return (EINVAL);
oip = VTOI(ovp);
if (ovp->v_type == VLNK &&
(oip->i_e2fs_size < ovp->v_mount->mnt_maxsymlinklen ||
(ovp->v_mount->mnt_maxsymlinklen == 0 &&
oip->i_e2fs_nblock == 0))) {
#ifdef DIAGNOSTIC
if (length != 0)
panic("ext2fs_truncate: partial truncate of symlink");
#endif
(oip->i_e2fs_size < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && oip->i_e2fs_nblock == 0))) {
KDASSERT(length == 0);
memset((char *)&oip->i_din.e2fs_din->e2di_shortlink, 0,
(u_int)oip->i_e2fs_size);
oip->i_e2fs_size = 0;
oip->i_flag |= IN_CHANGE | IN_UPDATE;
return (VOP_UPDATE(ovp, NULL, NULL, UPDATE_WAIT));
return (VOP_UPDATE(ovp, NULL, NULL, 0));
}
if (oip->i_e2fs_size == length) {
oip->i_flag |= IN_CHANGE | IN_UPDATE;
return (VOP_UPDATE(ovp, NULL, NULL, 0));
}
fs = oip->i_e2fs;
if (length > ump->um_maxfilesize)
return (EFBIG);
osize = oip->i_e2fs_size;
ioflag = ap->a_flags;
/*
* Lengthen the size of the file. We must ensure that the
* last byte of the file is allocated. Since the smallest
* value of osize is 0, length will be at least 1.
*/
if (osize < length) {
#if 0 /* XXX */
if (length > fs->fs_maxfilesize)
return (EFBIG);
#endif
ufs_balloc_range(ovp, length - 1, 1, ap->a_cred,
ap->a_flags & IO_SYNC ? B_SYNC : 0);
error = ufs_balloc_range(ovp, length - 1, 1, ap->a_cred,
ioflag & IO_SYNC ? B_SYNC : 0);
if (error) {
(void) VOP_TRUNCATE(ovp, osize, ioflag & IO_SYNC,
ap->a_cred, ap->a_p);
return (error);
}
uvm_vnp_setsize(ovp, length);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
return (VOP_UPDATE(ovp, NULL, NULL, 1));
KASSERT(ovp->v_size == oip->i_size);
return (VOP_UPDATE(ovp, NULL, NULL, 0));
}
/*
* Shorten the size of the file. If the file is not being
@ -294,7 +299,6 @@ ext2fs_truncate(v)
}
oip->i_e2fs_size = length;
uvm_vnp_setsize(ovp, length);
/*
* Calculate index into inode's block list of
* last direct and indirect blocks (if any)
@ -313,17 +317,26 @@ ext2fs_truncate(v)
* normalized to -1 for calls to ext2fs_indirtrunc below.
*/
memcpy((caddr_t)oldblks, (caddr_t)&oip->i_e2fs_blocks[0], sizeof oldblks);
for (level = TRIPLE; level >= SINGLE; level--)
if (lastiblock[level] < 0) {
sync = 0;
for (level = TRIPLE; level >= SINGLE; level--) {
if (lastiblock[level] < 0 && oldblks[NDADDR + level] != 0) {
sync = 1;
oip->i_e2fs_blocks[NDADDR + level] = 0;
lastiblock[level] = -1;
}
for (i = NDADDR - 1; i > lastblock; i--)
oip->i_e2fs_blocks[i] = 0;
}
for (i = 0; i < NDADDR; i++) {
if (i > lastblock && oldblks[i] != 0) {
sync = 1;
oip->i_e2fs_blocks[i] = 0;
}
}
oip->i_flag |= IN_CHANGE | IN_UPDATE;
error = VOP_UPDATE(ovp, NULL, NULL, UPDATE_WAIT);
if (error && !allerror)
allerror = error;
if (sync) {
error = VOP_UPDATE(ovp, NULL, NULL, UPDATE_WAIT);
if (error && !allerror)
allerror = error;
}
/*
* Having written the new inode to disk, save its new configuration
@ -331,9 +344,9 @@ ext2fs_truncate(v)
* Note that we save the new block configuration so we can check it
* when we are done.
*/
memcpy((caddr_t)newblks, (caddr_t)&oip->i_e2fs_blocks[0], sizeof newblks);
memcpy((caddr_t)&oip->i_e2fs_blocks[0], (caddr_t)oldblks, sizeof oldblks);
oip->i_e2fs_size = osize;
error = vtruncbuf(ovp, lastblock + 1, 0, 0);
if (error && !allerror)
@ -397,6 +410,7 @@ done:
oip->i_e2fs_size = length;
oip->i_e2fs_nblock -= blocksreleased;
oip->i_flag |= IN_CHANGE;
KASSERT(ovp->v_type != VREG || ovp->v_size == oip->i_size);
return (allerror);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_lookup.c,v 1.28 2003/08/07 16:34:26 agc Exp $ */
/* $NetBSD: ext2fs_lookup.c,v 1.29 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Modified for NetBSD 1.2E
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.28 2003/08/07 16:34:26 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.29 2004/08/15 07:19:56 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -263,10 +263,10 @@ ext2fs_lookup(v)
struct vnode **a_vpp;
struct componentname *a_cnp;
} */ *ap = v;
struct vnode *vdp; /* vnode for directory being searched */
struct inode *dp; /* inode for directory being searched */
struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */
struct inode *dp = VTOI(vdp); /* inode for directory being searched */
struct buf *bp; /* a buffer of directory entries */
struct ext2fs_direct *ep; /* the current directory entry */
struct ext2fs_direct *ep; /* the current directory entry */
int entryoffsetinblock; /* offset of ep in bp's buffer */
enum {NONE, COMPACT, FOUND} slotstatus;
doff_t slotoffset; /* offset of area with free space */
@ -286,17 +286,18 @@ ext2fs_lookup(v)
struct vnode **vpp = ap->a_vpp;
struct componentname *cnp = ap->a_cnp;
struct ucred *cred = cnp->cn_cred;
int flags = cnp->cn_flags;
int flags;
int nameiop = cnp->cn_nameiop;
struct ufsmount *ump = dp->i_ump;
int dirblksiz = ump->um_dirblksiz;
ino_t foundino;
int dirblksize = VTOI(ap->a_dvp)->i_e2fs->e2fs_bsize;
cnp->cn_flags &= ~PDIRUNLOCK;
flags = cnp->cn_flags;
bp = NULL;
slotoffset = -1;
*vpp = NULL;
vdp = ap->a_dvp;
dp = VTOI(vdp);
lockparent = flags & LOCKPARENT;
wantparent = flags & (LOCKPARENT|WANTPARENT);
/*
@ -328,7 +329,7 @@ ext2fs_lookup(v)
slotstatus = FOUND;
slotfreespace = slotsize = slotneeded = 0;
if ((nameiop == CREATE || nameiop == RENAME) &&
(flags & ISLASTCN)) {
(flags & ISLASTCN)) {
slotstatus = NONE;
slotneeded = EXT2FS_DIRSIZ(cnp->cn_namelen);
}
@ -344,9 +345,9 @@ ext2fs_lookup(v)
* profiling time and hence has been removed in the interest
* of simplicity.
*/
bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
bmask = vdp->v_mount->mnt_stat.f_iosize - 1;
if (nameiop != LOOKUP || dp->i_diroff == 0 ||
dp->i_diroff > dp->i_e2fs_size) {
dp->i_diroff >= dp->i_e2fs_size) {
entryoffsetinblock = 0;
dp->i_offset = 0;
numdirpasses = 1;
@ -356,21 +357,24 @@ ext2fs_lookup(v)
(error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp)))
return (error);
numdirpasses = 2;
nchstats.ncs_2passes++;
}
prevoff = dp->i_offset;
endsearch = roundup(dp->i_e2fs_size, dirblksize);
endsearch = roundup(dp->i_e2fs_size, dirblksiz);
enduseful = 0;
searchloop:
while (dp->i_offset < endsearch) {
if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
preempt(1);
/*
* If necessary, get the next directory block.
*/
if ((dp->i_offset & bmask) == 0) {
if (bp != NULL)
brelse(bp);
error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset,
NULL, &bp);
error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL,
&bp);
if (error != 0)
return (error);
entryoffsetinblock = 0;
@ -380,7 +384,7 @@ searchloop:
* boundary, have to start looking for free space again.
*/
if (slotstatus == NONE &&
(entryoffsetinblock & (dirblksize - 1)) == 0) {
(entryoffsetinblock & (dirblksiz - 1)) == 0) {
slotoffset = -1;
slotfreespace = 0;
}
@ -395,11 +399,11 @@ searchloop:
((char *)bp->b_data + entryoffsetinblock);
if (ep->e2d_reclen == 0 ||
(dirchk &&
ext2fs_dirbadentry(vdp, ep, entryoffsetinblock))) {
ext2fs_dirbadentry(vdp, ep, entryoffsetinblock))) {
int i;
ufs_dirbad(dp, dp->i_offset, "mangled entry");
i = dirblksize -
(entryoffsetinblock & (dirblksize - 1));
i = dirblksiz - (entryoffsetinblock & (dirblksiz - 1));
dp->i_offset += i;
entryoffsetinblock += i;
continue;
@ -428,7 +432,8 @@ searchloop:
if (slotfreespace >= slotneeded) {
slotstatus = COMPACT;
slotsize = dp->i_offset +
fs2h16(ep->e2d_reclen) - slotoffset;
fs2h16(ep->e2d_reclen) -
slotoffset;
}
}
}
@ -440,8 +445,8 @@ searchloop:
if (ep->e2d_ino) {
namlen = ep->e2d_namlen;
if (namlen == cnp->cn_namelen &&
!memcmp(cnp->cn_nameptr, ep->e2d_name,
(unsigned)namlen)) {
!memcmp(cnp->cn_nameptr, ep->e2d_name,
(unsigned)namlen)) {
/*
* Save directory entry's inode number and
* reclen in ndp->ni_ufs area, and release
@ -449,7 +454,6 @@ searchloop:
*/
foundino = fs2h32(ep->e2d_ino);
dp->i_reclen = fs2h16(ep->e2d_reclen);
brelse(bp);
goto found;
}
}
@ -478,12 +482,13 @@ searchloop:
* allowing file to be created.
*/
if ((nameiop == CREATE || nameiop == RENAME) &&
(flags & ISLASTCN) && dp->i_e2fs_nlink != 0) {
(flags & ISLASTCN) && dp->i_e2fs_nlink != 0) {
/*
* Access for write is interpreted as allowing
* creation of files in the directory.
*/
if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0)
error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc);
if (error)
return (error);
/*
* Return an indication of where the new directory
@ -495,17 +500,25 @@ searchloop:
* dp->i_offset + dp->i_count.
*/
if (slotstatus == NONE) {
dp->i_offset = roundup(dp->i_e2fs_size, dirblksize);
dp->i_offset = roundup(dp->i_e2fs_size, dirblksiz);
dp->i_count = 0;
enduseful = dp->i_offset;
} else if (nameiop == DELETE) {
dp->i_offset = slotoffset;
if ((dp->i_offset & (dirblksiz - 1)) == 0)
dp->i_count = 0;
else
dp->i_count = dp->i_offset - prevoff;
} else {
dp->i_offset = slotoffset;
dp->i_count = slotsize;
if (enduseful < slotoffset + slotsize)
enduseful = slotoffset + slotsize;
}
dp->i_endoff = roundup(enduseful, dirblksize);
dp->i_endoff = roundup(enduseful, dirblksiz);
#if 0
dp->i_flag |= IN_CHANGE | IN_UPDATE;
#endif
/*
* We return with the directory locked, so that
* the parameters we set up above will still be
@ -534,17 +547,18 @@ searchloop:
return (ENOENT);
found:
if (numdirpasses == 2)
nchstats.ncs_pass2++;
/*
* Check that directory length properly reflects presence
* of this entry.
*/
if (entryoffsetinblock + EXT2FS_DIRSIZ(ep->e2d_namlen)
> dp->i_e2fs_size) {
if (dp->i_offset + EXT2FS_DIRSIZ(ep->e2d_namlen) > dp->i_e2fs_size) {
ufs_dirbad(dp, dp->i_offset, "i_size too small");
dp->i_e2fs_size = entryoffsetinblock +
EXT2FS_DIRSIZ(ep->e2d_namlen);
dp->i_e2fs_size = dp->i_offset + EXT2FS_DIRSIZ(ep->e2d_namlen);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
}
brelse(bp);
/*
* Found component in pathname.
@ -552,7 +566,7 @@ found:
* in the cache as to where the entry was found.
*/
if ((flags & ISLASTCN) && nameiop == LOOKUP)
dp->i_diroff = dp->i_offset &~ (dirblksize - 1);
dp->i_diroff = dp->i_offset &~ (dirblksiz - 1);
/*
* If deleting, and at end of pathname, return
@ -573,7 +587,7 @@ found:
* is a previous entry in this block) in dp->i_count.
* Save directory inode pointer in ndp->ni_dvp for dirremove().
*/
if ((dp->i_offset & (dirblksize - 1)) == 0)
if ((dp->i_offset & (dirblksiz - 1)) == 0)
dp->i_count = 0;
else
dp->i_count = dp->i_offset - prevoff;
@ -582,7 +596,12 @@ found:
*vpp = vdp;
return (0);
}
if ((error = VFS_VGET(vdp->v_mount, foundino, &tdp)) != 0)
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp, 0); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
return (error);
/*
* If directory is "sticky", then user must own
@ -591,9 +610,9 @@ found:
* implements append-only directories.
*/
if ((dp->i_e2fs_mode & ISVTX) &&
cred->cr_uid != 0 &&
cred->cr_uid != dp->i_e2fs_uid &&
VTOI(tdp)->i_e2fs_uid != cred->cr_uid) {
cred->cr_uid != 0 &&
cred->cr_uid != dp->i_e2fs_uid &&
VTOI(tdp)->i_e2fs_uid != cred->cr_uid) {
vput(tdp);
return (EPERM);
}
@ -611,8 +630,7 @@ found:
* Must get inode of directory entry to verify it's a
* regular file, or empty directory.
*/
if (nameiop == RENAME && wantparent &&
(flags & ISLASTCN)) {
if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) {
error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc);
if (error)
return (error);
@ -622,7 +640,11 @@ found:
*/
if (dp->i_number == foundino)
return (EISDIR);
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp, 0); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
return (error);
*vpp = tdp;
@ -675,7 +697,8 @@ found:
VREF(vdp); /* we want ourself, ie "." */
*vpp = vdp;
} else {
if ((error = VFS_VGET(vdp->v_mount, foundino, &tdp)) != 0)
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (error)
return (error);
if (!lockparent || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
@ -709,7 +732,8 @@ ext2fs_dirbadentry(dp, de, entryoffsetinblock)
struct ext2fs_direct *de;
int entryoffsetinblock;
{
int dirblksize = VTOI(dp)->i_e2fs->e2fs_bsize;
struct ufsmount *ump = VFSTOUFS(dp->v_mount);
int dirblksiz = ump->um_dirblksiz;
char * error_msg = NULL;
int reclen = fs2h16(de->e2d_reclen);
@ -721,7 +745,7 @@ ext2fs_dirbadentry(dp, de, entryoffsetinblock)
error_msg = "rec_len % 4 != 0";
else if (reclen < EXT2FS_DIRSIZ(namlen))
error_msg = "reclen is too small for name_len";
else if (entryoffsetinblock + reclen > dirblksize)
else if (entryoffsetinblock + reclen > dirblksiz)
error_msg = "directory entry across blocks";
else if (fs2h32(de->e2d_ino) >
VTOI(dp)->i_e2fs->e2fs.e2fs_icount)
@ -761,8 +785,8 @@ ext2fs_direnter(ip, dvp, cnp)
u_int dsize;
int error, loc, newentrysize, spacefree;
char *dirbuf;
int dirblksize = ip->i_e2fs->e2fs_bsize;
struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
int dirblksiz = ump->um_dirblksiz;
#ifdef DIAGNOSTIC
if ((cnp->cn_flags & SAVENAME) == 0)
@ -786,10 +810,10 @@ ext2fs_direnter(ip, dvp, cnp)
* be on a directory block boundary and we will write the
* new entry into a fresh block.
*/
if (dp->i_offset & (dirblksize - 1))
if (dp->i_offset & (dirblksiz - 1))
panic("ext2fs_direnter: newblk");
auio.uio_offset = dp->i_offset;
newdir.e2d_reclen = h2fs16(dirblksize);
newdir.e2d_reclen = h2fs16(dirblksiz);
auio.uio_resid = newentrysize;
aiov.iov_len = newentrysize;
aiov.iov_base = (caddr_t)&newdir;
@ -799,12 +823,11 @@ ext2fs_direnter(ip, dvp, cnp)
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_procp = (struct proc *)0;
error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred);
if (dirblksize >
VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
if (dirblksiz > dvp->v_mount->mnt_stat.f_bsize)
/* XXX should grow with balloc() */
panic("ext2fs_direnter: frag size");
else if (!error) {
dp->i_e2fs_size = roundup(dp->i_e2fs_size, dirblksize);
dp->i_e2fs_size = roundup(dp->i_e2fs_size, dirblksiz);
dp->i_flag |= IN_CHANGE;
}
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_readwrite.c,v 1.32 2004/03/22 19:23:08 bouyer Exp $ */
/* $NetBSD: ext2fs_readwrite.c,v 1.33 2004/08/15 07:19:56 mycroft Exp $ */
/*-
* Copyright (c) 1993
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.32 2004/03/22 19:23:08 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.33 2004/08/15 07:19:56 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -81,6 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.32 2004/03/22 19:23:08 bouyer
#include <sys/signalvar.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/ufs_extern.h>
#include <ufs/ext2fs/ext2fs.h>
#include <ufs/ext2fs/ext2fs_extern.h>
@ -114,54 +115,53 @@ ext2fs_read(v)
off_t bytesinfile;
long size, xfersize, blkoffset;
int error;
struct ufsmount *ump;
vp = ap->a_vp;
ip = VTOI(vp);
ump = ip->i_ump;
uio = ap->a_uio;
error = 0;
#ifdef DIAGNOSTIC
if (uio->uio_rw != UIO_READ)
panic("%s: mode", "ext2fs_read");
if (vp->v_type == VLNK) {
if ((int)ip->i_e2fs_size < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 &&
ip->i_e2fs_nblock == 0))
if (ip->i_e2fs_size < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && ip->i_e2fs_nblock == 0))
panic("%s: short symlink", "ext2fs_read");
} else if (vp->v_type != VREG && vp->v_type != VDIR)
panic("%s: type %d", "ext2fs_read", vp->v_type);
#endif
fs = ip->i_e2fs;
if ((u_int64_t)uio->uio_offset >
((u_int64_t)0x80000000 * fs->e2fs_bsize - 1))
if ((u_int64_t)uio->uio_offset > ump->um_maxfilesize)
return (EFBIG);
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset >= ip->i_e2fs_size)
return (0);
goto out;
if (vp->v_type == VREG) {
error = 0;
while (uio->uio_resid > 0) {
bytelen = MIN(ip->i_e2fs_size - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0) {
if (bytelen == 0)
break;
}
win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
&bytelen, UBC_READ);
error = uiomove(win, bytelen, uio);
ubc_release(win, 0);
if (error) {
if (error)
break;
}
}
goto out;
}
for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
if ((bytesinfile = ip->i_e2fs_size - uio->uio_offset) <= 0)
bytesinfile = ip->i_e2fs_size - uio->uio_offset;
if (bytesinfile <= 0)
break;
lbn = lblkno(fs, uio->uio_offset);
nextlbn = lbn + 1;
@ -239,14 +239,17 @@ ext2fs_write(v)
void *win;
off_t oldoff;
boolean_t async;
int extended=0;
int extended = 0;
struct ufsmount *ump;
ioflag = ap->a_ioflag;
uio = ap->a_uio;
vp = ap->a_vp;
ip = VTOI(vp);
ump = ip->i_ump;
error = 0;
KASSERT(vp->v_size == ip->i_size);
#ifdef DIAGNOSTIC
if (uio->uio_rw != UIO_WRITE)
panic("%s: mode", "ext2fs_write");
@ -257,7 +260,7 @@ ext2fs_write(v)
if (ioflag & IO_APPEND)
uio->uio_offset = ip->i_e2fs_size;
if ((ip->i_e2fs_flags & EXT2_APPEND) &&
uio->uio_offset != ip->i_e2fs_size)
uio->uio_offset != ip->i_e2fs_size)
return (EPERM);
/* FALLTHROUGH */
case VLNK:
@ -272,8 +275,7 @@ ext2fs_write(v)
fs = ip->i_e2fs;
if (uio->uio_offset < 0 ||
(u_int64_t)uio->uio_offset + uio->uio_resid >
((u_int64_t)0x80000000 * fs->e2fs_bsize - 1))
(u_int64_t)uio->uio_offset + uio->uio_resid > ump->um_maxfilesize)
return (EFBIG);
/*
* Maybe this should be above the vnode op call, but so long as
@ -281,8 +283,8 @@ ext2fs_write(v)
*/
p = uio->uio_procp;
if (vp->v_type == VREG && p &&
uio->uio_offset + uio->uio_resid >
p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
uio->uio_offset + uio->uio_resid >
p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
psignal(p, SIGXFSZ);
return (EFBIG);
}
@ -302,16 +304,14 @@ ext2fs_write(v)
error = ufs_balloc_range(vp, uio->uio_offset,
bytelen, ap->a_cred, 0);
if (error) {
if (error)
break;
}
win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
&bytelen, UBC_WRITE);
error = uiomove(win, bytelen, uio);
ubc_release(win, 0);
if (error) {
if (error)
break;
}
/*
* update UVM's notion of the size now that we've

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vfsops.c,v 1.74 2004/08/14 01:08:02 mycroft Exp $ */
/* $NetBSD: ext2fs_vfsops.c,v 1.75 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.74 2004/08/14 01:08:02 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.75 2004/08/15 07:19:56 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -654,10 +654,10 @@ ext2fs_mountfs(devvp, mp, p)
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_EXT2FS);
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
mp->mnt_stat.f_namemax = MAXNAMLEN;
mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN;
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_dev_bshift = DEV_BSHIFT; /* XXX */
mp->mnt_fs_bshift = m_fs->e2fs_bshift;
mp->mnt_iflag |= IMNT_DTYPE;
ump->um_flags = 0;
ump->um_mountp = mp;
ump->um_dev = dev;
@ -666,6 +666,9 @@ ext2fs_mountfs(devvp, mp, p)
ump->um_lognindir = ffs(NINDIR(m_fs)) - 1;
ump->um_bptrtodb = m_fs->e2fs_fsbtodb;
ump->um_seqinc = 1; /* no frags */
ump->um_maxsymlinklen = EXT2_MAXSYMLINKLEN;
ump->um_dirblksiz = m_fs->e2fs_bsize;
ump->um_maxfilesize = ((u_int64_t)0x80000000 * m_fs->e2fs_bsize - 1);
devvp->v_specmountpoint = mp;
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vnops.c,v 1.54 2004/08/14 14:32:04 mycroft Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.55 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.54 2004/08/14 14:32:04 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.55 2004/08/15 07:19:56 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1044,19 +1044,18 @@ ext2fs_mkdir(v)
struct componentname *a_cnp;
struct vattr *a_vap;
} */ *ap = v;
struct vnode *dvp = ap->a_dvp;
struct vattr *vap = ap->a_vap;
struct componentname *cnp = ap->a_cnp;
struct inode *ip, *dp;
struct vnode *tvp;
struct vnode *dvp = ap->a_dvp;
struct vattr *vap = ap->a_vap;
struct componentname *cnp = ap->a_cnp;
struct inode *ip, *dp = VTOI(dvp);
struct vnode *tvp;
struct ext2fs_dirtemplate dirtemplate;
int error, dmode;
int error, dmode;
#ifdef DIAGNOSTIC
if ((cnp->cn_flags & HASBUF) == 0)
panic("ext2fs_mkdir: no name");
#endif
dp = VTOI(dvp);
if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) {
error = EMLINK;
goto out;
@ -1077,7 +1076,6 @@ ext2fs_mkdir(v)
ip->i_e2fs_mode = dmode;
tvp->v_type = VDIR; /* Rest init'd in getnewvnode(). */
ip->i_e2fs_nlink = 2;
error = VOP_UPDATE(tvp, NULL, NULL, UPDATE_WAIT);
/*
* Bump link count in parent directory
@ -1087,7 +1085,7 @@ ext2fs_mkdir(v)
*/
dp->i_e2fs_nlink++;
dp->i_flag |= IN_CHANGE;
if ((error = VOP_UPDATE(dvp, NULL, NULL, UPDATE_WAIT)) != 0)
if ((error = VOP_UPDATE(dvp, NULL, NULL, UPDATE_DIROP)) != 0)
goto bad;
/* Initialize directory with "." and ".." from static template. */
@ -1116,8 +1114,7 @@ ext2fs_mkdir(v)
dp->i_flag |= IN_CHANGE;
goto bad;
}
if (VTOI(dvp)->i_e2fs->e2fs_bsize >
VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
if (VTOI(dvp)->i_e2fs->e2fs_bsize > dvp->v_mount->mnt_stat.f_bsize)
panic("ext2fs_mkdir: blksize"); /* XXX should grow with balloc() */
else {
ip->i_e2fs_size = VTOI(dvp)->i_e2fs->e2fs_bsize;
@ -1246,10 +1243,11 @@ ext2fs_symlink(v)
struct vattr *a_vap;
char *a_target;
} */ *ap = v;
struct vnode *vp, **vpp = ap->a_vpp;
struct inode *ip;
int len, error;
struct vnode *vp, **vpp;
struct inode *ip;
int len, error;
vpp = ap->a_vpp;
error = ext2fs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
vpp, ap->a_cnp);
if (error)
@ -1257,8 +1255,8 @@ ext2fs_symlink(v)
VN_KNOTE(ap->a_dvp, NOTE_WRITE);
vp = *vpp;
len = strlen(ap->a_target);
if (len < vp->v_mount->mnt_maxsymlinklen) {
ip = VTOI(vp);
ip = VTOI(vp);
if (len < ip->i_ump->um_maxsymlinklen) {
memcpy((char *)ip->i_din.e2fs_din->e2di_shortlink, ap->a_target, len);
ip->i_e2fs_size = len;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
@ -1283,13 +1281,14 @@ ext2fs_readlink(v)
struct uio *a_uio;
struct ucred *a_cred;
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct inode *ip = VTOI(vp);
int isize;
struct vnode *vp = ap->a_vp;
struct inode *ip = VTOI(vp);
struct ufsmount *ump = ip->i_ump;
int isize;
isize = ip->i_e2fs_size;
if (isize < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 && ip->i_e2fs_nblock == 0)) {
if (isize < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && ip->i_e2fs_nblock == 0)) {
uiomove((char *)ip->i_din.e2fs_din->e2di_shortlink, isize, ap->a_uio);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_inode.c,v 1.67 2004/08/14 02:26:57 mycroft Exp $ */
/* $NetBSD: ffs_inode.c,v 1.68 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.67 2004/08/14 02:26:57 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.68 2004/08/15 07:19:56 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -186,7 +186,7 @@ ffs_truncate(v)
struct vnode *ovp = ap->a_vp;
struct genfs_node *gp = VTOG(ovp);
daddr_t lastblock;
struct inode *oip;
struct inode *oip = VTOI(ovp);
daddr_t bn, lastiblock[NIADDR], indir_lbn[NIADDR];
daddr_t blks[NDADDR + NIADDR];
off_t length = ap->a_length;
@ -197,14 +197,14 @@ ffs_truncate(v)
int error, allerror = 0;
off_t osize;
int sync;
struct ufsmount *ump = oip->i_ump;
if (length < 0)
return (EINVAL);
oip = VTOI(ovp);
if (ovp->v_type == VLNK &&
(oip->i_size < ovp->v_mount->mnt_maxsymlinklen ||
(ovp->v_mount->mnt_maxsymlinklen == 0 &&
DIP(oip, blocks) == 0))) {
(oip->i_size < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && DIP(oip, blocks) == 0))) {
KDASSERT(length == 0);
memset(SHORTLINK(oip), 0, (size_t)oip->i_size);
oip->i_size = 0;
@ -221,7 +221,7 @@ ffs_truncate(v)
return (error);
#endif
fs = oip->i_fs;
if (length > fs->fs_maxfilesize)
if (length > ump->um_maxfilesize)
return (EFBIG);
if ((oip->i_flags & SF_SNAPSHOT) != 0)
@ -243,9 +243,8 @@ ffs_truncate(v)
blkroundup(fs, osize) != osize) {
error = ufs_balloc_range(ovp, osize,
blkroundup(fs, osize) - osize, ap->a_cred, aflag);
if (error) {
if (error)
return error;
}
if (ioflag & IO_SYNC) {
ovp->v_size = blkroundup(fs, osize);
simple_lock(&ovp->v_interlock);
@ -260,12 +259,12 @@ ffs_truncate(v)
if (error) {
(void) VOP_TRUNCATE(ovp, osize, ioflag & IO_SYNC,
ap->a_cred, ap->a_p);
return error;
return (error);
}
uvm_vnp_setsize(ovp, length);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
KASSERT(ovp->v_size == oip->i_size);
return (VOP_UPDATE(ovp, NULL, NULL, 1));
return (VOP_UPDATE(ovp, NULL, NULL, 0));
}
/*
@ -367,8 +366,8 @@ ffs_truncate(v)
DIP_ASSIGN(oip, db[i], 0);
}
}
oip->i_flag |= IN_CHANGE | IN_UPDATE;
if (sync) {
oip->i_flag |= IN_CHANGE | IN_UPDATE;
error = VOP_UPDATE(ovp, NULL, NULL, UPDATE_WAIT);
if (error && !allerror)
allerror = error;
@ -499,8 +498,6 @@ done:
DIP_ADD(oip, blocks, -blocksreleased);
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
oip->i_flag |= IN_CHANGE;
if (!sync)
oip->i_flag |= IN_UPDATE;
#ifdef QUOTA
(void) chkdq(oip, -blocksreleased, NOCRED, 0);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_vfsops.c,v 1.152 2004/08/14 01:08:03 mycroft Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.153 2004/08/15 07:19:56 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.152 2004/08/14 01:08:03 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.153 2004/08/15 07:19:56 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -452,8 +452,8 @@ ffs_mount(mp, path, data, ndp, p)
* 6) re-read inode data for all active vnodes.
*/
int
ffs_reload(mountp, cred, p)
struct mount *mountp;
ffs_reload(mp, cred, p)
struct mount *mp;
struct ucred *cred;
struct proc *p;
{
@ -468,10 +468,10 @@ ffs_reload(mountp, cred, p)
struct ufsmount *ump;
daddr_t sblockloc;
if ((mountp->mnt_flag & MNT_RDONLY) == 0)
if ((mp->mnt_flag & MNT_RDONLY) == 0)
return (EINVAL);
ump = VFSTOUFS(mountp);
ump = VFSTOUFS(mp);
/*
* Step 1: invalidate all cached meta-data.
*/
@ -530,13 +530,13 @@ ffs_reload(mountp, cred, p)
free(newfs, M_UFSMNT);
/* Recheck for apple UFS filesystem */
VFSTOUFS(mountp)->um_flags &= ~UFS_ISAPPLEUFS;
ump->um_flags &= ~UFS_ISAPPLEUFS;
/* First check to see if this is tagged as an Apple UFS filesystem
* in the disklabel
*/
if ((VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, cred, p) == 0) &&
(dpart.part->p_fstype == FS_APPLEUFS)) {
VFSTOUFS(mountp)->um_flags |= UFS_ISAPPLEUFS;
ump->um_flags |= UFS_ISAPPLEUFS;
}
#ifdef APPLE_UFS
else {
@ -551,29 +551,37 @@ ffs_reload(mountp, cred, p)
}
error = ffs_appleufs_validate(fs->fs_fsmnt,
(struct appleufslabel *)bp->b_data,NULL);
if (error == 0) {
VFSTOUFS(mountp)->um_flags |= UFS_ISAPPLEUFS;
}
if (error == 0)
ump->um_flags |= UFS_ISAPPLEUFS;
brelse(bp);
bp = NULL;
}
#else
if (VFSTOUFS(mountp)->um_flags & UFS_ISAPPLEUFS)
if (ump->um_flags & UFS_ISAPPLEUFS)
return (EIO);
#endif
mountp->mnt_maxsymlinklen = fs->fs_maxsymlinklen;
if (UFS_MPISAPPLEUFS(mountp)) {
if (UFS_MPISAPPLEUFS(ump)) {
/* see comment about NeXT below */
mountp->mnt_maxsymlinklen = APPLEUFS_MAXSYMLINKLEN;
ump->um_maxsymlinklen = APPLEUFS_MAXSYMLINKLEN;
ump->um_dirblksiz = APPLEUFS_DIRBLKSIZ;
mp->mnt_iflag |= IMNT_DTYPE;
} else {
ump->um_maxsymlinklen = fs->fs_maxsymlinklen;
ump->um_dirblksiz = DIRBLKSIZ;
if (ump->um_maxsymlinklen > 0)
mp->mnt_iflag |= IMNT_DTYPE;
else
mp->mnt_iflag &= ~IMNT_DTYPE;
}
ffs_oldfscompat_read(fs, VFSTOUFS(mountp), sblockloc);
ump->um_maxfilesize = fs->fs_maxfilesize;
ffs_oldfscompat_read(fs, ump, sblockloc);
if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) {
fs->fs_pendingblocks = 0;
fs->fs_pendinginodes = 0;
}
ffs_statvfs(mountp, &mountp->mnt_stat, p);
ffs_statvfs(mp, &mp->mnt_stat, p);
/*
* Step 3: re-read summary information from disk.
*/
@ -600,9 +608,9 @@ ffs_reload(mountp, cred, p)
brelse(bp);
}
if ((fs->fs_flags & FS_DOSOFTDEP))
softdep_mount(devvp, mountp, fs, cred);
softdep_mount(devvp, mp, fs, cred);
if (fs->fs_snapinum[0] != 0)
ffs_snapshot_mount(mountp);
ffs_snapshot_mount(mp);
/*
* We no longer know anything about clusters per cylinder group.
*/
@ -614,8 +622,8 @@ ffs_reload(mountp, cred, p)
loop:
simple_lock(&mntvnode_slock);
for (vp = mountp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
if (vp->v_mount != mountp) {
for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
if (vp->v_mount != mp) {
simple_unlock(&mntvnode_slock);
goto loop;
}
@ -807,6 +815,7 @@ ffs_mountfs(devvp, mp, p)
#endif
fs->fs_flags &= ~FS_SWAPPED;
ump->um_maxfilesize = fs->fs_maxfilesize;
ffs_oldfscompat_read(fs, ump, sblockloc);
if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) {
@ -923,14 +932,22 @@ ffs_mountfs(devvp, mp, p)
mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_FFS);
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
mp->mnt_stat.f_namemax = MAXNAMLEN;
mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen;
if (UFS_MPISAPPLEUFS(mp)) {
if (UFS_MPISAPPLEUFS(ump)) {
/* NeXT used to keep short symlinks in the inode even
* when using FS_42INODEFMT. In that case fs->fs_maxsymlinklen
* is probably -1, but we still need to be able to identify
* short symlinks.
*/
mp->mnt_maxsymlinklen = APPLEUFS_MAXSYMLINKLEN;
ump->um_maxsymlinklen = APPLEUFS_MAXSYMLINKLEN;
ump->um_dirblksiz = APPLEUFS_DIRBLKSIZ;
mp->mnt_iflag |= IMNT_DTYPE;
} else {
ump->um_maxsymlinklen = fs->fs_maxsymlinklen;
ump->um_dirblksiz = DIRBLKSIZ;
if (ump->um_maxsymlinklen > 0)
mp->mnt_iflag |= IMNT_DTYPE;
else
mp->mnt_iflag &= ~IMNT_DTYPE;
}
mp->mnt_fs_bshift = fs->fs_bshift;
mp->mnt_dev_bshift = DEV_BSHIFT; /* XXX */
@ -1034,14 +1051,14 @@ ffs_oldfscompat_read(fs, ump, sblockloc)
}
if (fs->fs_old_inodefmt < FS_44INODEFMT) {
fs->fs_maxfilesize = (u_quad_t) 1LL << 39;
ump->um_maxfilesize = (u_quad_t) 1LL << 39;
fs->fs_qbmask = ~fs->fs_bmask;
fs->fs_qfmask = ~fs->fs_fmask;
}
maxfilesize = (u_int64_t)0x80000000 * fs->fs_bsize - 1;
if (fs->fs_maxfilesize > maxfilesize)
fs->fs_maxfilesize = maxfilesize;
if (ump->um_maxfilesize > maxfilesize)
ump->um_maxfilesize = maxfilesize;
/* Compatibility for old filesystems */
if (fs->fs_avgfilesize <= 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.c,v 1.84 2004/08/14 01:08:04 mycroft Exp $ */
/* $NetBSD: lfs_inode.c,v 1.85 2004/08/15 07:19:56 mycroft Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.84 2004/08/14 01:08:04 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.85 2004/08/15 07:19:56 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -230,7 +230,7 @@ lfs_truncate(void *v)
struct vnode *ovp = ap->a_vp;
struct genfs_node *gp = VTOG(ovp);
daddr_t lastblock;
struct inode *oip;
struct inode *oip = VTOI(ovp);
daddr_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR];
/* XXX ondisk32 */
int32_t newblks[NDADDR + NIADDR];
@ -247,10 +247,10 @@ lfs_truncate(void *v)
size_t bc;
int obufsize, odb;
int usepc;
struct ufsmount *ump = oip->i_ump;
if (length < 0)
return (EINVAL);
oip = VTOI(ovp);
/*
* Just return and not update modification times.
@ -259,8 +259,8 @@ lfs_truncate(void *v)
return (0);
if (ovp->v_type == VLNK &&
(oip->i_size < ovp->v_mount->mnt_maxsymlinklen ||
(ovp->v_mount->mnt_maxsymlinklen == 0 &&
(oip->i_size < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 &&
oip->i_ffs1_blocks == 0))) {
#ifdef DIAGNOSTIC
if (length != 0)
@ -290,7 +290,7 @@ lfs_truncate(void *v)
* value of osize is 0, length will be at least 1.
*/
if (osize < length) {
if (length > fs->lfs_maxfilesize)
if (length > ump->um_maxfilesize)
return (EFBIG);
aflags = B_CLRBUF;
if (ap->a_flags & IO_SYNC)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.155 2004/08/14 01:08:06 mycroft Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.156 2004/08/15 07:19:58 mycroft Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.155 2004/08/14 01:08:06 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.156 2004/08/15 07:19:58 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -1058,7 +1058,6 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
mp->mnt_stat.f_namemax = MAXNAMLEN;
mp->mnt_stat.f_iosize = fs->lfs_bsize;
mp->mnt_maxsymlinklen = fs->lfs_maxsymlinklen;
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_fs_bshift = fs->lfs_bshift;
ump->um_flags = 0;
@ -1071,6 +1070,8 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
ump->um_lognindir = ffs(fs->lfs_nindir) - 1;
for (i = 0; i < MAXQUOTAS; i++)
ump->um_quotas[i] = NULLVP;
ump->um_maxsymlinklen = fs->lfs_maxsymlinklen;
ump->um_maxfilesize = fs->lfs_maxfilesize;
devvp->v_specmountpoint = mp;
/* Set up reserved memory for pageout */
@ -2061,8 +2062,7 @@ lfs_vinit(struct mount *mp, struct vnode **vpp)
ufs_vinit(mp, lfs_specop_p, lfs_fifoop_p, &vp);
memset(ip->i_lfs_fragsize, 0, NDADDR * sizeof(*ip->i_lfs_fragsize));
if (vp->v_type != VLNK ||
VTOI(vp)->i_size >= vp->v_mount->mnt_maxsymlinklen) {
if (vp->v_type != VLNK || ip->i_size >= ip->i_ump->um_maxsymlinklen) {
struct lfs *fs = ump->um_lfs;
#ifdef DEBUG
for (i = (ip->i_size + fs->lfs_bsize - 1) >> fs->lfs_bshift;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_bmap.c,v 1.30 2004/07/24 15:02:32 dbj Exp $ */
/* $NetBSD: ufs_bmap.c,v 1.31 2004/08/15 07:19:58 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.30 2004/07/24 15:02:32 dbj Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.31 2004/08/15 07:19:58 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -136,7 +136,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, is_sequential)
ip = VTOI(vp);
mp = vp->v_mount;
ump = VFSTOUFS(mp);
ump = ip->i_ump;
#ifdef DIAGNOSTIC
if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
panic("ufs_bmaparray: invalid arguments");

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_bswap.h,v 1.13 2003/10/05 17:48:50 bouyer Exp $ */
/* $NetBSD: ufs_bswap.h,v 1.14 2004/08/15 07:19:58 mycroft Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@ -41,13 +41,13 @@
/* Macros to access UFS flags */
#ifdef FFS_EI
#define UFS_MPNEEDSWAP(mp) (VFSTOUFS(mp)->um_flags & UFS_NEEDSWAP)
#define UFS_MPNEEDSWAP(ump) ((ump)->um_flags & UFS_NEEDSWAP)
#define UFS_FSNEEDSWAP(fs) ((fs)->fs_flags & FS_SWAPPED)
#define UFS_IPNEEDSWAP(ip) UFS_MPNEEDSWAP(ITOV(ip)->v_mount)
#define UFS_IPNEEDSWAP(ip) UFS_MPNEEDSWAP((ip)->i_ump)
#else
#define UFS_MPNEEDSWAP(mp) (0)
#define UFS_FSNEEDSWAP(fs) (0)
#define UFS_IPNEEDSWAP(ip) (0)
#define UFS_MPNEEDSWAP(ump) (0)
#define UFS_FSNEEDSWAP(fs) (0)
#define UFS_IPNEEDSWAP(ip) (0)
#endif
#if !defined(_KERNEL) || defined(FFS_EI)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_lookup.c,v 1.57 2004/05/25 14:55:46 hannken Exp $ */
/* $NetBSD: ufs_lookup.c,v 1.58 2004/08/15 07:19:58 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.57 2004/05/25 14:55:46 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.58 2004/08/15 07:19:58 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -61,7 +61,7 @@ int dirchk = 1;
int dirchk = 0;
#endif
#define FSFMT(vp) ((vp)->v_mount->mnt_maxsymlinklen <= 0)
#define FSFMT(vp) (((vp)->v_mount->mnt_iflag & IMNT_DTYPE) == 0)
/*
* Convert a component of a pathname into a pointer to a locked inode.
@ -105,8 +105,8 @@ ufs_lookup(v)
struct vnode **a_vpp;
struct componentname *a_cnp;
} */ *ap = v;
struct vnode *vdp; /* vnode for directory being searched */
struct inode *dp; /* inode for directory being searched */
struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */
struct inode *dp = VTOI(vdp); /* inode for directory being searched */
struct buf *bp; /* a buffer of directory entries */
struct direct *ep; /* the current directory entry */
int entryoffsetinblock; /* offset of ep in bp's buffer */
@ -130,12 +130,10 @@ ufs_lookup(v)
struct ucred *cred = cnp->cn_cred;
int flags;
int nameiop = cnp->cn_nameiop;
const int needswap = UFS_MPNEEDSWAP(ap->a_dvp->v_mount);
int dirblksiz = DIRBLKSIZ;
struct ufsmount *ump = dp->i_ump;
const int needswap = UFS_MPNEEDSWAP(ump);
int dirblksiz = ump->um_dirblksiz;
ino_t foundino;
if (UFS_MPISAPPLEUFS(ap->a_dvp->v_mount)) {
dirblksiz = APPLEUFS_DIRBLKSIZ;
}
cnp->cn_flags &= ~PDIRUNLOCK;
flags = cnp->cn_flags;
@ -143,12 +141,8 @@ ufs_lookup(v)
bp = NULL;
slotoffset = -1;
*vpp = NULL;
vdp = ap->a_dvp;
dp = VTOI(vdp);
lockparent = flags & LOCKPARENT;
wantparent = flags & (LOCKPARENT|WANTPARENT);
/*
* Check accessiblity of directory.
*/
@ -180,8 +174,7 @@ ufs_lookup(v)
if ((nameiop == CREATE || nameiop == RENAME) &&
(flags & ISLASTCN)) {
slotstatus = NONE;
slotneeded = (sizeof(struct direct) - MAXNAMLEN +
cnp->cn_namelen + 3) &~ 3;
slotneeded = DIRECTSIZ(cnp->cn_namelen);
}
/*
@ -224,7 +217,7 @@ searchloop:
if (bp != NULL)
brelse(bp);
error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL,
&bp);
&bp);
if (error)
return (error);
entryoffsetinblock = 0;
@ -273,7 +266,7 @@ searchloop:
slotstatus = FOUND;
slotoffset = dp->i_offset;
slotsize = ufs_rw16(ep->d_reclen,
needswap);
needswap);
} else if (slotstatus == NONE) {
slotfreespace += size;
if (slotoffset == -1)
@ -282,8 +275,8 @@ searchloop:
slotstatus = COMPACT;
slotsize = dp->i_offset +
ufs_rw16(ep->d_reclen,
needswap)
- slotoffset;
needswap) -
slotoffset;
}
}
}
@ -294,28 +287,25 @@ searchloop:
*/
if (ep->d_ino) {
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (vdp->v_mount->mnt_maxsymlinklen > 0 ||
needswap != 0)
namlen = ep->d_namlen;
else
if (FSFMT(vdp) && needswap == 0)
namlen = ep->d_type;
else
namlen = ep->d_namlen;
#else
if (vdp->v_mount->mnt_maxsymlinklen <= 0
&& needswap != 0)
if (FSFMT(vdp) && needswap != 0)
namlen = ep->d_type;
else
namlen = ep->d_namlen;
#endif
if (namlen == cnp->cn_namelen &&
!memcmp(cnp->cn_nameptr, ep->d_name,
(unsigned)namlen)) {
(unsigned)namlen)) {
/*
* Save directory entry's inode number and
* reclen in ndp->ni_ufs area, and release
* directory buffer.
*/
if (vdp->v_mount->mnt_maxsymlinklen > 0 &&
ep->d_type == DT_WHT) {
if (!FSFMT(vdp) && ep->d_type == DT_WHT) {
slotstatus = FOUND;
slotoffset = dp->i_offset;
slotsize = ufs_rw16(ep->d_reclen,
@ -641,22 +631,20 @@ ufs_dirbadentry(dp, ep, entryoffsetinblock)
{
int i;
int namlen;
const int needswap = UFS_MPNEEDSWAP(dp->v_mount);
int dirblksiz = DIRBLKSIZ;
if (UFS_MPISAPPLEUFS(dp->v_mount)) {
dirblksiz = APPLEUFS_DIRBLKSIZ;
}
struct ufsmount *ump = VFSTOUFS(dp->v_mount);
const int needswap = UFS_MPNEEDSWAP(ump);
int dirblksiz = ump->um_dirblksiz;
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (dp->v_mount->mnt_maxsymlinklen > 0 || needswap != 0)
if (FSFMT(dp) && needswap == 0)
namlen = ep->d_type;
else
namlen = ep->d_namlen;
else
namlen = ep->d_type;
#else
if (dp->v_mount->mnt_maxsymlinklen <= 0 && needswap != 0)
if (FSFMT(dp) && needswap != 0)
namlen = ep->d_type;
else
namlen = ep->d_namlen;
namlen = ep->d_namlen;
#endif
if ((ufs_rw16(ep->d_reclen, needswap) & 0x3) != 0 ||
ufs_rw16(ep->d_reclen, needswap) >
@ -706,11 +694,10 @@ ufs_makedirentry(ip, cnp, newdirp)
newdirp->d_namlen = cnp->cn_namelen;
memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen);
newdirp->d_name[cnp->cn_namelen] = '\0';
if (ITOV(ip)->v_mount->mnt_maxsymlinklen > 0)
newdirp->d_type = IFTODT(ip->i_mode);
else {
if (FSFMT(ITOV(ip)))
newdirp->d_type = 0;
}
else
newdirp->d_type = IFTODT(ip->i_mode);
}
/*
@ -740,11 +727,9 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
int error, ret, blkoff, loc, spacefree, flags;
char *dirbuf;
struct timespec ts;
const int needswap = UFS_MPNEEDSWAP(dvp->v_mount);
int dirblksiz = DIRBLKSIZ;
if (UFS_MPISAPPLEUFS(dvp->v_mount)) {
dirblksiz = APPLEUFS_DIRBLKSIZ;
}
struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
const int needswap = UFS_MPNEEDSWAP(ump);
int dirblksiz = ump->um_dirblksiz;
error = 0;
cr = cnp->cn_cred;
@ -777,7 +762,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
uvm_vnp_setsize(dvp, dp->i_size);
dirp->d_reclen = ufs_rw16(dirblksiz, needswap);
dirp->d_ino = ufs_rw32(dirp->d_ino, needswap);
if (dvp->v_mount->mnt_maxsymlinklen <= 0) {
if (FSFMT(dvp)) {
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (needswap == 0) {
#else
@ -788,8 +773,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
dirp->d_type = tmp;
}
}
blkoff = dp->i_offset &
(VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1);
blkoff = dp->i_offset & (ump->um_mountp->mnt_stat.f_iosize - 1);
memcpy((caddr_t)bp->b_data + blkoff, (caddr_t)dirp,
newentrysize);
if (DOINGSOFTDEP(dvp)) {
@ -917,7 +901,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
}
dirp->d_reclen = ufs_rw16(dirp->d_reclen, needswap);
dirp->d_ino = ufs_rw32(dirp->d_ino, needswap);
if (dvp->v_mount->mnt_maxsymlinklen <= 0) {
if (FSFMT(dvp)) {
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (needswap == 0) {
#else
@ -1065,7 +1049,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype, isrmdir, iflags)
if (error)
return (error);
ep->d_ino = ufs_rw32(newinum, UFS_MPNEEDSWAP(vdp->v_mount));
if (vdp->v_mount->mnt_maxsymlinklen > 0)
if (!FSFMT(vdp))
ep->d_type = newtype;
oip->i_ffs_effnlink--;
if (DOINGSOFTDEP(vdp)) {
@ -1130,12 +1114,12 @@ ufs_dirempty(ip, parentino, cred)
continue;
/* accept only "." and ".." */
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (ITOV(ip)->v_mount->mnt_maxsymlinklen > 0 || needswap != 0)
namlen = dp->d_namlen;
else
if (FSFMT(ITOV(ip)) && needswap == 0)
namlen = dp->d_type;
else
namlen = dp->d_namlen;
#else
if (ITOV(ip)->v_mount->mnt_maxsymlinklen <= 0 && needswap != 0)
if (FSFMT(ITOV(ip)) && needswap != 0)
namlen = dp->d_type;
else
namlen = dp->d_namlen;
@ -1196,14 +1180,12 @@ ufs_checkpath(source, target, cred)
if (error != 0)
break;
#if (BYTE_ORDER == LITTLE_ENDIAN)
if (vp->v_mount->mnt_maxsymlinklen > 0 ||
needswap != 0)
namlen = dirbuf.dotdot_namlen;
else
if (FSFMT(vp) && needswap == 0)
namlen = dirbuf.dotdot_type;
else
namlen = dirbuf.dotdot_namlen;
#else
if (vp->v_mount->mnt_maxsymlinklen == 0 &&
needswap != 0)
if (FSFMT(vp) && needswap != 0)
namlen = dirbuf.dotdot_type;
else
namlen = dirbuf.dotdot_namlen;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_quota.c,v 1.30 2003/11/05 10:18:38 hannken Exp $ */
/* $NetBSD: ufs_quota.c,v 1.31 2004/08/15 07:19:58 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.30 2003/11/05 10:18:38 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.31 2004/08/15 07:19:58 mycroft Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -69,11 +69,10 @@ int
getinoquota(ip)
struct inode *ip;
{
struct ufsmount *ump;
struct ufsmount *ump = ip->i_ump;
struct vnode *vp = ITOV(ip);
int error;
ump = VFSTOUFS(vp->v_mount);
/*
* Set up the user quota based on file uid.
* EINVAL means that quotas are not enabled.
@ -188,8 +187,7 @@ chkdqchg(ip, change, cred, type)
*/
if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) {
if (dq->dq_curblocks < dq->dq_bsoftlimit) {
dq->dq_btime = time.tv_sec +
VFSTOUFS(ITOV(ip)->v_mount)->um_btime[type];
dq->dq_btime = time.tv_sec + ip->i_ump->um_btime[type];
if (ip->i_uid == cred->cr_uid)
uprintf("\n%s: warning, %s %s\n",
ITOV(ip)->v_mount->mnt_stat.f_mntonname,
@ -303,8 +301,7 @@ chkiqchg(ip, change, cred, type)
*/
if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) {
if (dq->dq_curinodes < dq->dq_isoftlimit) {
dq->dq_itime = time.tv_sec +
VFSTOUFS(ITOV(ip)->v_mount)->um_itime[type];
dq->dq_itime = time.tv_sec + ip->i_ump->um_itime[type];
if (ip->i_uid == cred->cr_uid)
uprintf("\n%s: warning, %s %s\n",
ITOV(ip)->v_mount->mnt_stat.f_mntonname,
@ -335,7 +332,7 @@ void
chkdquot(ip)
struct inode *ip;
{
struct ufsmount *ump = VFSTOUFS(ITOV(ip)->v_mount);
struct ufsmount *ump = ip->i_ump;
int i;
for (i = 0; i < MAXQUOTAS; i++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_readwrite.c,v 1.55 2003/08/07 16:34:46 agc Exp $ */
/* $NetBSD: ufs_readwrite.c,v 1.56 2004/08/15 07:19:58 mycroft Exp $ */
/*-
* Copyright (c) 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.55 2003/08/07 16:34:46 agc Exp $");
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.56 2004/08/15 07:19:58 mycroft Exp $");
#ifdef LFS_READWRITE
#define BLKSIZE(a, b, c) blksize(a, b, c)
@ -79,9 +79,11 @@ READ(void *v)
long size, xfersize, blkoffset;
int error;
boolean_t usepc = FALSE;
struct ufsmount *ump;
vp = ap->a_vp;
ip = VTOI(vp);
ump = ip->i_ump;
uio = ap->a_uio;
error = 0;
@ -90,21 +92,19 @@ READ(void *v)
panic("%s: mode", READ_S);
if (vp->v_type == VLNK) {
if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 &&
DIP(ip, blocks) == 0))
if (ip->i_size < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && DIP(ip, blocks) == 0))
panic("%s: short symlink", READ_S);
} else if (vp->v_type != VREG && vp->v_type != VDIR)
panic("%s: type %d", READ_S, vp->v_type);
#endif
fs = ip->I_FS;
if ((u_int64_t)uio->uio_offset > fs->fs_maxfilesize)
if ((u_int64_t)uio->uio_offset > ump->um_maxfilesize)
return (EFBIG);
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset >= ip->i_size) {
if (uio->uio_offset >= ip->i_size)
goto out;
}
#ifdef LFS_READWRITE
usepc = (vp->v_type == VREG && ip->i_number != LFS_IFILE_INUM);
@ -119,7 +119,7 @@ READ(void *v)
break;
win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
&bytelen, UBC_READ);
&bytelen, UBC_READ);
error = uiomove(win, bytelen, uio);
ubc_release(win, 0);
if (error)
@ -212,6 +212,7 @@ WRITE(void *v)
#ifdef LFS_READWRITE
boolean_t need_unreserve = FALSE;
#endif
struct ufsmount *ump;
cred = ap->a_cred;
ioflag = ap->a_ioflag;
@ -219,6 +220,7 @@ WRITE(void *v)
vp = ap->a_vp;
ip = VTOI(vp);
gp = VTOG(vp);
ump = ip->i_ump;
KASSERT(vp->v_size == ip->i_size);
#ifdef DIAGNOSTIC
@ -245,7 +247,7 @@ WRITE(void *v)
fs = ip->I_FS;
if (uio->uio_offset < 0 ||
(u_int64_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
(u_int64_t)uio->uio_offset + uio->uio_resid > ump->um_maxfilesize)
return (EFBIG);
#ifdef LFS_READWRITE
/* Disallow writes to the Ifile, even if noschg flag is removed */
@ -253,7 +255,6 @@ WRITE(void *v)
if (vp == fs->lfs_ivnode)
return (EPERM);
#endif
/*
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, I don't think it matters.
@ -288,9 +289,8 @@ WRITE(void *v)
}
lfs_check(vp, LFS_UNUSED_LBN, 0);
#endif /* !LFS_READWRITE */
if (!usepc) {
if (!usepc)
goto bcache;
}
preallocoff = round_page(blkroundup(fs, MAX(osize, uio->uio_offset)));
aflag = ioflag & IO_SYNC ? B_SYNC : 0;
@ -386,9 +386,8 @@ WRITE(void *v)
extended = 1;
}
if (error) {
if (error)
break;
}
/*
* flush what we just wrote if necessary.
@ -399,9 +398,8 @@ WRITE(void *v)
simple_lock(&vp->v_interlock);
error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16,
(uio->uio_offset >> 16) << 16, PGO_CLEANIT);
if (error) {
if (error)
break;
}
}
}
if (error == 0 && ioflag & IO_SYNC) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_vnops.c,v 1.118 2004/08/14 01:08:07 mycroft Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.119 2004/08/15 07:20:00 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993, 1995
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.118 2004/08/14 01:08:07 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.119 2004/08/15 07:20:00 mycroft Exp $");
#ifndef _LKM
#include "opt_quota.h"
@ -310,7 +310,7 @@ ufs_getattr(void *v)
vap->va_size = vp->v_size;
if (ip->i_ump->um_fstype == UFS1) {
vap->va_rdev = (dev_t)ufs_rw32(ip->i_ffs1_rdev,
UFS_MPNEEDSWAP(vp->v_mount));
UFS_MPNEEDSWAP(ump));
vap->va_atime.tv_sec = ip->i_ffs1_atime;
vap->va_atime.tv_nsec = ip->i_ffs1_atimensec;
vap->va_mtime.tv_sec = ip->i_ffs1_mtime;
@ -322,7 +322,7 @@ ufs_getattr(void *v)
vap->va_bytes = dbtob((u_quad_t)ip->i_ffs1_blocks);
} else {
vap->va_rdev = (dev_t)ufs_rw64(ip->i_ffs2_rdev,
UFS_MPNEEDSWAP(vp->v_mount));
UFS_MPNEEDSWAP(ump));
vap->va_atime.tv_sec = ip->i_ffs2_atime;
vap->va_atime.tv_nsec = ip->i_ffs2_atimensec;
vap->va_mtime.tv_sec = ip->i_ffs2_mtime;
@ -744,18 +744,17 @@ ufs_whiteout(void *v)
struct componentname *a_cnp;
int a_flags;
} */ *ap = v;
struct vnode *dvp;
struct componentname *cnp;
struct vnode *dvp = ap->a_dvp;
struct componentname *cnp = ap->a_cnp;
struct direct *newdir;
int error;
struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
dvp = ap->a_dvp;
cnp = ap->a_cnp;
error = 0;
switch (ap->a_flags) {
case LOOKUP:
/* 4.4 format directories support whiteout operations */
if (dvp->v_mount->mnt_maxsymlinklen > 0)
if (ump->um_maxsymlinklen > 0)
return (0);
return (EOPNOTSUPP);
@ -764,7 +763,7 @@ ufs_whiteout(void *v)
#ifdef DIAGNOSTIC
if ((cnp->cn_flags & SAVENAME) == 0)
panic("ufs_whiteout: missing name");
if (dvp->v_mount->mnt_maxsymlinklen <= 0)
if (ump->um_maxsymlinklen <= 0)
panic("ufs_whiteout: old format filesystem");
#endif
@ -782,7 +781,7 @@ ufs_whiteout(void *v)
case DELETE:
/* remove an existing directory whiteout */
#ifdef DIAGNOSTIC
if (dvp->v_mount->mnt_maxsymlinklen <= 0)
if (ump->um_maxsymlinklen <= 0)
panic("ufs_whiteout: old format filesystem");
#endif
@ -1230,27 +1229,21 @@ ufs_mkdir(void *v)
struct componentname *a_cnp;
struct vattr *a_vap;
} */ *ap = v;
struct vnode *dvp, *tvp;
struct vattr *vap;
struct componentname *cnp;
struct inode *ip, *dp;
struct vnode *dvp = ap->a_dvp, *tvp;
struct vattr *vap = ap->a_vap;
struct componentname *cnp = ap->a_cnp;
struct inode *ip, *dp = VTOI(dvp);
struct buf *bp;
struct dirtemplate dirtemplate;
struct direct *newdir;
int error, dmode, blkoff;
int dirblksiz = DIRBLKSIZ;
if (UFS_MPISAPPLEUFS(ap->a_dvp->v_mount)) {
dirblksiz = APPLEUFS_DIRBLKSIZ;
}
struct ufsmount *ump = dp->i_ump;
int dirblksiz = ump->um_dirblksiz;
dvp = ap->a_dvp;
vap = ap->a_vap;
cnp = ap->a_cnp;
#ifdef DIAGNOSTIC
if ((cnp->cn_flags & HASBUF) == 0)
panic("ufs_mkdir: no name");
#endif
dp = VTOI(dvp);
if ((nlink_t)dp->i_nlink >= LINK_MAX) {
error = EMLINK;
goto out;
@ -1312,19 +1305,17 @@ ufs_mkdir(void *v)
*/
dirtemplate = mastertemplate;
dirtemplate.dotdot_reclen = dirblksiz - dirtemplate.dot_reclen;
dirtemplate.dot_ino = ufs_rw32(ip->i_number,
UFS_MPNEEDSWAP(dvp->v_mount));
dirtemplate.dotdot_ino = ufs_rw32(dp->i_number,
UFS_MPNEEDSWAP(dvp->v_mount));
dirtemplate.dot_ino = ufs_rw32(ip->i_number, UFS_MPNEEDSWAP(ump));
dirtemplate.dotdot_ino = ufs_rw32(dp->i_number, UFS_MPNEEDSWAP(ump));
dirtemplate.dot_reclen = ufs_rw16(dirtemplate.dot_reclen,
UFS_MPNEEDSWAP(dvp->v_mount));
UFS_MPNEEDSWAP(ump));
dirtemplate.dotdot_reclen = ufs_rw16(dirtemplate.dotdot_reclen,
UFS_MPNEEDSWAP(dvp->v_mount));
if (dvp->v_mount->mnt_maxsymlinklen <= 0) {
UFS_MPNEEDSWAP(ump));
if (ump->um_maxsymlinklen <= 0) {
#if BYTE_ORDER == LITTLE_ENDIAN
if (UFS_MPNEEDSWAP(dvp->v_mount) == 0)
if (UFS_MPNEEDSWAP(ump) == 0)
#else
if (UFS_MPNEEDSWAP(dvp->v_mount) != 0)
if (UFS_MPNEEDSWAP(ump) != 0)
#endif
{
dirtemplate.dot_type = dirtemplate.dot_namlen;
@ -1537,8 +1528,8 @@ ufs_symlink(void *v)
VN_KNOTE(ap->a_dvp, NOTE_WRITE);
vp = *vpp;
len = strlen(ap->a_target);
if (len < vp->v_mount->mnt_maxsymlinklen) {
ip = VTOI(vp);
ip = VTOI(vp);
if (len < ip->i_ump->um_maxsymlinklen) {
memcpy((char *)SHORTLINK(ip), ap->a_target, len);
ip->i_size = len;
DIP_ASSIGN(ip, size, len);
@ -1573,14 +1564,13 @@ ufs_readdir(void *v)
off_t **a_cookies;
int *ncookies;
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct uio *uio;
int error;
size_t count, lost;
off_t off;
int dirblksiz = DIRBLKSIZ;
if (UFS_MPISAPPLEUFS(ap->a_vp->v_mount)) {
dirblksiz = APPLEUFS_DIRBLKSIZ;
}
struct ufsmount *ump = VFSTOUFS(vp->v_mount);
int dirblksiz = ump->um_dirblksiz;
uio = ap->a_uio;
off = uio->uio_offset;
@ -1593,13 +1583,12 @@ ufs_readdir(void *v)
uio->uio_resid = count;
uio->uio_iov->iov_len = count;
#if BYTE_ORDER == LITTLE_ENDIAN
if (ap->a_vp->v_mount->mnt_maxsymlinklen > 0 &&
UFS_MPNEEDSWAP(ap->a_vp->v_mount) == 0)
if (ump->um_maxsymlinklen > 0 && UFS_MPNEEDSWAP(ump) == 0)
#else
if (UFS_MPNEEDSWAP(ap->a_vp->v_mount) == 0)
if (UFS_MPNEEDSWAP(ump) == 0)
#endif
{
error = VOP_READ(ap->a_vp, uio, 0, ap->a_cred);
error = VOP_READ(vp, uio, 0, ap->a_cred);
} else {
struct dirent *dp, *edp;
struct uio auio;
@ -1615,17 +1604,17 @@ ufs_readdir(void *v)
aiov.iov_len = count;
MALLOC(dirbuf, caddr_t, count, M_TEMP, M_WAITOK);
aiov.iov_base = dirbuf;
error = VOP_READ(ap->a_vp, &auio, 0, ap->a_cred);
error = VOP_READ(vp, &auio, 0, ap->a_cred);
if (error == 0) {
readcnt = count - auio.uio_resid;
edp = (struct dirent *)&dirbuf[readcnt];
for (dp = (struct dirent *)dirbuf; dp < edp; ) {
#if BYTE_ORDER == LITTLE_ENDIAN
if (ap->a_vp->v_mount->mnt_maxsymlinklen <= 0 &&
UFS_MPNEEDSWAP(ap->a_vp->v_mount) == 0)
if (ump->um_maxsymlinklen <= 0 &&
UFS_MPNEEDSWAP(ump) == 0)
#else
if (ap->a_vp->v_mount->mnt_maxsymlinklen <= 0 &&
UFS_MPNEEDSWAP(ap->a_vp->v_mount) != 0)
if (ump->um_maxsymlinklen <= 0 &&
UFS_MPNEEDSWAP(ump) != 0)
#endif
{
tmp = dp->d_namlen;
@ -1633,9 +1622,9 @@ ufs_readdir(void *v)
dp->d_type = tmp;
}
dp->d_fileno = ufs_rw32(dp->d_fileno,
UFS_MPNEEDSWAP(ap->a_vp->v_mount));
UFS_MPNEEDSWAP(ump));
dp->d_reclen = ufs_rw16(dp->d_reclen,
UFS_MPNEEDSWAP(ap->a_vp->v_mount));
UFS_MPNEEDSWAP(ump));
if (dp->d_reclen > 0) {
dp = (struct dirent *)
((char *)dp + dp->d_reclen);
@ -1683,7 +1672,7 @@ ufs_readdir(void *v)
}
}
uio->uio_resid += lost;
*ap->a_eofflag = VTOI(ap->a_vp)->i_size <= uio->uio_offset;
*ap->a_eofflag = VTOI(vp)->i_size <= uio->uio_offset;
return (error);
}
@ -1698,15 +1687,14 @@ ufs_readlink(void *v)
struct uio *a_uio;
struct ucred *a_cred;
} */ *ap = v;
struct vnode *vp;
struct inode *ip;
struct vnode *vp = ap->a_vp;
struct inode *ip = VTOI(vp);
struct ufsmount *ump = VFSTOUFS(vp->v_mount);
int isize;
vp = ap->a_vp;
ip = VTOI(vp);
isize = ip->i_size;
if (isize < vp->v_mount->mnt_maxsymlinklen ||
(vp->v_mount->mnt_maxsymlinklen == 0 && DIP(ip, blocks) == 0)) {
if (isize < ump->um_maxsymlinklen ||
(ump->um_maxsymlinklen == 0 && DIP(ip, blocks) == 0)) {
uiomove((char *)SHORTLINK(ip), isize, ap->a_uio);
return (0);
}
@ -1996,6 +1984,7 @@ ufs_vinit(struct mount *mntp, int (**specops)(void *), int (**fifoops)(void *),
struct inode *ip;
struct vnode *vp, *nvp;
dev_t rdev;
struct ufsmount *ump;
vp = *vpp;
ip = VTOI(vp);
@ -2003,12 +1992,13 @@ ufs_vinit(struct mount *mntp, int (**specops)(void *), int (**fifoops)(void *),
case VCHR:
case VBLK:
vp->v_op = specops;
if (ip->i_ump->um_fstype == UFS1)
ump = ip->i_ump;
if (ump->um_fstype == UFS1)
rdev = (dev_t)ufs_rw32(ip->i_ffs1_rdev,
UFS_MPNEEDSWAP(vp->v_mount));
UFS_MPNEEDSWAP(ump));
else
rdev = (dev_t)ufs_rw64(ip->i_ffs2_rdev,
UFS_MPNEEDSWAP(vp->v_mount));
UFS_MPNEEDSWAP(ump));
if ((nvp = checkalias(vp, rdev, mntp)) != NULL) {
/*
* Discard unneeded vnode, but save its inode.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufsmount.h,v 1.16 2004/05/25 14:55:46 hannken Exp $ */
/* $NetBSD: ufsmount.h,v 1.17 2004/08/15 07:20:00 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -98,6 +98,9 @@ struct ufsmount {
TAILQ_HEAD(, inode) um_snapshots; /* list of active snapshots */
daddr_t um_snaplistsize; /* size of block hints list */
daddr_t *um_snapblklist; /* snapshot block hints list */
int um_maxsymlinklen;
int um_dirblksiz;
off_t um_maxfilesize;
};
/* UFS-specific flags */
@ -121,9 +124,9 @@ struct ufsmount {
#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
#ifdef APPLE_UFS
#define UFS_MPISAPPLEUFS(mp) (VFSTOUFS(mp)->um_flags & UFS_ISAPPLEUFS)
#define UFS_MPISAPPLEUFS(ump) ((ump)->um_flags & UFS_ISAPPLEUFS)
#else
#define UFS_MPISAPPLEUFS(mp) (0)
#define UFS_MPISAPPLEUFS(ump) (0)
#endif
/*