summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2023-03-30 10:11:57 -0700
committerColin Cross <ccross@android.com>2023-03-30 12:31:03 -0700
commit07183db29cd9a176901d8f1aab75f324e92397d2 (patch)
tree336809d23ad8e1599c92ceb06f3559a7faa0ac80 /ext4_utils
parentc0766c1ceade3488565a421bacbb8f30026f6928 (diff)
downloadextras-07183db29cd9a176901d8f1aab75f324e92397d2.tar.gz
Don't use _LARGEFILE64_SOURCE in ext4_utils.h
Defining _LARGEFILE64_SOURCE in ext4_utils.h is problematic because ext4_utils.h is included by system/core/fs_mgr after system headers, which could cause inconsistent definitions. _LARGEFILE64_SOURCE was only being used for lseek64, which is unnecessary when _FILE_OFFSET_BITS=64 is set. Remove _LARGEFILE64_SOURCE and switch lseek64 to lseek. Also move _FILE_OFFSET_BITS=64 to the Android.bp file, the functions defined in ext4_utils.h don't use off_t. Remove _GNU_SOURCE, it is already set by the default -std=gnu11. This is a step towards removing usage of _LARGEFILE64_SOURCE in favor of setting _FILE_OFFSET_BITS=64 globally. Test: builds Change-Id: I14c7e0ca0fd85920aa0b1d1a18fc5a11d352a4c5
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/Android.bp1
-rw-r--r--ext4_utils/ext4_utils.cpp13
-rw-r--r--ext4_utils/include/ext4_utils/ext4_utils.h12
3 files changed, 6 insertions, 20 deletions
diff --git a/ext4_utils/Android.bp b/ext4_utils/Android.bp
index ba2c8ac0..b28e84f3 100644
--- a/ext4_utils/Android.bp
+++ b/ext4_utils/Android.bp
@@ -32,6 +32,7 @@ cc_library {
cflags: [
"-Werror",
"-fno-strict-aliasing",
+ "-D_FILE_OFFSET_BITS=64",
],
export_include_dirs: ["include"],
shared_libs: [
diff --git a/ext4_utils/ext4_utils.cpp b/ext4_utils/ext4_utils.cpp
index 5fce61bc..dde75903 100644
--- a/ext4_utils/ext4_utils.cpp
+++ b/ext4_utils/ext4_utils.cpp
@@ -83,12 +83,9 @@ int ext4_bg_has_super_block(int bg) {
/* Function to read the primary superblock */
void read_sb(int fd, struct ext4_super_block* sb) {
- off64_t ret;
+ if (lseek(fd, 1024, SEEK_SET) < 0) critical_error_errno("failed to seek to superblock");
- ret = lseek64(fd, 1024, SEEK_SET);
- if (ret < 0) critical_error_errno("failed to seek to superblock");
-
- ret = read(fd, sb, sizeof(*sb));
+ ssize_t ret = read(fd, sb, sizeof(*sb));
if (ret < 0) critical_error_errno("failed to read superblock");
if (ret != sizeof(*sb)) critical_error("failed to read all of superblock");
}
@@ -277,17 +274,17 @@ static void read_block_group_descriptors(int fd) {
}
int read_ext(int fd, int verbose) {
- off64_t ret;
+ off_t ret;
struct ext4_super_block sb;
read_sb(fd, &sb);
ext4_parse_sb_info(&sb);
- ret = lseek64(fd, info.len, SEEK_SET);
+ ret = lseek(fd, info.len, SEEK_SET);
if (ret < 0) critical_error_errno("failed to seek to end of input image");
- ret = lseek64(fd, info.block_size * (aux_info.first_data_block + 1), SEEK_SET);
+ ret = lseek(fd, info.block_size * (aux_info.first_data_block + 1), SEEK_SET);
if (ret < 0) critical_error_errno("failed to seek to block group descriptors");
read_block_group_descriptors(fd);
diff --git a/ext4_utils/include/ext4_utils/ext4_utils.h b/ext4_utils/include/ext4_utils/ext4_utils.h
index 48f3ee78..d6bef68d 100644
--- a/ext4_utils/include/ext4_utils/ext4_utils.h
+++ b/ext4_utils/include/ext4_utils/ext4_utils.h
@@ -21,11 +21,6 @@
extern "C" {
#endif
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#define _FILE_OFFSET_BITS 64
-#define _LARGEFILE64_SOURCE 1
#include <sys/types.h>
#include <unistd.h>
@@ -38,13 +33,6 @@ extern "C" {
#include <string.h>
#include <sys/types.h>
-#if defined(__APPLE__) && defined(__MACH__)
-#define lseek64 lseek
-#define ftruncate64 ftruncate
-#define mmap64 mmap
-#define off64_t off_t
-#endif
-
#include "ext4_sb.h"
extern int force;