src Makefile, NONE, 1.1 dirent.h, NONE, 1.1 inode.h, NONE, 1.1 ufsmount.h, NONE, 1.1 ext2fs.h, 1.1.
Status: Alpha
Brought to you by:
pluknet
Update of /cvsroot/bsdext2fs/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16212 Modified Files: ext2fs.h ext2fs_alloc.c ext2fs_balloc.c ext2fs_bmap.c ext2fs_bswap.c ext2fs_dinode.h ext2fs_dir.h ext2fs_extern.h ext2fs_inode.c ext2fs_lookup.c ext2fs_readwrite.c ext2fs_subr.c ext2fs_vfsops.c ext2fs_vnops.c Added Files: Makefile dirent.h inode.h ufsmount.h Log Message: Apply current changes to sync with FreeBSD. It includes: o Move from kauth() framework to suser() with partial priv() support o Move from uvm VM subsystem to native FreeBSD one o Some local headers are used now to not touch system wide ones It compiles now and sometimes passes mount op. This work based on v7 sources. Further commits to support v6 are coming. Submitted by: pluknet --- NEW FILE: inode.h --- /*- * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 * * From: src/sys/ufs/ufs/inode.h,v 1.51 * * $Id: inode.h,v 1.1 2008/03/19 23:06:36 nightgoblin Exp $ */ #ifndef _UFS_UFS_INODE_H_ #define _UFS_UFS_INODE_H_ #include <sys/file.h> #include <sys/lock.h> #include <sys/queue.h> #include <ufs/ufs/dinode.h> /* * This must agree with the definition in <ufs/ufs/dir.h>. */ #define doff_t int32_t /* * Per-filesystem inode extensions. */ struct ext2fs_inode_ext { daddr_t ext2fs_last_lblk; /* last logical block allocated */ daddr_t ext2fs_last_blk; /* last block allocated on disk */ }; /* * The inode is used to describe each active (or recently active) file in the * UFS filesystem. It is composed of two types of information. The first part * is the information that is needed only while the file is active (such as * the identity of the file and linkage to speed its lookup). The second part * is the permanent meta-data associated with the file which is read in * from the permanent dinode from long term storage when the file becomes * active, and is put back when the file is no longer being used. * * An inode may only be changed while holding either the exclusive * vnode lock or the shared vnode lock and the vnode interlock. We use * the latter only for "read" and "get" operations that require * changing i_flag, or a timestamp. This locking protocol allows executing * those operations without having to upgrade the vnode lock from shared to * exclusive. */ struct inode { TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */ struct vnode *i_vnode;/* Vnode associated with this inode. */ struct ufsmount *i_ump;/* Ufsmount point associated with this inode. */ u_int32_t i_flag; /* flags, see below */ struct cdev *i_dev; /* Device associated with the inode. */ ino_t i_number; /* The identity of the inode. */ int i_effnlink; /* i_nlink when I/O completes */ union { struct fs *fs; /* FFS */ struct m_ext2fs *e2fs; /* EXT2FS */ } inode_u; #define i_fs inode_u.fs #define i_e2fs inode_u.e2fs struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ /* * Side effects; used during directory lookup. */ int32_t i_count; /* Size of free slot in directory. */ doff_t i_endoff; /* End of useful stuff in directory. */ doff_t i_diroff; /* Offset in dir, where we found last entry. */ doff_t i_offset; /* Offset of free space in directory. */ ino_t i_ino; /* Inode number of found directory. */ u_int32_t i_reclen; /* Size of found directory entry. */ union { struct dirhash *dirhash; /* Hashing for large directories. */ daddr_t *snapblklist; /* Collect expunged snapshot blocks. */ struct ext2fs_inode_ext *e2fs; } i_un; #define i_e2fs_last_lblk i_un.e2fs->ext2fs_last_lblk #define i_e2fs_last_blk i_un.e2fs->ext2fs_last_blk /* * Data for extended attribute modification. */ u_char *i_ea_area; /* Pointer to malloced copy of EA area */ unsigned i_ea_len; /* Length of i_ea_area */ int i_ea_error; /* First errno in transaction */ /* * Copies from the on-disk dinode itself. */ u_int16_t i_mode; /* IFMT, permissions; see below. */ int16_t i_nlink; /* File link count. */ u_int64_t i_size; /* File byte count. */ u_int32_t i_flags; /* Status flags (chflags). */ int64_t i_gen; /* Generation number. */ u_int32_t i_uid; /* File owner. */ u_int32_t i_gid; /* File group. */ /* * The real copy of the on-disk inode. */ union { struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */ struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */ struct ext2fs_dinode *e2fs_din; /* 128 bytes of the on-disk dinode. */ } dinode_u; }; /* * These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ #define IN_CHANGE 0x0002 /* Inode change time update request. */ #define IN_UPDATE 0x0004 /* Modification time update request. */ #define IN_MODIFIED 0x0008 /* Inode has been modified. */ #define IN_RENAME 0x0010 /* Inode is being renamed. */ #define IN_LAZYMOD 0x0040 /* Modified, but don't write yet. */ #define IN_SPACECOUNTED 0x0080 /* Blocks to be freed in free count. */ #define IN_LAZYACCESS 0x0100 /* Process IN_ACCESS after the suspension finished */ #define i_devvp i_ump->um_devvp #define i_umbufobj i_ump->um_bo #define i_dirhash i_un.dirhash #define i_snapblklist i_un.snapblklist #define i_din1 dinode_u.din1 #define i_din2 dinode_u.din2 #define i_e2di dinode_u.e2fs_din #ifdef _KERNEL /* * The DIP macro is used to access fields in the dinode that are * not cached in the inode itself. */ #define DIP(ip, field) \ (((ip)->i_ump->um_fstype == UFS1) ? \ (ip)->i_din1->d##field : (ip)->i_din2->d##field) #define DIP_SET(ip, field, val) do { \ if ((ip)->i_ump->um_fstype == UFS1) \ (ip)->i_din1->d##field = (val); \ else \ (ip)->i_din2->d##field = (val); \ } while (0) #define MAXSYMLINKLEN(ip) \ ((ip)->i_ump->um_fstype == UFS1) ? \ ((NDADDR + NIADDR) * sizeof(ufs1_daddr_t)) : \ ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t)) #define SHORTLINK(ip) \ (((ip)->i_ump->um_fstype == UFS1) ? \ (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db) /* * Structure used to pass around logical block paths generated by * ufs_getlbns and used by truncate and bmap code. */ struct indir { ufs2_daddr_t in_lbn; /* Logical block number. */ int in_off; /* Offset in buffer. */ int in_exists; /* Flag if the block exists. */ }; /* Convert between inode pointers and vnode pointers. */ #define VTOI(vp) ((struct inode *)(vp)->v_data) #define ITOV(ip) ((ip)->i_vnode) /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) #define DOINGASYNC(vp) ((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC) /* This overlays the fid structure (see mount.h). */ struct ufid { u_int16_t ufid_len; /* Length of structure. */ u_int16_t ufid_pad; /* Force 32-bit alignment. */ ino_t ufid_ino; /* File number (ino). */ int32_t ufid_gen; /* Generation number. */ }; #endif /* _KERNEL */ #endif /* !_UFS_UFS_INODE_H_ */ Index: ext2fs_extern.h =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_extern.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_extern.h 14 Mar 2008 18:31:45 -0000 1.1.1.1 +++ ext2fs_extern.h 19 Mar 2008 23:06:36 -0000 1.2 @@ -1,4 +1,5 @@ /* $NetBSD: ext2fs_extern.h,v 1.38 2007/12/08 19:29:53 pooka Exp $ */ +/* $Id$ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -83,52 +84,54 @@ struct mbuf; struct componentname; -extern struct pool ext2fs_inode_pool; /* memory pool for inodes */ -extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */ +extern uma_zone_t ext2fs_inode_pool; /* memory pool for inodes */ +extern uma_zone_t ext2fs_dinode_pool; /* memory pool for dinodes */ +extern uma_zone_t ext2fs_inode_ext_pool; /* memory pool for extended + inodes */ #define EXT2FS_ITIMES(ip, acc, mod, cre) \ - while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \ + while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED)) \ ext2fs_itimes(ip, acc, mod, cre) __BEGIN_DECLS /* ext2fs_alloc.c */ -int ext2fs_alloc(struct inode *, daddr_t, daddr_t , kauth_cred_t, +int ext2fs_alloc(struct inode *, daddr_t, daddr_t , struct ucred *, daddr_t *); int ext2fs_realloccg(struct inode *, daddr_t, daddr_t, int, int , - kauth_cred_t, struct buf **); -int ext2fs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **); + struct ucred, struct buf **); +int ext2fs_valloc(struct vnode *, int, struct ucred *, struct vnode **); /* XXX ondisk32 */ daddr_t ext2fs_blkpref(struct inode *, daddr_t, int, int32_t *); void ext2fs_blkfree(struct inode *, daddr_t); int ext2fs_vfree(struct vnode *, ino_t, int); /* ext2fs_balloc.c */ -int ext2fs_balloc(struct inode *, daddr_t, int, kauth_cred_t, +int ext2fs_balloc(struct inode *, daddr_t, int, struct ucred *, struct buf **, int); -int ext2fs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); +int ext2fs_gop_alloc(struct vnode *, off_t, off_t, int, struct ucred *); /* ext2fs_bmap.c */ -int ext2fs_bmap(void *); +int ext2fs_bmap(struct vop_bmap_args *); /* ext2fs_inode.c */ u_int64_t ext2fs_size(struct inode *); int ext2fs_setsize(struct inode *, u_int64_t); int ext2fs_update(struct vnode *, const struct timespec *, const struct timespec *, int); -int ext2fs_truncate(struct vnode *, off_t, int, kauth_cred_t); -int ext2fs_inactive(void *); +int ext2fs_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *); +int ext2fs_inactive(struct vop_inactive_args *); /* ext2fs_lookup.c */ -int ext2fs_readdir(void *); -int ext2fs_lookup(void *); +int ext2fs_lookup(struct vop_lookup_args *); +int ext2fs_readdir(struct vop_readdir_args *); int ext2fs_direnter(struct inode *, struct vnode *, struct componentname *); int ext2fs_dirremove(struct vnode *, struct componentname *); int ext2fs_dirrewrite(struct inode *, struct inode *, struct componentname *); -int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t); -int ext2fs_checkpath(struct inode *, struct inode *, kauth_cred_t); +int ext2fs_dirempty(struct inode *, ino_t, struct ucred *); +int ext2fs_checkpath(struct inode *, struct inode *, struct ucred *); /* ext2fs_subr.c */ int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **); @@ -137,38 +140,39 @@ const struct timespec *, const struct timespec *); /* ext2fs_vfsops.c */ -VFS_PROTOS(ext2fs); -int ext2fs_reload(struct mount *, kauth_cred_t); -int ext2fs_mountfs(struct vnode *, struct mount *); -int ext2fs_flushfiles(struct mount *, int); +int ext2fs_reload(struct mount *, struct thread *); +int ext2fs_mountfs(struct vnode *, struct mount *, struct thread *); +int ext2fs_flushfiles(struct mount *, int, struct thread *); int ext2fs_sbupdate(struct ufsmount *, int); int ext2fs_cgupdate(struct ufsmount *, int); /* ext2fs_readwrite.c */ -int ext2fs_read(void *); -int ext2fs_write(void *); +int ext2fs_read(struct vop_read_args *); +int ext2fs_write(struct vop_write_args *); /* ext2fs_vnops.c */ -int ext2fs_create(void *); -int ext2fs_mknod(void *); -int ext2fs_open(void *); -int ext2fs_access(void *); -int ext2fs_getattr(void *); -int ext2fs_setattr(void *); -int ext2fs_remove(void *); -int ext2fs_link(void *); -int ext2fs_rename(void *); -int ext2fs_mkdir(void *); -int ext2fs_rmdir(void *); -int ext2fs_symlink(void *); -int ext2fs_readlink(void *); -int ext2fs_advlock(void *); -int ext2fs_fsync(void *); -int ext2fs_vinit(struct mount *, int (**specops)(void *), - int (**fifoops)(void *), struct vnode **); +int ext2fs_create(struct vop_create_args *); +int ext2fs_mknod(struct vop_mknod_args *); +int ext2fs_open(struct vop_open_args *); +int ext2fs_access(struct vop_access_args *); +int ext2fs_getattr(struct vop_getattr_args *); +int ext2fs_setattr(struct vop_setattr_args *); +int ext2fs_remove(struct vop_remove_args *); +int ext2fs_link(struct vop_link_args *); +int ext2fs_rename(struct vop_rename_args *); +int ext2fs_mkdir(struct vop_mkdir_args *); +int ext2fs_rmdir(struct vop_rmdir_args *); +int ext2fs_symlink(struct vop_symlink_args *); +int ext2fs_readlink(struct vop_readlink_args *); +int ext2fs_advlock(struct vop_advlock_args *); +int ext2fs_fsync(struct vop_fsync_args *); +int ext2fs_vinit(struct mount *, struct vop_vector *, struct vnode **); int ext2fs_makeinode(int, struct vnode *, struct vnode **, struct componentname *cnp); -int ext2fs_reclaim(void *); +int ext2fs_reclaim(struct vop_reclaim_args *); + +extern struct vop_vector ext2fs_vnodeop_p; +extern struct vop_vector ext2fs_fifoop_p; #ifdef SYSCTL_SETUP_PROTO SYSCTL_SETUP_PROTO(sysctl_vfs_ext2fs_setup); @@ -177,8 +181,4 @@ #define IS_EXT2_VNODE(vp) (vp->v_tag == VT_EXT2FS) -extern int (**ext2fs_vnodeop_p)(void *); -extern int (**ext2fs_specop_p)(void *); -extern int (**ext2fs_fifoop_p)(void *); - #endif /* !_UFS_EXT2FS_EXT2FS_EXTERN_H_ */ --- NEW FILE: dirent.h --- /* $NetBSD: dirent.h,v 1.23 2005/12/26 18:41:36 perry Exp $ */ /* $Id: dirent.h,v 1.1 2008/03/19 23:06:36 nightgoblin Exp $ */ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)dirent.h 8.3 (Berkeley) 8/10/94 */ #ifndef _SYS_DIRENT_H_ #define _SYS_DIRENT_H_ /* * The dirent structure defines the format of directory entries returned by * the getdents(2) system call. * * A directory entry has a struct dirent at the front of it, containing its * inode number, the length of the entry, and the length of the name * contained in the entry. These are followed by the name padded to a 4 * byte boundary with null bytes. All names are guaranteed null terminated. * The maximum length of a name in a directory is MAXNAMLEN. */ struct dirent { ino_t d_fileno; /* file number of entry */ uint16_t d_reclen; /* length of this record */ uint16_t d_namlen; /* length of string in d_name */ uint8_t d_type; /* file type, see below */ char d_name[511 + 1]; /* name must be no longer than this */ }; /* * File types */ #define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 #define DT_DIR 4 #define DT_BLK 6 #define DT_REG 8 #define DT_LNK 10 #define DT_SOCK 12 #define DT_WHT 14 /* * The _DIRENT_ALIGN macro returns the alignment of struct dirent. * struct direct and struct dirent12 used 4 byte alignment but * struct dirent uses 8. */ #define _DIRENT_ALIGN(dp) (sizeof((dp)->d_fileno) - 1) /* * The _DIRENT_NAMEOFF macro returns the offset of the d_name field in * struct dirent */ #define _DIRENT_NAMEOFF(dp) \ ((char *)(void *)&(dp)->d_name - (char *)(void *)dp) /* * The _DIRENT_RECLEN macro gives the minimum record length which will hold * a name of size "namlen". This requires the amount of space in struct dirent * without the d_name field, plus enough space for the name with a terminating * null byte (namlen+1), rounded up to a the appropriate byte boundary. */ #define _DIRENT_RECLEN(dp, namlen) \ ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \ ~_DIRENT_ALIGN(dp)) /* * The _DIRENT_SIZE macro returns the minimum record length required for * name name stored in the current record. */ #define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, (dp)->d_namlen) /* * The _DIRENT_NEXT macro advances to the next dirent record. */ #define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen)) /* * The _DIRENT_MINSIZE returns the size of an empty (invalid) record. */ #define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0) /* * Convert between stat structure types and directory types. */ #define IFTODT(mode) (((mode) & 0170000) >> 12) #define DTTOIF(dirtype) ((dirtype) << 12) #endif /* !_SYS_DIRENT_H_ */ Index: ext2fs_vnops.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_vnops.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_vnops.c 14 Mar 2008 18:32:16 -0000 1.1.1.1 +++ ext2fs_vnops.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -70,42 +70,44 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.81 2008/01/25 14:32:16 ad Exp $"); +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/resourcevar.h> #include <sys/kernel.h> -#include <sys/file.h> [...1512 lines suppressed...] - { &vop_bmap_desc, fifo_bmap }, /* bmap */ - { &vop_strategy_desc, fifo_strategy }, /* strategy */ - { &vop_print_desc, ufs_print }, /* print */ - { &vop_islocked_desc, ufs_islocked }, /* islocked */ - { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */ - { &vop_advlock_desc, fifo_advlock }, /* advlock */ - { &vop_bwrite_desc, vn_bwrite }, /* bwrite */ - { &vop_putpages_desc, fifo_putpages }, /* putpages */ - { NULL, NULL } +struct vop_vector ext2fs_fifoop_p = { + .vop_default = &ufs_fifoops, + .vop_access = ext2fs_access, /* access */ + .vop_getattr = ext2fs_getattr, /* getattr */ + .vop_setattr = ext2fs_setattr, /* setattr */ + .vop_fsync = ext2fs_fsync, /* fsync */ + .vop_inactive = ext2fs_inactive, /* inactive */ + .vop_reclaim = ext2fs_reclaim, /* reclaim */ }; -const struct vnodeopv_desc ext2fs_fifoop_opv_desc = - { &ext2fs_fifoop_p, ext2fs_fifoop_entries }; Index: ext2fs_dinode.h =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_dinode.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_dinode.h 14 Mar 2008 18:31:41 -0000 1.1.1.1 +++ ext2fs_dinode.h 19 Mar 2008 23:06:36 -0000 1.2 @@ -1,4 +1,5 @@ /* $NetBSD: ext2fs_dinode.h,v 1.16 2007/11/17 08:51:51 tsutsui Exp $ */ +/* $Id$ */ /* * Copyright (c) 1982, 1989, 1993 Index: ext2fs_subr.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_subr.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_subr.c 14 Mar 2008 18:32:00 -0000 1.1.1.1 +++ ext2fs_subr.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -65,18 +65,22 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.25 2007/10/08 18:01:28 ad Exp $"); +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/vnode.h> +#include <sys/mount.h> #include <sys/buf.h> -#include <sys/inttypes.h> -#include <sys/kauth.h> +#include <machine/_inttypes.h> -#include <ufs/ufs/inode.h> -#include <ufs/ext2fs/ext2fs.h> -#include <ufs/ext2fs/ext2fs_extern.h> +#include <vm/vm.h> + +#include <ufs/ufs/quota.h> +#include <fs/bsdext2fs/inode.h> +#include <fs/bsdext2fs/ext2fs.h> +#include <fs/bsdext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs_dinode.h> /* * Return buffer with the contents of block "offset" from the beginning of @@ -98,7 +102,7 @@ *bpp = NULL; if ((error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, &bp)) != 0) { - brelse(bp, 0); + brelse(bp); return (error); } if (res) @@ -113,7 +117,7 @@ { struct timespec now; - if (!(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY))) { + if (!(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED))) { return; } @@ -121,22 +125,22 @@ if (ip->i_flag & IN_ACCESS) { if (acc == NULL) acc = &now; - ip->i_e2fs_atime = acc->tv_sec; + ip->i_e2di->e2di_atime = acc->tv_sec; } - if (ip->i_flag & (IN_UPDATE | IN_MODIFY)) { + if (ip->i_flag & (IN_UPDATE | IN_MODIFIED)) { if (mod == NULL) mod = &now; - ip->i_e2fs_mtime = mod->tv_sec; + ip->i_e2di->e2di_mtime = mod->tv_sec; ip->i_modrev++; } - if (ip->i_flag & (IN_CHANGE | IN_MODIFY)) { + if (ip->i_flag & (IN_CHANGE | IN_MODIFIED)) { if (cre == NULL) cre = &now; - ip->i_e2fs_ctime = cre->tv_sec; + ip->i_e2di->e2di_ctime = cre->tv_sec; } - if (ip->i_flag & (IN_ACCESS | IN_MODIFY)) - ip->i_flag |= IN_ACCESSED; + if (ip->i_flag & (IN_ACCESS | IN_MODIFIED)) + ip->i_flag |= IN_ACCESS; if (ip->i_flag & (IN_UPDATE | IN_CHANGE)) ip->i_flag |= IN_MODIFIED; - ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY); + ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED); } --- NEW FILE: Makefile --- # $Id: Makefile,v 1.1 2008/03/19 23:06:36 nightgoblin Exp $ .PATH: ${.CURDIR}/../../fs/bsdext2fs KMOD= ext2fs SRCS= vnode_if.h \ ext2fs.h ext2fs_dinode.h ext2fs_readwrite.c ext2fs_alloc.c \ ext2fs_dir.h ext2fs_subr.c ext2fs_balloc.c ext2fs_extern.h \ ext2fs_vfsops.c ext2fs_bmap.c ext2fs_inode.c ext2fs_vnops.c \ ext2fs_bswap.c ext2fs_lookup.c #SRCS= opt_ddb.h opt_quota.h opt_suiddir.h vnode_if.h \ # ext2_alloc.c ext2_balloc.c ext2_bmap.c ext2_inode.c \ # ext2_inode_cnv.c ext2_linux_balloc.c ext2_linux_ialloc.c \ # ext2_lookup.c ext2_subr.c ext2_vfsops.c ext2_vnops.c .include <bsd.kmod.mk> Index: ext2fs.h =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs.h 14 Mar 2008 18:31:30 -0000 1.1.1.1 +++ ext2fs.h 19 Mar 2008 23:06:36 -0000 1.2 @@ -1,4 +1,5 @@ /* $NetBSD: ext2fs.h,v 1.26 2007/12/25 18:33:49 perry Exp $ */ +/* $Id$ */ /* * Copyright (c) 1982, 1986, 1993 @@ -67,7 +68,7 @@ #ifndef _UFS_EXT2FS_EXT2FS_H_ #define _UFS_EXT2FS_EXT2FS_H_ -#include <sys/bswap.h> +#include <sys/endian.h> /* * Each disk drive contains some number of file systems. @@ -84,12 +85,12 @@ * The first boot and super blocks are given in absolute disk addresses. * The byte-offset forms are preferred, as they don't imply a sector size. */ -#define BBSIZE 1024 +#define E_BBSIZE 1024 #define SBSIZE 1024 #define BBOFF ((off_t)(0)) -#define SBOFF ((off_t)(BBOFF + BBSIZE)) +#define SBOFF ((off_t)(BBOFF + E_BBSIZE)) #define BBLOCK ((daddr_t)(0)) -#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE)) +#define SBLOCK ((daddr_t)(BBLOCK + E_BBSIZE / DEV_BSIZE)) /* * Addresses stored in inodes are capable of addressing blocks @@ -373,4 +374,8 @@ */ #define NINDIR(fs) ((fs)->e2fs_bsize / sizeof(u_int32_t)) +#define UPDATE_WAIT 0x0001 /* update: wait for completion */ +#define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */ +#define UPDATE_CLOSE 0x0004 /* update: clean up on close */ + #endif /* !_UFS_EXT2FS_EXT2FS_H_ */ Index: ext2fs_readwrite.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_readwrite.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_readwrite.c 14 Mar 2008 18:31:57 -0000 1.1.1.1 +++ ext2fs_readwrite.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.50 2008/01/02 11:49:08 ad Exp $"); +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> @@ -79,14 +79,25 @@ #include <sys/vnode.h> #include <sys/malloc.h> #include <sys/signalvar.h> -#include <sys/kauth.h> +#include <sys/sx.h> +#include <sys/sched.h> +#include <sys/sf_buf.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> +#include <vm/vm.h> +#include <vm/vm_extern.h> +#include <vm/vm_object.h> +#include <vm/vm_page.h> +#include <vm/vm_pager.h> +#include <ufs/ufs/quota.h> +#include <fs/bsdext2fs/inode.h> +#include <ufs/ufs/extattr.h> +#include <fs/bsdext2fs/ufsmount.h> +#include <ufs/ufs/dinode.h> +#include <ufs/ufs/ufs_extern.h> +#include <fs/bsdext2fs/ext2fs.h> +#include <fs/bsdext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs_dinode.h> #define doclusterread 0 /* XXX underway */ #define doclusterwrite 0 @@ -96,26 +107,25 @@ */ /* ARGSUSED */ int -ext2fs_read(void *v) -{ +ext2fs_read(ap) + struct vop_read_args /* { struct vnode *a_vp; struct uio *a_uio; int a_ioflag; - kauth_cred_t a_cred; - } */ *ap = v; + struct ucred *a_cred; + } */ *ap; +{ struct vnode *vp; struct inode *ip; struct uio *uio; struct m_ext2fs *fs; struct buf *bp; struct ufsmount *ump; - void *win; - vsize_t bytelen; daddr_t lbn, nextlbn; off_t bytesinfile; long size, xfersize, blkoffset; - int error, flags; + int error; vp = ap->a_vp; ip = VTOI(vp); @@ -135,33 +145,13 @@ panic("%s: type %d", "ext2fs_read", vp->v_type); #endif fs = ip->i_e2fs; - if ((u_int64_t)uio->uio_offset > ump->um_maxfilesize) + if ((u_int64_t)uio->uio_offset > ump->um_savedmaxfilesize) return (EFBIG); if (uio->uio_resid == 0) return (0); if (uio->uio_offset >= ext2fs_size(ip)) goto out; - if (vp->v_type == VREG) { - const int advice = IO_ADV_DECODE(ap->a_ioflag); - - while (uio->uio_resid > 0) { - bytelen = MIN(ext2fs_size(ip) - uio->uio_offset, - uio->uio_resid); - if (bytelen == 0) - break; - - win = ubc_alloc(&vp->v_uobj, uio->uio_offset, - &bytelen, advice, UBC_READ); - error = uiomove(win, bytelen, uio); - flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; - ubc_release(win, flags); - if (error) - break; - } - goto out; - } - for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { bytesinfile = ext2fs_size(ip) - uio->uio_offset; if (bytesinfile <= 0) @@ -183,8 +173,11 @@ error = breadn(vp, lbn, size, &nextlbn, &nextsize, 1, NOCRED, &bp); } - if (error) + if (error) { + brelse(bp); + bp = NULL; break; + } /* * We should only get non-zero b_resid when an I/O error @@ -202,14 +195,15 @@ error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio); if (error) break; - brelse(bp, 0); } if (bp != NULL) - brelse(bp, 0); + brelse(bp); out: if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { + VI_LOCK(vp); ip->i_flag |= IN_ACCESS; + VI_UNLOCK(vp); if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT); } @@ -220,28 +214,24 @@ * Vnode op for writing. */ int -ext2fs_write(void *v) -{ - struct vop_write_args /* { +ext2fs_write(ap) + struct vop_write_args /* { struct vnode *a_vp; struct uio *a_uio; int a_ioflag; - kauth_cred_t a_cred; - } */ *ap = v; + struct ucred *a_cred; + } */ *ap; +{ struct vnode *vp; struct uio *uio; struct inode *ip; struct m_ext2fs *fs; struct buf *bp; - struct proc *p; + struct thread *td; struct ufsmount *ump; daddr_t lbn; off_t osize; - int blkoffset, error, flags, ioflag, resid, xfersize; - vsize_t bytelen; - void *win; - off_t oldoff = 0; /* XXX */ - bool async; + int blkoffset, error, ioflag, resid, xfersize, flags = 0; int extended = 0; ioflag = ap->a_ioflag; @@ -253,14 +243,14 @@ #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) - panic("%s: mode", "ext2fs_write"); + panic("ext2fs_write: mode"); #endif switch (vp->v_type) { case VREG: if (ioflag & IO_APPEND) uio->uio_offset = ext2fs_size(ip); - if ((ip->i_e2fs_flags & EXT2_APPEND) && + if ((ip->i_e2di->e2di_flags & EXT2_APPEND) && uio->uio_offset != ext2fs_size(ip)) return (EPERM); /* FALLTHROUGH */ @@ -268,98 +258,55 @@ break; case VDIR: if ((ioflag & IO_SYNC) == 0) - panic("%s: nonsync dir write", "ext2fs_write"); + panic("ext2fs_write: nonsync dir write"); break; default: - panic("%s: type", "ext2fs_write"); + panic("ext2fs_write: type %p %d (%d,%d)", vp, (int)vp->v_type, + (int)uio->uio_offset, + (int)uio->uio_resid + ); } + KASSERT(uio->uio_resid >= 0, ("ffs_write: uio->uio_resid < 0")); + KASSERT(uio->uio_offset >= 0, ("ffs_write: uio->uio_offset < 0")); fs = ip->i_e2fs; - if (uio->uio_offset < 0 || - (u_int64_t)uio->uio_offset + uio->uio_resid > ump->um_maxfilesize) + if (uio->uio_offset < 0 || (u_int64_t)uio->uio_offset + + uio->uio_resid > ump->um_savedmaxfilesize) return (EFBIG); /* * Maybe this should be above the vnode op call, but so long as * file servers have no limits, I don't think it matters. */ - p = curproc; - if (vp->v_type == VREG && p && - uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - mutex_enter(&proclist_mutex); - psignal(p, SIGXFSZ); - mutex_exit(&proclist_mutex); - return (EFBIG); + td = uio->uio_td; + if (vp->v_type == VREG && td != NULL) { + PROC_LOCK(td->td_proc); + if (uio->uio_offset + uio->uio_resid > + lim_cur(td->td_proc, RLIMIT_FSIZE)) { + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); + return (EFBIG); + } + PROC_UNLOCK(td->td_proc); } if (uio->uio_resid == 0) return (0); - async = vp->v_mount->mnt_flag & MNT_ASYNC; resid = uio->uio_resid; osize = ext2fs_size(ip); + if ((ioflag & IO_SYNC) && !DOINGASYNC(vp)) + flags |= IO_SYNC; - if (vp->v_type == VREG) { - while (uio->uio_resid > 0) { - oldoff = uio->uio_offset; - blkoffset = blkoff(fs, uio->uio_offset); - bytelen = MIN(fs->e2fs_bsize - blkoffset, - uio->uio_resid); - - if (vp->v_size < oldoff + bytelen) { - uvm_vnp_setwritesize(vp, oldoff + bytelen); - } - error = ufs_balloc_range(vp, uio->uio_offset, - bytelen, ap->a_cred, 0); - if (error) - break; - win = ubc_alloc(&vp->v_uobj, uio->uio_offset, - &bytelen, UVM_ADV_NORMAL, UBC_WRITE); - error = uiomove(win, bytelen, uio); - flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; - ubc_release(win, flags); - if (error) - break; - - /* - * update UVM's notion of the size now that we've - * copied the data into the vnode's pages. - */ - - if (vp->v_size < uio->uio_offset) { - uvm_vnp_setsize(vp, uio->uio_offset); - extended = 1; - } - - /* - * flush what we just wrote if necessary. - * XXXUBC simplistic async flushing. - */ - - if (!async && oldoff >> 16 != uio->uio_offset >> 16) { - mutex_enter(&vp->v_interlock); - error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16, - (uio->uio_offset >> 16) << 16, PGO_CLEANIT); - } - } - if (error == 0 && ioflag & IO_SYNC) { - mutex_enter(&vp->v_interlock); - error = VOP_PUTPAGES(vp, trunc_page(oldoff), - round_page(blkroundup(fs, uio->uio_offset)), - PGO_CLEANIT | PGO_SYNCIO); - } - - goto out; - } - - flags = ioflag & IO_SYNC ? B_SYNC : 0; for (error = 0; uio->uio_resid > 0;) { lbn = lblkno(fs, uio->uio_offset); blkoffset = blkoff(fs, uio->uio_offset); xfersize = MIN(fs->e2fs_bsize - blkoffset, uio->uio_resid); + if (uio->uio_offset + xfersize > ext2fs_size(ip)) + vnode_pager_setsize(vp, uio->uio_offset + xfersize); + if (xfersize < fs->e2fs_bsize) - flags |= B_CLRBUF; + flags |= BA_CLRBUF; else - flags &= ~B_CLRBUF; + flags &= ~BA_CLRBUF; error = ext2fs_balloc(ip, lbn, blkoffset + xfersize, ap->a_cred, &bp, flags); if (error) @@ -371,16 +318,6 @@ } error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio); - /* - * update UVM's notion of the size now that we've - * copied the data into the vnode's pages. - */ - - if (vp->v_size < uio->uio_offset) { - uvm_vnp_setsize(vp, uio->uio_offset); - extended = 1; - } - if (ioflag & IO_SYNC) (void)bwrite(bp); else if (xfersize + blkoffset == fs->e2fs_bsize) @@ -396,20 +333,16 @@ * we clear the setuid and setgid bits as a precaution against * tampering. */ - -out: ip->i_flag |= IN_CHANGE | IN_UPDATE; - if (resid > uio->uio_resid && ap->a_cred && - kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) - ip->i_e2fs_mode &= ~(ISUID | ISGID); + if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0) + ip->i_e2di->e2di_mode &= ~(ISUID | ISGID); if (resid > uio->uio_resid) - VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); + VN_KNOTE_UNLOCKED(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); if (error) { - (void) ext2fs_truncate(vp, osize, ioflag & IO_SYNC, ap->a_cred); + (void) ext2fs_truncate(vp, osize, ioflag & IO_SYNC, ap->a_cred, td); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC) error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT); - KASSERT(vp->v_size == ext2fs_size(ip)); return (error); } Index: ext2fs_bmap.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_bmap.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_bmap.c 14 Mar 2008 18:31:38 -0000 1.1.1.1 +++ ext2fs_bmap.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -70,24 +70,27 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.23 2008/01/02 11:49:08 ad Exp $"); +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/bio.h> #include <sys/buf.h> #include <sys/proc.h> #include <sys/vnode.h> #include <sys/mount.h> #include <sys/resourcevar.h> -#include <sys/trace.h> -#include <miscfs/specfs/specdev.h> +#include <vm/vm.h> -#include <ufs/ufs/inode.h> -#include <ufs/ufs/ufsmount.h> +#include <ufs/ufs/quota.h> +#include <ufs/ufs/extattr.h> +#include <fs/bsdext2fs/inode.h> +#include <fs/bsdext2fs/ufsmount.h> #include <ufs/ufs/ufs_extern.h> -#include <ufs/ext2fs/ext2fs.h> -#include <ufs/ext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs.h> +#include <fs/bsdext2fs/ext2fs_dinode.h> +#include <fs/bsdext2fs/ext2fs_extern.h> static int ext2fs_bmaparray(struct vnode *, daddr_t, daddr_t *, struct indir *, int *, int *); @@ -100,21 +103,21 @@ * number to index into the array of block pointers described by the dinode. */ int -ext2fs_bmap(void *v) -{ +ext2fs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; struct vnode **a_vpp; daddr_t *a_bnp; int *a_runp; - } */ *ap = v; + } */ *ap; +{ /* * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = VTOI(ap->a_vp)->i_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); @@ -141,7 +144,7 @@ int *nump, int *runp) { struct inode *ip; - struct buf *bp, *cbp; + struct buf *bp; struct ufsmount *ump; struct mount *mp; struct indir a[NIADDR+1], *xap; @@ -170,15 +173,16 @@ if (bn >= 0 && bn < NDADDR) { /* XXX ondisk32 */ - *bnp = blkptrtodb(ump, fs2h32(ip->i_e2fs_blocks[bn])); + *bnp = blkptrtodb(ump, fs2h32(ip->i_e2di->e2di_blocks[bn])); if (*bnp == 0) *bnp = -1; else if (runp) /* XXX ondisk32 */ for (++bn; bn < NDADDR && *runp < maxrun && - is_sequential(ump, (daddr_t)fs2h32(ip->i_e2fs_blocks[bn - 1]), - (daddr_t)fs2h32(ip->i_e2fs_blocks[bn])); - ++bn, ++*runp); + is_sequential(ump, + (daddr_t)fs2h32(ip->i_e2di->e2di_blocks[bn - 1]), + (daddr_t)fs2h32(ip->i_e2di->e2di_blocks[bn])); + ++bn, ++*runp); return (0); } @@ -192,7 +196,7 @@ /* Get disk address out of indirect block array */ /* XXX ondisk32 */ - daddr = fs2h32(ip->i_e2fs_blocks[NDADDR + xap->in_off]); + daddr = fs2h32(ip->i_e2di->e2di_blocks[NDADDR + xap->in_off]); #ifdef DIAGNOSTIC if (num > NIADDR + 1 || num < 1) { @@ -210,22 +214,17 @@ metalbn = xap->in_lbn; if (metalbn == bn) break; - if (daddr == 0) { - mutex_enter(&bufcache_lock); - cbp = incore(vp, metalbn); - mutex_exit(&bufcache_lock); - if (cbp == NULL) + if (daddr == 0 && !incore(&vp->v_bufobj, metalbn)) break; - } /* * If we get here, we've either got the block in the cache * or we have a disk address for it, go fetch it. */ if (bp) - brelse(bp, 0); + bqrelse(bp); xap->in_exists = 1; - bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0); + bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0, 0); if (bp == NULL) { /* @@ -236,21 +235,18 @@ return (ENOMEM); } - if (bp->b_oflags & (BO_DONE | BO_DELWRI)) { - trace(TR_BREADHIT, pack(vp, size), metalbn); - } #ifdef DIAGNOSTIC else if (!daddr) panic("ext2fs_bmaparry: indirect block not in cache"); #endif else { - trace(TR_BREADMISS, pack(vp, size), metalbn); +/* trace(TR_BREADMISS, pack(vp, size), metalbn); */ bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_flags |= B_READ; + bp->b_iocmd |= BIO_READ; VOP_STRATEGY(vp, bp); - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ - if ((error = biowait(bp)) != 0) { - brelse(bp, 0); + curthread->td_ru.ru_inblock++; /* XXX */ + if ((error = bufwait(bp)) != 0) { + brelse(bp); return (error); } } @@ -266,7 +262,7 @@ ++bn, ++*runp); } if (bp) - brelse(bp, 0); + bqrelse(bp); daddr = blkptrtodb(ump, daddr); *bnp = daddr == 0 ? -1 : daddr; Index: ext2fs_balloc.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_balloc.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_balloc.c 14 Mar 2008 18:31:34 -0000 1.1.1.1 +++ ext2fs_balloc.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -65,11 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_balloc.c,v 1.32 2007/10/08 18:01:27 ad Exp $"); - -#if defined(_KERNEL_OPT) -#include "opt_uvmhist.h" -#endif +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> @@ -78,15 +74,15 @@ #include <sys/file.h> #include <sys/vnode.h> #include <sys/mount.h> -#include <sys/kauth.h> -#include <uvm/uvm.h> +#include <vm/vm.h> -#include <ufs/ufs/inode.h> +#include <ufs/ufs/quota.h> +#include <fs/bsdext2fs/inode.h> #include <ufs/ufs/ufs_extern.h> - -#include <ufs/ext2fs/ext2fs.h> -#include <ufs/ext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs.h> +#include <fs/bsdext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs_dinode.h> /* * Balloc defines the structure of file system storage @@ -94,8 +90,8 @@ * the inode and the logical block number in a file. */ int -ext2fs_balloc(struct inode *ip, daddr_t bn, int size, - kauth_cred_t cred, struct buf **bpp, int flags) +ext2fs_balloc(struct inode *ip, daddr_t bn, int size, struct ucred *cred, + struct buf **bpp, int flags) { struct m_ext2fs *fs; daddr_t nb; @@ -109,9 +105,6 @@ daddr_t *blkp, *allocblk, allociblk[NIADDR + 1]; int32_t *allocib; /* XXX ondisk32 */ int unwindidx = -1; - UVMHIST_FUNC("ext2fs_balloc"); UVMHIST_CALLED(ubchist); - - UVMHIST_LOG(ubchist, "bn 0x%x", bn,0,0,0); if (bpp != NULL) { *bpp = NULL; @@ -126,7 +119,7 @@ */ if (bn < NDADDR) { /* XXX ondisk32 */ - nb = fs2h32(ip->i_e2fs_blocks[bn]); + nb = fs2h32(ip->i_e2di->e2di_blocks[bn]); if (nb != 0) { /* @@ -137,7 +130,7 @@ error = bread(vp, bn, fs->e2fs_bsize, NOCRED, &bp); if (error) { - brelse(bp, 0); + brelse(bp); return (error); } *bpp = bp; @@ -150,19 +143,19 @@ */ error = ext2fs_alloc(ip, bn, - ext2fs_blkpref(ip, bn, bn, &ip->i_e2fs_blocks[0]), + ext2fs_blkpref(ip, bn, bn, &ip->i_e2di->e2di_blocks[0]), cred, &newb); if (error) return (error); ip->i_e2fs_last_lblk = lbn; ip->i_e2fs_last_blk = newb; /* XXX ondisk32 */ - ip->i_e2fs_blocks[bn] = h2fs32((int32_t)newb); + ip->i_e2di->e2di_blocks[bn] = h2fs32((int32_t)newb); ip->i_flag |= IN_CHANGE | IN_UPDATE; if (bpp != NULL) { - bp = getblk(vp, bn, fs->e2fs_bsize, 0, 0); + bp = getblk(vp, bn, fs->e2fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); - if (flags & B_CLRBUF) + if (flags & BA_CLRBUF) clrbuf(bp); *bpp = bp; } @@ -183,7 +176,7 @@ */ --num; /* XXX ondisk32 */ - nb = fs2h32(ip->i_e2fs_blocks[NDADDR + indirs[0].in_off]); + nb = fs2h32(ip->i_e2di->e2di_blocks[NDADDR + indirs[0].in_off]); allocib = NULL; allocblk = allociblk; if (nb == 0) { @@ -194,7 +187,7 @@ nb = newb; *allocblk++ = nb; ip->i_e2fs_last_blk = newb; - bp = getblk(vp, indirs[1].in_lbn, fs->e2fs_bsize, 0, 0); + bp = getblk(vp, indirs[1].in_lbn, fs->e2fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); /* @@ -204,7 +197,7 @@ if ((error = bwrite(bp)) != 0) goto fail; unwindidx = 0; - allocib = &ip->i_e2fs_blocks[NDADDR + indirs[0].in_off]; + allocib = &ip->i_e2di->e2di_blocks[NDADDR + indirs[0].in_off]; /* XXX ondisk32 */ *allocib = h2fs32((int32_t)newb); ip->i_flag |= IN_CHANGE | IN_UPDATE; @@ -216,7 +209,7 @@ error = bread(vp, indirs[i].in_lbn, (int)fs->e2fs_bsize, NOCRED, &bp); if (error) { - brelse(bp, 0); + brelse(bp); goto fail; } bap = (int32_t *)bp->b_data; /* XXX ondisk32 */ @@ -225,19 +218,19 @@ break; i++; if (nb != 0) { - brelse(bp, 0); + brelse(bp); continue; } pref = ext2fs_blkpref(ip, lbn, 0, (int32_t *)0); error = ext2fs_alloc(ip, lbn, pref, cred, &newb); if (error) { - brelse(bp, 0); + brelse(bp); goto fail; } nb = newb; *allocblk++ = nb; ip->i_e2fs_last_blk = newb; - nbp = getblk(vp, indirs[i].in_lbn, fs->e2fs_bsize, 0, 0); + nbp = getblk(vp, indirs[i].in_lbn, fs->e2fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -245,7 +238,7 @@ * never point at garbage. */ if ((error = bwrite(nbp)) != 0) { - brelse(bp, 0); + brelse(bp); goto fail; } if (unwindidx < 0) @@ -256,7 +249,7 @@ * If required, write synchronously, otherwise use * delayed write. */ - if (flags & B_SYNC) { + if (flags & IO_SYNC) { bwrite(bp); } else { bdwrite(bp); @@ -269,7 +262,7 @@ pref = ext2fs_blkpref(ip, lbn, indirs[num].in_off, &bap[0]); error = ext2fs_alloc(ip, lbn, pref, cred, &newb); if (error) { - brelse(bp, 0); + brelse(bp); goto fail; } nb = newb; @@ -282,31 +275,31 @@ * If required, write synchronously, otherwise use * delayed write. */ - if (flags & B_SYNC) { + if (flags & IO_SYNC) { bwrite(bp); } else { bdwrite(bp); } if (bpp != NULL) { - nbp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0); + nbp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); - if (flags & B_CLRBUF) + if (flags & BA_CLRBUF) clrbuf(nbp); *bpp = nbp; } return (0); } - brelse(bp, 0); + brelse(bp); if (bpp != NULL) { - if (flags & B_CLRBUF) { + if (flags & BA_CLRBUF) { error = bread(vp, lbn, (int)fs->e2fs_bsize, NOCRED, &nbp); if (error) { - brelse(nbp, 0); + brelse(nbp); goto fail; } } else { - nbp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0); + nbp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } *bpp = nbp; @@ -331,11 +324,11 @@ (int)fs->e2fs_bsize, NOCRED, &bp); if (r) { panic("Could not unwind indirect block, error %d", r); - brelse(bp, 0); + brelse(bp); } else { bap = (int32_t *)bp->b_data; /* XXX ondisk32 */ bap[indirs[unwindidx].in_off] = 0; - if (flags & B_SYNC) + if (flags & IO_SYNC) bwrite(bp); else bdwrite(bp); @@ -343,25 +336,25 @@ } for (i = unwindidx + 1; i <= num; i++) { bp = getblk(vp, indirs[i].in_lbn, (int)fs->e2fs_bsize, - 0, 0); - brelse(bp, BC_INVAL); + 0, 0, 0); + bp->b_flags |= B_INVAL; + brelse(bp); } } if (deallocated) { - ip->i_e2fs_nblock -= btodb(deallocated); - ip->i_e2fs_flags |= IN_CHANGE | IN_UPDATE; + ip->i_e2di->e2di_nblock -= btodb(deallocated); + ip->i_e2di->e2di_flags |= IN_CHANGE | IN_UPDATE; } return error; } int ext2fs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags, - kauth_cred_t cred) + struct ucred *cred) { struct inode *ip = VTOI(vp); struct m_ext2fs *fs = ip->i_e2fs; int error, delta, bshift, bsize; - UVMHIST_FUNC("ext2fs_gop_alloc"); UVMHIST_CALLED(ubchist); bshift = fs->e2fs_bshift; bsize = 1 << bshift; @@ -372,13 +365,10 @@ while (len > 0) { bsize = min(bsize, len); - UVMHIST_LOG(ubchist, "off 0x%x len 0x%x bsize 0x%x", - off, len, bsize, 0); error = ext2fs_balloc(ip, lblkno(fs, off), bsize, cred, NULL, flags); if (error) { - UVMHIST_LOG(ubchist, "error %d", error, 0,0,0); return error; } @@ -388,15 +378,8 @@ */ if (ext2fs_size(ip) < off + bsize) { - UVMHIST_LOG(ubchist, "old 0x%lx%8lx new 0x%lx%8lx", - /* Note that arguments are always cast to u_long. */ - ext2fs_size(ip) >> 32, - ext2fs_size(ip) & 0xffffffff, - (off + bsize) >> 32, - (off + bsize) & 0xffffffff); error = ext2fs_setsize(ip, off + bsize); if (error) { - UVMHIST_LOG(ubchist, "error %d", error, 0,0,0); return error; } } --- NEW FILE: ufsmount.h --- /*- * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 * * From: src/sys/ufs/ufs/ufsmount.h,v 1.37 * * $Id: ufsmount.h,v 1.1 2008/03/19 23:06:36 nightgoblin Exp $ */ #ifndef _UFS_UFS_UFSMOUNT_H_ #define _UFS_UFS_UFSMOUNT_H_ #include <sys/buf.h> /* XXX For struct workhead. */ /* * Arguments to mount UFS-based filesystems */ struct ufs_args { char *fspec; /* block special device to mount */ struct export_args export; /* network export information */ }; #ifdef _KERNEL #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_UFSMNT); #endif struct buf; struct inode; struct nameidata; struct timeval; struct ucred; struct uio; struct vnode; struct ufs_extattr_per_mount; /* This structure describes the UFS specific mount structure data. */ struct ufsmount { struct mount *um_mountp; /* filesystem vfs structure */ struct cdev *um_dev; /* device mounted */ struct g_consumer *um_cp; struct bufobj *um_bo; /* Buffer cache object */ struct vnode *um_devvp; /* block device mounted vnode */ u_long um_fstype; /* type of filesystem */ union { /* pointer to superblock */ struct fs *fs; /* FFS */ struct m_ext2fs *e2fs; /* EXT2FS */ } ufsmount_u; #define um_fs ufsmount_u.fs #define um_e2fs ufsmount_u.e2fs #define um_e2fsb ufsmount_u.e2fs->s_es struct ufs_extattr_per_mount um_extattr; /* extended attrs */ u_long um_nindir; /* indirect ptrs per block */ u_long um_bptrtodb; /* indir ptr to disk block */ u_long um_seqinc; /* inc between seq blocks */ struct mtx um_lock; /* Protects ufsmount & fs */ long um_numindirdeps; /* outstanding indirdeps */ struct workhead softdep_workitem_pending; /* softdep work queue */ struct worklist *softdep_worklist_tail; /* Tail pointer for above */ int softdep_on_worklist; /* Items on the worklist */ int softdep_on_worklist_inprogress; /* Busy items on worklist */ int softdep_deps; /* Total dependency count */ int softdep_accdeps; /* accumulated dep count */ int softdep_req; /* Wakeup when deps hits 0. */ struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ time_t um_btime[MAXQUOTAS]; /* block quota time limit */ time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ char um_qflags[MAXQUOTAS]; /* quota specific flags */ int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **); int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **); int (*um_truncate)(struct vnode *, off_t, int, struct ucred *, struct thread *); int (*um_update)(struct vnode *, int); int (*um_valloc)(struct vnode *, int, struct ucred *, struct vnode **); int (*um_vfree)(struct vnode *, ino_t, int); void (*um_ifree)(struct ufsmount *, struct inode *); }; #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) #define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd) #define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee) #define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb) #define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd) #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) #define UFS_MTX(aa) (&(aa)->um_lock) /* * Filesystem types */ #define UFS1 1 #define UFS2 2 /* * Flags describing the state of quotas. */ #define QTF_OPENING 0x01 /* Q_QUOTAON in progress */ #define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */ /* Convert mount ptr to ufsmount ptr. */ #define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data)) #define UFSTOVFS(ump) (ump)->um_mountp /* * Macros to access filesystem parameters in the ufsmount structure. * Used by ufs_bmap. */ #define MNINDIR(ump) ((ump)->um_nindir) #define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) #define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) #endif /* _KERNEL */ #endif Index: ext2fs_dir.h =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_dir.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_dir.h 14 Mar 2008 18:31:41 -0000 1.1.1.1 +++ ext2fs_dir.h 19 Mar 2008 23:06:36 -0000 1.2 @@ -1,4 +1,5 @@ /* $NetBSD: ext2fs_dir.h,v 1.15 2007/12/25 18:33:49 perry Exp $ */ +/* $Id$ */ /* * Copyright (c) 1982, 1986, 1989, 1993 Index: ext2fs_lookup.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_lookup.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ext2fs_lookup.c 14 Mar 2008 18:31:57 -0000 1.1.1.1 +++ ext2fs_lookup.c 19 Mar 2008 23:06:36 -0000 1.2 @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.55 2007/12/08 19:29:53 pooka Exp $"); +__RCSID("$Id$"); #include <sys/param.h> #include <sys/systm.h> @@ -58,19 +58,21 @@ #include <sys/mount.h> #include <sys/vnode.h> #include <sys/malloc.h> -#include <sys/dirent.h> -#include <sys/kauth.h> +#include <fs/bsdext2fs/dirent.h> #include <sys/proc.h> -#include <ufs/ufs/inode.h> -#include <ufs/ufs/ufsmount.h> -#include <ufs/ufs/ufs_extern.h> - -#include <ufs/ext2fs/ext2fs_extern.h> -#include <ufs/ext2fs/ext2fs_dir.h> -#include <ufs/ext2fs/ext2fs.h> +#include <vm/vm.h> +#include <vm/vm_extern.h> -extern int dirchk; +#include <ufs/ufs/quota.h> +#include <ufs/ufs/extattr.h> +#include <fs/bsdext2fs/inode.h> +#include <fs/bsdext2fs/ufsmount.h> +#include <ufs/ufs/ufs_extern.h> +#include <fs/bsdext2fs/ext2fs.h> +#include <fs/bsdext2fs/ext2fs_dinode.h> +#include <fs/bsdext2fs/ext2fs_extern.h> +#include <fs/bsdext2fs/ext2fs_dir.h> static void ext2fs_dirconv2ffs(struct ext2fs_direct *e2dir, struct dirent *ffsdir); @@ -126,16 +128,16 @@ * the whole buffer to uiomove */ int -ext2fs_readdir(void *v) -{ +ext2fs_readdir(ap) struct vop_readdir_args /* { struct vnode *a_vp; struct uio *a_uio; - kauth_cred_t a_cred; + struct ucred *a_cred; int **a_eofflag; off_t **a_cookies; int ncookies; - } */ *ap = v; + } */ *ap; +{ struct uio *uio = ap->a_uio; int error; size_t e2fs_count, readcnt; @@ -148,7 +150,7 @@ struct iovec aiov; void *dirbuf; off_t off = uio->uio_offset; - off_t *cookies = NULL; + u_long *cookies = NULL; int nc = 0, ncookies = 0; int e2d_reclen; @@ -166,7 +168,7 @@ auio.uio_iovcnt = 1; aiov.iov_len = e2fs_count; auio.uio_resid = e2fs_count; - UIO_SETUP_SYSSPACE(&auio); + auio.uio_segflg = UIO_SYSSPACE; dirbuf = malloc(e2fs_count, M_TEMP, M_WAITOK); dstd = malloc(sizeof(struct dirent), M_TEMP, M_WAITOK | M_ZERO); if (ap->a_ncookies) { @@ -257,13 +259,13 @@ * nor deleting, add name to cache */ int -ext2fs_lookup(void *v) -{ +ext2fs_lookup(ap) struct vop_lookup_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; - } */ *ap = v; + } */ *ap; +{ 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 */ @@ -284,15 +286,12 @@ int namlen, error; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; - kauth_cred_t cred = cnp->cn_cred; - int flags; + struct ucred *cred = cnp->cn_cred; + int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct ufsmount *ump = dp->i_ump; - int dirblksiz = ump->um_dirblksiz; + struct thread *td = cnp->cn_thread; ino_t foundino; - flags = cnp->cn_flags; - bp = NULL; slotoffset = -1; *vpp = NULL; @@ -300,7 +299,7 @@ /* * Check accessiblity of directory. */ - if ((error = VOP_ACCESS(vdp, VEXEC, cred)) != 0) + if ((error = VOP_ACCESS(vdp, VEXEC, cred, td)) != 0) return (error); if ((flags & ISLASTCN) && (vdp->v_mount->mnt_flag & MNT_RDONLY) && @@ -357,19 +356,17 @@ nchstats.ncs_2passes++; } prevoff = dp->i_offset; - endsearch = roundup(ext2fs_size(dp), dirblksiz); + endsearch = roundup(ext2fs_size(dp), DEV_BSIZE); enduseful = 0; searchloop: while (dp->i_offset < endsearch) { - if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) - preempt(); /* * If necessary, get the next directory block. */ if ((dp->i_offset & bmask) == 0) { if (bp != NULL) - brelse(bp, 0); + brelse(bp); error = ext2fs_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp); if (error != 0) @@ -381,7 +378,7 @@ * boundary, have to start looking for free space again. */ if (slotstatus == NONE && - (entryoffsetinblock & (dirblksiz - 1)) == 0) { + (entryoffsetinblock & (DEV_BSIZE - 1)) == 0) { slotoffset = -1; slotfreespace = 0; } @@ -392,16 +389,15 @@ * directory. Complete checks can be run by patching * "dirchk" to be true. */ - KASSERT(bp != NULL); + MPASS(bp != NULL); ep = (struct ext2fs_direct *) ((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 = dirblksiz - (entryoffsetinblock & (dirblksiz - 1)); + i = DEV_BSIZE - (entryoffsetinblock & (DEV_BSIZE - 1)); dp->i_offset += i; entryoffsetinblock += i; continue; @@ -473,19 +469,19 @@ goto searchloop; } if (bp != NULL) - brelse(bp, 0); + brelse(bp); /* * If creating, and at end of pathname and current * directory has not been removed, then can consider * allowing file to be created. */ if ((nameiop == CREATE || nameiop == RENAME) && - (flags & ISLASTCN) && dp->i_e2fs_nlink != 0) { + (flags & ISLASTCN) && dp->i_e2di->e2di_nlink != 0) { /* * Access for write is interpreted as allowing * creation of files in the directory. */ - error = VOP_ACCESS(vdp, VWRITE, cred); + error = VOP_ACCESS(vdp, VWRITE, cred, td); if (error) return (error); /* @@ -498,7 +494,7 @@ * dp->i_offset + dp->i_count. */ if (slotstatus == NONE) { - dp->i_offset = roundup(ext2fs_size(dp), dirblksiz); + dp->i_offset = roundup(ext2fs_size(dp), DEV_BSIZE); dp->i_count = 0; enduseful = dp->i_offset; } else { @@ -507,7 +503,7 @@ if (enduseful < slotoffset + slotsize) enduseful = slotoffset + slotsize; } - dp->i_endoff = roundup(enduseful, dirblksiz); + dp->i_endoff = roundup(enduseful, DEV_BSIZE); #if 0 dp->i_flag |= IN_CHANGE | IN_UPDATE; #endif @@ -546,13 +542,13 @@ error = ext2fs_setsize(dp, dp->i_offset + EXT2FS_DIRSIZ(ep->e2d_namlen)); if (error) { - brelse(bp, 0); + brelse(bp); return (error); } dp->i_flag |= IN_CHANGE | IN_UPDATE; - uvm_vnp_setsize(vdp, ext2fs_size(dp)); + vnode... [truncated message content] |