summaryrefslogtreecommitdiffstats
path: root/tools/power/acpi/common/cmfsize.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-06-03 23:12:27 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-06-03 23:12:27 +0200
commit0e36d43c9c87554cdb18aa865eec9edccda17324 (patch)
treedc2c2cfacca0e9c53ca8148dc91676a30be3f010 /tools/power/acpi/common/cmfsize.c
parentb04c58b1ed26317bfb4b33d3a2d16377fc6acd0f (diff)
parent729ddb657f6a47a2cb6e495f1ff68fff622c758a (diff)
downloadop-kernel-dev-0e36d43c9c87554cdb18aa865eec9edccda17324.zip
op-kernel-dev-0e36d43c9c87554cdb18aa865eec9edccda17324.tar.gz
Merge branch 'acpica'
* acpica: (63 commits) ACPICA: Namespace: Remove _PRP method support. ACPI: Fix x86 regression related to early mapping size limitation ACPICA: Tables: Add mechanism to control early table checksum verification. ACPICA: acpidump: Fix repetitive table dump in -n mode. ACPI: Clean up acpi_os_map/unmap_memory() to eliminate __iomem. ACPICA: Clean up redudant definitions already defined elsewhere ACPICA: Linux headers: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> ACPICA: Linux headers: Add <acpi/platform/aclinuxex.h> ACPICA: Linux headers: Remove ACPI_PREEMPTION_POINT() due to no usages. ACPICA: Update version to 20140424. ACPICA: Comment/format update, no functional change. ACPICA: Events: Update GPE handling and initialization code. ACPICA: Remove extraneous error message for large number of GPEs. ACPICA: Tables: Remove old mechanism to validate if XSDT contains NULL entries. ACPICA: Tables: Add new mechanism to skip NULL entries in RSDT and XSDT. ACPICA: acpidump: Add support to force using RSDT. ACPICA: Back port of improvements on exception code. ACPICA: Back port of _PRP update. ACPICA: acpidump: Fix truncated RSDP signature validation. ACPICA: Linux header: Add support for stubbed externals. ...
Diffstat (limited to 'tools/power/acpi/common/cmfsize.c')
-rw-r--r--tools/power/acpi/common/cmfsize.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/tools/power/acpi/common/cmfsize.c b/tools/power/acpi/common/cmfsize.c
new file mode 100644
index 0000000..5140e5e
--- /dev/null
+++ b/tools/power/acpi/common/cmfsize.c
@@ -0,0 +1,101 @@
+/******************************************************************************
+ *
+ * Module Name: cfsize - Common get file size function
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2014, Intel Corp.
+ * 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,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ */
+
+#include <acpi/acpi.h>
+#include "accommon.h"
+#include "acapps.h"
+#include <stdio.h>
+
+#define _COMPONENT ACPI_TOOLS
+ACPI_MODULE_NAME("cmfsize")
+
+/*******************************************************************************
+ *
+ * FUNCTION: cm_get_file_size
+ *
+ * PARAMETERS: file - Open file descriptor
+ *
+ * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX)
+ *
+ * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open.
+ * Does not disturb the current file pointer. Uses perror for
+ * error messages.
+ *
+ ******************************************************************************/
+u32 cm_get_file_size(FILE * file)
+{
+ long file_size;
+ long current_offset;
+
+ /* Save the current file pointer, seek to EOF to obtain file size */
+
+ current_offset = ftell(file);
+ if (current_offset < 0) {
+ goto offset_error;
+ }
+
+ if (fseek(file, 0, SEEK_END)) {
+ goto seek_error;
+ }
+
+ file_size = ftell(file);
+ if (file_size < 0) {
+ goto offset_error;
+ }
+
+ /* Restore original file pointer */
+
+ if (fseek(file, current_offset, SEEK_SET)) {
+ goto seek_error;
+ }
+
+ return ((u32)file_size);
+
+offset_error:
+ perror("Could not get file offset");
+ return (ACPI_UINT32_MAX);
+
+seek_error:
+ perror("Could not seek file");
+ return (ACPI_UINT32_MAX);
+}
OpenPOWER on IntegriCloud