Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs Collect the pieces of lfs rename into lfs_rename.c, ...
details: https://anonhg.NetBSD.org/src/rev/4e8d956d9827
branches: trunk
changeset: 788804:4e8d956d9827
user: dholland <dholland%NetBSD.org@localhost>
date: Sat Jul 20 19:59:31 2013 +0000
description:
Collect the pieces of lfs rename into lfs_rename.c, and sprinkle static.
diffstat:
sys/ufs/files.ufs | 4 +-
sys/ufs/lfs/lfs_extern.h | 5 +-
sys/ufs/lfs/lfs_rename.c | 1222 +++++++++++++++++++++++++++++++++++++++++++++
sys/ufs/lfs/lfs_vnops.c | 194 +------
sys/ufs/lfs/ulfs_extern.h | 25 +-
sys/ufs/lfs/ulfs_inode.h | 65 ++-
sys/ufs/lfs/ulfs_rename.c | 1047 --------------------------------------
7 files changed, 1297 insertions(+), 1265 deletions(-)
diffs (truncated from 2675 to 300 lines):
diff -r 755fefef2e91 -r 4e8d956d9827 sys/ufs/files.ufs
--- a/sys/ufs/files.ufs Sat Jul 20 18:46:15 2013 +0000
+++ b/sys/ufs/files.ufs Sat Jul 20 19:59:31 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.ufs,v 1.32 2013/06/08 22:07:24 dholland Exp $
+# $NetBSD: files.ufs,v 1.33 2013/07/20 19:59:31 dholland Exp $
deffs FFS
deffs EXT2FS
@@ -65,6 +65,7 @@
file ufs/lfs/lfs_debug.c lfs
file ufs/lfs/lfs_inode.c lfs
file ufs/lfs/lfs_itimes.c lfs
+file ufs/lfs/lfs_rename.c lfs
file ufs/lfs/lfs_rfw.c lfs & lfs_kernel_rfw
file ufs/lfs/lfs_segment.c lfs
file ufs/lfs/lfs_subr.c lfs
@@ -82,7 +83,6 @@
file ufs/lfs/ulfs_quota2.c lfs & lfs_quota2
file ufs/lfs/ulfs_quota1_subr.c lfs
file ufs/lfs/ulfs_quota2_subr.c lfs & lfs_quota2
-file ufs/lfs/ulfs_rename.c lfs
file ufs/lfs/ulfs_snapshot.c lfs
file ufs/lfs/ulfs_vfsops.c lfs
file ufs/lfs/ulfs_vnops.c lfs
diff -r 755fefef2e91 -r 4e8d956d9827 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h Sat Jul 20 18:46:15 2013 +0000
+++ b/sys/ufs/lfs/lfs_extern.h Sat Jul 20 19:59:31 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_extern.h,v 1.99 2013/06/06 00:48:04 dholland Exp $ */
+/* $NetBSD: lfs_extern.h,v 1.100 2013/07/20 19:59:31 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -167,6 +167,9 @@
void lfs_finalize_ino_seguse(struct lfs *, struct inode *);
void lfs_finalize_fs_seguse(struct lfs *);
+/* lfs_rename.c */
+int lfs_rename(void *);
+
/* lfs_rfw.c */
int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **);
void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *);
diff -r 755fefef2e91 -r 4e8d956d9827 sys/ufs/lfs/lfs_rename.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/lfs/lfs_rename.c Sat Jul 20 19:59:31 2013 +0000
@@ -0,0 +1,1222 @@
+/* $NetBSD: lfs_rename.c,v 1.1 2013/07/20 19:59:31 dholland Exp $ */
+/* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R Campbell.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+/*-
+ * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Konrad E. Schroder <perseant%hhhh.org@localhost>.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+/*
+ * Copyright (c) 1986, 1989, 1991, 1993, 1995
+ * 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.
+ *
+ * @(#)lfs_vnops.c 8.13 (Berkeley) 6/10/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.1 2013/07/20 19:59:31 dholland Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/namei.h>
+#include <sys/resourcevar.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/buf.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/vnode_if.h>
+#include <sys/pool.h>
+#include <sys/signalvar.h>
+#include <sys/kauth.h>
+#include <sys/syslog.h>
+#include <sys/fstrans.h>
+
+#include <uvm/uvm.h>
+#include <uvm/uvm_pmap.h>
+#include <uvm/uvm_stat.h>
+#include <uvm/uvm_pager.h>
+
+#include <miscfs/fifofs/fifo.h>
+#include <miscfs/genfs/genfs.h>
+#include <miscfs/specfs/specdev.h>
+
+#include <ufs/lfs/ulfs_inode.h>
+#include <ufs/lfs/ulfsmount.h>
+#include <ufs/lfs/ulfs_bswap.h>
+#include <ufs/lfs/ulfs_extern.h>
+
+#include <ufs/lfs/lfs.h>
+#include <ufs/lfs/lfs_extern.h>
+
+/*
+ * A virgin directory (no blushing please).
+ *
+ * XXX Copypasta from ulfs_vnops.c. Kill!
+ */
+static const struct lfs_dirtemplate mastertemplate = {
+ 0, 12, LFS_DT_DIR, 1, ".",
+ 0, LFS_DIRBLKSIZ - 12, LFS_DT_DIR, 2, ".."
+};
+
+/*
+ * ulfs_gro_directory_empty_p: Return true if the directory vp is
+ * empty. dvp is its parent.
+ *
+ * vp and dvp must be locked and referenced.
+ */
+static bool
+ulfs_gro_directory_empty_p(struct mount *mp, kauth_cred_t cred,
+ struct vnode *vp, struct vnode *dvp)
+{
+
+ (void)mp;
+ KASSERT(mp != NULL);
+ KASSERT(vp != NULL);
+ KASSERT(dvp != NULL);
+ KASSERT(vp != dvp);
+ KASSERT(vp->v_mount == mp);
+ KASSERT(dvp->v_mount == mp);
+ KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+ KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+
+ return ulfs_dirempty(VTOI(vp), VTOI(dvp)->i_number, cred);
+}
+
+/*
+ * ulfs_gro_rename_check_possible: Check whether a rename is possible
+ * independent of credentials.
+ */
+static int
+ulfs_gro_rename_check_possible(struct mount *mp,
+ struct vnode *fdvp, struct vnode *fvp,
+ struct vnode *tdvp, struct vnode *tvp)
+{
+
+ (void)mp;
+ KASSERT(mp != NULL);
+ KASSERT(fdvp != NULL);
+ KASSERT(fvp != NULL);
+ KASSERT(tdvp != NULL);
+ KASSERT(fdvp != fvp);
+ KASSERT(fdvp != tvp);
+ KASSERT(tdvp != fvp);
+ KASSERT(tdvp != tvp);
+ KASSERT(fvp != tvp);
+ KASSERT(fdvp->v_type == VDIR);
+ KASSERT(tdvp->v_type == VDIR);
+ KASSERT(fdvp->v_mount == mp);
+ KASSERT(fvp->v_mount == mp);
+ KASSERT(tdvp->v_mount == mp);
+ KASSERT((tvp == NULL) || (tvp->v_mount == mp));
+ KASSERT(VOP_ISLOCKED(fdvp) == LK_EXCLUSIVE);
+ KASSERT(VOP_ISLOCKED(fvp) == LK_EXCLUSIVE);
+ KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
+ KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
+
+ return genfs_ufslike_rename_check_possible(
+ VTOI(fdvp)->i_flags, VTOI(fvp)->i_flags,
+ VTOI(tdvp)->i_flags, (tvp? VTOI(tvp)->i_flags : 0),
+ (tvp != NULL),
+ IMMUTABLE, APPEND);
+}
+
+/*
+ * ulfs_gro_rename_check_permitted: Check whether a rename is permitted
+ * given our credentials.
+ */
+static int
+ulfs_gro_rename_check_permitted(struct mount *mp, kauth_cred_t cred,
+ struct vnode *fdvp, struct vnode *fvp,
+ struct vnode *tdvp, struct vnode *tvp)
+{
+
+ (void)mp;
+ KASSERT(mp != NULL);
+ KASSERT(fdvp != NULL);
+ KASSERT(fvp != NULL);
+ KASSERT(tdvp != NULL);
+ KASSERT(fdvp != fvp);
+ KASSERT(fdvp != tvp);
+ KASSERT(tdvp != fvp);
+ KASSERT(tdvp != tvp);
+ KASSERT(fvp != tvp);
+ KASSERT(fdvp->v_type == VDIR);
+ KASSERT(tdvp->v_type == VDIR);
+ KASSERT(fdvp->v_mount == mp);
+ KASSERT(fvp->v_mount == mp);
+ KASSERT(tdvp->v_mount == mp);
+ KASSERT((tvp == NULL) || (tvp->v_mount == mp));
+ KASSERT(VOP_ISLOCKED(fdvp) == LK_EXCLUSIVE);
+ KASSERT(VOP_ISLOCKED(fvp) == LK_EXCLUSIVE);
+ KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
+ KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
+
+ return genfs_ufslike_rename_check_permitted(cred,
+ fdvp, VTOI(fdvp)->i_mode, VTOI(fdvp)->i_uid,
+ fvp, VTOI(fvp)->i_uid,
+ tdvp, VTOI(tdvp)->i_mode, VTOI(tdvp)->i_uid,
+ tvp, (tvp? VTOI(tvp)->i_uid : 0));
+}
+
+/*
+ * ulfs_gro_remove_check_possible: Check whether a remove is possible
+ * independent of credentials.
+ */
+static int
+ulfs_gro_remove_check_possible(struct mount *mp,
+ struct vnode *dvp, struct vnode *vp)
+{
+
+ (void)mp;
+ KASSERT(mp != NULL);
+ KASSERT(dvp != NULL);
+ KASSERT(vp != NULL);
Home |
Main Index |
Thread Index |
Old Index