]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/xfs_extfree_item.c
[PATCH] proc: Use sane permission checks on the /proc/<pid>/fd/ symlinks
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_extfree_item.c
index cc7d1494a45d1a449151451f3a109d4abec8589d..6cf6d8769b975902c290a4485372b9b507793aa1 100644 (file)
@@ -1,50 +1,28 @@
 /*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-
-/*
- * This file contains the implementation of the xfs_efi_log_item
- * and xfs_efd_log_item items.
- */
-
 #include "xfs.h"
-
-#include "xfs_macros.h"
+#include "xfs_fs.h"
 #include "xfs_types.h"
-#include "xfs_inum.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_buf_item.h"
 #include "xfs_sb.h"
-#include "xfs_dir.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_trans_priv.h"
@@ -314,6 +292,62 @@ xfs_efi_init(xfs_mount_t   *mp,
        return (efip);
 }
 
+/*
+ * Copy an EFI format buffer from the given buf, and into the destination
+ * EFI format structure.
+ * The given buffer can be in 32 bit or 64 bit form (which has different padding),
+ * one of which will be the native format for this kernel.
+ * It will handle the conversion of formats if necessary.
+ */
+int
+xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
+{
+       xfs_efi_log_format_t *src_efi_fmt = (xfs_efi_log_format_t *)buf->i_addr;
+       uint i;
+       uint len = sizeof(xfs_efi_log_format_t) + 
+               (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t);  
+       uint len32 = sizeof(xfs_efi_log_format_32_t) + 
+               (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_32_t);  
+       uint len64 = sizeof(xfs_efi_log_format_64_t) + 
+               (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_64_t);  
+
+       if (buf->i_len == len) {
+               memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len);
+               return 0;
+       } else if (buf->i_len == len32) {
+               xfs_efi_log_format_32_t *src_efi_fmt_32 =
+                       (xfs_efi_log_format_32_t *)buf->i_addr;
+
+               dst_efi_fmt->efi_type     = src_efi_fmt_32->efi_type;
+               dst_efi_fmt->efi_size     = src_efi_fmt_32->efi_size;
+               dst_efi_fmt->efi_nextents = src_efi_fmt_32->efi_nextents;
+               dst_efi_fmt->efi_id       = src_efi_fmt_32->efi_id;
+               for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
+                       dst_efi_fmt->efi_extents[i].ext_start =
+                               src_efi_fmt_32->efi_extents[i].ext_start;
+                       dst_efi_fmt->efi_extents[i].ext_len =
+                               src_efi_fmt_32->efi_extents[i].ext_len;
+               }
+               return 0;
+       } else if (buf->i_len == len64) {
+               xfs_efi_log_format_64_t *src_efi_fmt_64 =
+                       (xfs_efi_log_format_64_t *)buf->i_addr;
+
+               dst_efi_fmt->efi_type     = src_efi_fmt_64->efi_type;
+               dst_efi_fmt->efi_size     = src_efi_fmt_64->efi_size;
+               dst_efi_fmt->efi_nextents = src_efi_fmt_64->efi_nextents;
+               dst_efi_fmt->efi_id       = src_efi_fmt_64->efi_id;
+               for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
+                       dst_efi_fmt->efi_extents[i].ext_start =
+                               src_efi_fmt_64->efi_extents[i].ext_start;
+                       dst_efi_fmt->efi_extents[i].ext_len =
+                               src_efi_fmt_64->efi_extents[i].ext_len;
+               }
+               return 0;
+       }
+       return EFSCORRUPTED;
+}
+
 /*
  * This is called by the efd item code below to release references to
  * the given efi item.  Each efd calls this with the number of