src Makefile, 1.1, 1.2 ext2fs_inode.c, 1.2, 1.3 ext2fs_readwrite.c, 1.2, 1.3 ext2fs_vfsops.c, 1.3,
Status: Alpha
Brought to you by:
pluknet
From: pluknet <pl...@us...> - 2008-12-16 23:45:32
|
Update of /cvsroot/bsdext2fs/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12173 Modified Files: Makefile ext2fs_inode.c ext2fs_readwrite.c ext2fs_vfsops.c ext2fs_vnops.c ufsmount.h Log Message: Sync up with recent FreeBSD 7/8. Index: ext2fs_vnops.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_vnops.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ext2fs_vnops.c 27 Mar 2008 02:23:49 -0000 1.3 +++ ext2fs_vnops.c 16 Dec 2008 23:45:26 -0000 1.4 @@ -227,21 +227,33 @@ ext2fs_access(ap) struct vop_access_args /* { struct vnode *a_vp; +#if __FreeBSD__ < 8 int a_mode; +#else + accmode_t a_accmode; +#endif struct ucred *a_cred; struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); +#if __FreeBSD__ < 8 mode_t mode = ap->a_mode; +#else + accmode_t accmode = ap->a_accmode; +#endif /* * Disallow write attempts on read-only file systems; * unless the file is a socket, fifo, or a block or * character device resident on the file system. */ +#if __FreeBSD__ < 8 if (mode & VWRITE) { +#else + if (accmode & VWRITE) { +#endif switch (vp->v_type) { case VDIR: case VLNK: @@ -255,11 +267,19 @@ } /* If immutable bit set, nobody gets to write it. */ +#if __FreeBSD__ < 8 if ((mode & VWRITE) && (ip->i_e2di->e2di_flags & EXT2_IMMUTABLE)) +#else + if ((accmode & VWRITE) && (ip->i_e2di->e2di_flags & EXT2_IMMUTABLE)) +#endif return (EPERM); return (vaccess(vp->v_type, ip->i_e2di->e2di_mode & ALLPERMS, +#if __FreeBSD__ < 8 ip->i_e2di->e2di_uid, ip->i_e2di->e2di_gid, mode, +#else + ip->i_e2di->e2di_uid, ip->i_e2di->e2di_gid, accmode, +#endif ap->a_cred, NULL)); } @@ -328,7 +348,11 @@ struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct ucred *cred = ap->a_cred; +#if __FreeBSD__ < 8 struct thread *td = ap->a_td; +#else + struct thread *td = curthread; +#endif int error; /* @@ -344,7 +368,11 @@ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != ip->i_e2di->e2di_uid && +#if __FreeBSD__ < 8 (error = suser_cred(cred, td->td_proc->p_acflag))) +#else + (error = priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0))) +#endif return (error); ip->i_e2di->e2di_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE); ip->i_e2di->e2di_flags |= @@ -391,7 +419,11 @@ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != ip->i_e2di->e2di_uid && +#if __FreeBSD__ < 8 (error = suser_cred(cred, td->td_proc->p_acflag)) && +#else + (error = priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) && +#endif ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || (error = VOP_ACCESS(vp, VWRITE, cred, td)))) return (error); @@ -424,13 +456,26 @@ struct inode *ip = VTOI(vp); int error; - if (cred->cr_uid != ip->i_e2di->e2di_uid && - (error = suser_cred(cred, td->td_proc->p_acflag))) - return (error); - if (cred->cr_uid) { - if (vp->v_type != VDIR && (mode & S_ISTXT)) + /* + * To modify the permissions on a file, must possess VADMIN + * for that file. + */ + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) + return (error); + if (vp->v_type != VDIR && (mode & S_ISTXT)) { +#if __FreeBSD__ < 7 + if (suser_cred(cred, td->td_proc->p_acflag)) +#else + if (priv_check_cred(cred, PRIV_VFS_STICKYFILE, 0)) +#endif return (EFTYPE); - if (!groupmember(ip->i_e2di->e2di_gid, cred) && (mode & S_ISGID)) + } + if (!groupmember(ip->i_e2di->e2di_gid, cred) && (mode & S_ISGID)) { +#if __FreeBSD__ < 7 + if (suser_cred(cred, td->td_proc->p_acflag)) +#else + error = priv_check_cred(cred, PRIV_VFS_SETGID, 0); +#endif return (EPERM); } ip->i_e2di->e2di_mode &= ~ALLPERMS; @@ -457,14 +502,23 @@ if (gid == (gid_t)VNOVAL) gid = ip->i_e2di->e2di_gid; /* + * To modify the ownership of a file, must possess VADMIN for that + * file. + */ + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) + return (error); + /* * If we don't own the file, are trying to change the owner * of the file, or are not a member of the target group, * the caller must be superuser or the call fails. */ - if ((cred->cr_uid != ip->i_e2di->e2di_uid || uid != ip->i_e2di->e2di_uid || - (gid != ip->i_e2di->e2di_gid && - !(cred->cr_uid == gid || groupmember((gid_t)gid, cred)))) && + if ((uid != ip->i_e2di->e2di_uid || + (gid != ip->i_e2di->e2di_gid && !groupmember((gid_t)gid, cred))) && +#if __FreeBSD__ < 7 (error = suser_cred(cred, td->td_proc->p_acflag))) +#else + (error = priv_check_cred(cred, PRIV_VFS_CHOWN, 0))) +#endif return (error); ogid = ip->i_e2di->e2di_gid; ouid = ip->i_e2di->e2di_uid; @@ -1364,8 +1418,12 @@ tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */ ip->i_e2di->e2di_nlink = 1; if ((ip->i_e2di->e2di_mode & ISGID) && - !groupmember(ip->i_e2di->e2di_gid, cnp->cn_cred) && + !groupmember(ip->i_e2di->e2di_gid, cnp->cn_cred) && +#if __FreeBSD__ < 7 suser_cred(cnp->cn_cred, 0)) +#else + priv_check_cred(cnp->cn_cred, PRIV_VFS_SETGID, 0)) +#endif ip->i_e2di->e2di_mode &= ~ISGID; /* Index: Makefile =================================================================== RCS file: /cvsroot/bsdext2fs/src/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 19 Mar 2008 23:06:36 -0000 1.1 +++ Makefile 16 Dec 2008 23:45:26 -0000 1.2 @@ -7,10 +7,6 @@ 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 +WARNS?= 2 .include <bsd.kmod.mk> Index: ext2fs_readwrite.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_readwrite.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ext2fs_readwrite.c 19 Mar 2008 23:06:36 -0000 1.2 +++ ext2fs_readwrite.c 16 Dec 2008 23:45:26 -0000 1.3 @@ -145,11 +145,11 @@ panic("%s: type %d", "ext2fs_read", vp->v_type); #endif fs = ip->i_e2fs; - if ((u_int64_t)uio->uio_offset > ump->um_savedmaxfilesize) + if (uio->uio_offset > ump->um_savedmaxfilesize) return (EFBIG); if (uio->uio_resid == 0) return (0); - if (uio->uio_offset >= ext2fs_size(ip)) + if ((uint64_t)uio->uio_offset >= ext2fs_size(ip)) goto out; for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { @@ -166,7 +166,7 @@ if (bytesinfile < xfersize) xfersize = bytesinfile; - if (lblktosize(fs, nextlbn) >= ext2fs_size(ip)) + if ((uint64_t)lblktosize(fs, nextlbn) >= ext2fs_size(ip)) error = bread(vp, lbn, size, NOCRED, &bp); else { int nextsize = fs->e2fs_bsize; Index: ufsmount.h =================================================================== RCS file: /cvsroot/bsdext2fs/src/ufsmount.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ufsmount.h 19 Mar 2008 23:06:36 -0000 1.1 +++ ufsmount.h 16 Dec 2008 23:45:26 -0000 1.2 @@ -73,8 +73,8 @@ 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_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 */ Index: ext2fs_inode.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_inode.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ext2fs_inode.c 19 Mar 2008 23:06:36 -0000 1.2 +++ ext2fs_inode.c 16 Dec 2008 23:45:26 -0000 1.3 @@ -306,7 +306,11 @@ vnode_pager_setsize(vp, length); ip->i_flag |= IN_CHANGE | IN_UPDATE; +#if __FreeBSD__ < 8 error = VOP_GETATTR(vp, &va, cred, td); +#else + error = VOP_GETATTR(vp, &va, cred); +#endif if (error) return (error); MPASS(error || va.va_size == ext2fs_size(ip)); @@ -449,7 +453,11 @@ (void)ext2fs_setsize(ip, length); ip->i_e2di->e2di_nblock -= blocksreleased; ip->i_flag |= IN_CHANGE; +#if __FreeBSD__ < 8 VOP_GETATTR(vp, &va, cred, td); +#else + VOP_GETATTR(vp, &va, cred); +#endif if (error) return (error); MPASS(vp->v_type != VREG || va.va_size == ext2fs_size(ip)); Index: ext2fs_vfsops.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_vfsops.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ext2fs_vfsops.c 27 Mar 2008 02:23:49 -0000 1.3 +++ ext2fs_vfsops.c 16 Dec 2008 23:45:26 -0000 1.4 @@ -245,12 +245,20 @@ if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; printf("vfs_busy\n"); +#if __FreeBSD__ < 8 if (vfs_busy(mp, LK_NOWAIT, 0, td)) +#else + if (vfs_busy(mp, LK_NOWAIT)) +#endif return (EBUSY); printf("ext2fs_mount -> ext2fs_flushfiles\n"); error = ext2fs_flushfiles(mp, flags, td); printf("ext2fs_mount <- ext2fs_flushfiles\n"); +#if __FreeBSD__ < 8 vfs_unbusy(mp, td); +#else + vfs_unbusy(mp); +#endif if (error == 0 && ext2fs_cgupdate(ump, MNT_WAIT) == 0 && (fs->e2fs.e2fs_state & E2FS_ERRORS) == 0) { @@ -425,13 +433,11 @@ devvp = VFSTOUFS(mp)->um_devvp; #if __FreeBSD_version < 800000 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); -#else - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); -#endif - error = vinvalbuf(devvp, 0, td, 0, 0); -#if __FreeBSD_version < 800000 + VOP_UNLOCK(devvp, 0, td); VOP_UNLOCK(devvp, 0, td); #else + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); + error = vinvalbuf(devvp, 0, 0, 0); VOP_UNLOCK(devvp, 0); #endif if (error) @@ -505,7 +511,11 @@ MNT_VNODE_FOREACH_ABORT(mp, mvp); goto loop; } +#if __FreeBSD_version < 800000 if (vinvalbuf(vp, 0, td, 0, 0)) +#else + if (vinvalbuf(vp, 0, 0, 0)) +#endif panic("ext2fs_reload: dirty2"); /* * Step 5: re-read inode data for all active vnodes. @@ -575,7 +585,11 @@ (SBSIZE < cp->provider->sectorsize)) { DROP_GIANT(); g_topology_lock(); +#if __FreeBSD__ < 8 g_vfs_close(cp, td); +#else + g_vfs_close(cp); +#endif g_topology_unlock(); PICKUP_GIANT(); return (EINVAL); @@ -678,7 +692,11 @@ if (cp != NULL) { DROP_GIANT(); g_topology_lock(); +#if __FreeBSD__ < 8 g_vfs_close(cp, td); +#else + g_vfs_close(cp); +#endif g_topology_unlock(); PICKUP_GIANT(); } @@ -722,7 +740,11 @@ printf("ext2fs_umount ump->um_cp %p\n", ump->um_cp); DROP_GIANT(); g_topology_lock(); +#if __FreeBSD__ < 8 g_vfs_close(ump->um_cp, td); +#else + g_vfs_close(ump->um_cp); +#endif g_topology_unlock(); PICKUP_GIANT(); printf("ext2fs_unmount g_vfs_close POST\n"); |