/* Function to read the primary superblock */
void read_sb(int fd, struct ext4_super_block *sb)
{
- off64_t ret;
+ off_t ret;
- ret = lseek64(fd, 1024, SEEK_SET);
+ ret = lseek(fd, 1024, SEEK_SET);
if (ret < 0)
critical_error_errno("failed to seek to superblock");
/* Function to write a primary or backup superblock at a given offset */
void write_sb(int fd, unsigned long long offset, struct ext4_super_block *sb)
{
- off64_t ret;
+ off_t ret;
- ret = lseek64(fd, offset, SEEK_SET);
+ ret = lseek(fd, offset, SEEK_SET);
if (ret < 0)
critical_error_errno("failed to seek to superblock");
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");
#include <setjmp.h>
#include <stdint.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;
#include <fcntl.h>
#include <unistd.h>
-#if defined(__APPLE__) && defined(__MACH__)
-#define lseek64 lseek
-#define off64_t off_t
-#endif
-
/* The inode block count for a file/directory is in units of 512 byte blocks,
* _NOT_ the filesystem block size!
*/
return no_write_fixup_state;
}
- lseek64(fd, 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
len = read(fd, &magic, sizeof(magic));
if (len != sizeof(magic)) {
critical_error("cannot read fixup_state\n");
break;
}
- lseek64(fd, 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
len = write(fd, &magic, sizeof(magic));
if (len != sizeof(magic)) {
critical_error("cannot write fixup_state\n");
static int read_inode(int fd, unsigned int inum, struct ext4_inode *inode)
{
unsigned int bg_num, bg_offset;
- off64_t inode_offset;
+ off_t inode_offset;
int len;
bg_num = (inum-1) / info.inodes_per_group;
inode_offset = ((unsigned long long)aux_info.bg_desc[bg_num].bg_inode_table * info.block_size) +
(bg_offset * info.inode_size);
- if (lseek64(fd, inode_offset, SEEK_SET) < 0) {
+ if (lseek(fd, inode_offset, SEEK_SET) < 0) {
critical_error_errno("failed to seek to inode %d\n", inum);
}
static int read_block(int fd, unsigned long long block_num, void *block)
{
- off64_t off;
+ off_t off;
unsigned int len;
off = block_num * info.block_size;
- if (lseek64(fd, off, SEEK_SET) , 0) {
+ if (lseek(fd, off, SEEK_SET) , 0) {
critical_error_errno("failed to seek to block %lld\n", block_num);
}
static int write_block(int fd, unsigned long long block_num, void *block)
{
- off64_t off;
+ off_t off;
unsigned int len;
if (no_write) {
off = block_num * info.block_size;
- if (lseek64(fd, off, SEEK_SET) < 0) {
+ if (lseek(fd, off, SEEK_SET) < 0) {
critical_error_errno("failed to seek to block %lld\n", block_num);
}
/* Update the superblock and bgdesc of the specified block group */
static int update_superblocks_and_bg_desc(int fd, int state)
{
- off64_t ret;
+ off_t ret;
struct ext4_super_block sb;
unsigned int num_block_groups, total_new_inodes;
unsigned int i;
&sb);
}
- ret = lseek64(fd, ((unsigned long long)i * info.blocks_per_group * info.block_size) +
+ ret = lseek(fd, ((unsigned long long)i * info.blocks_per_group * info.block_size) +
(info.block_size * (aux_info.first_data_block + 1)), SEEK_SET);
if (ret < 0)
critical_error_errno("failed to seek to block group descriptors");
{
int i, j;
struct ext4_extent *extent;
- off64_t fs_block_num;
+ off_t fs_block_num;
if (ext_hdr->eh_depth != 0) {
critical_error("get_extent_ents called with eh_depth != 0\n");
extent = (struct ext4_extent *)(ext_hdr + 1);
for (i = 0; i < ext_hdr->eh_entries; i++) {
- fs_block_num = ((off64_t)extent->ee_start_hi << 32) | extent->ee_start_lo;
+ fs_block_num = ((off_t)extent->ee_start_hi << 32) | extent->ee_start_lo;
for (j = 0; j < extent->ee_len; j++) {
block_list[extent->ee_block+j] = fs_block_num+j;
}
int i;
struct ext4_extent_idx *extent_idx;
struct ext4_extent_header *tmp_ext_hdr;
- off64_t fs_block_num;
+ off_t fs_block_num;
unsigned char block[MAX_EXT4_BLOCK_SIZE];
/* Sanity check */
extent_idx = (struct ext4_extent_idx *)(ext_hdr + 1);
for (i = 0; i < ext_hdr->eh_entries; i++) {
- fs_block_num = ((off64_t)extent_idx->ei_leaf_hi << 32) | extent_idx->ei_leaf_lo;
+ fs_block_num = ((off_t)extent_idx->ei_leaf_hi << 32) | extent_idx->ei_leaf_lo;
read_block(fd, fs_block_num, block);
tmp_ext_hdr = (struct ext4_extent_header *)block;
static void extent_create_backing_file(struct block_allocation *alloc,
u64 backing_len, const char *filename)
{
- off64_t offset = 0;
+ off_t offset = 0;
for (; alloc != NULL && backing_len > 0; get_next_region(alloc)) {
u32 region_block;
u32 region_len;
#include "sparse_crc32.h"
#include "sparse_format.h"
-#if defined(__APPLE__) && defined(__MACH__)
-#define lseek64 lseek
-#define ftruncate64 ftruncate
-#define mmap64 mmap
-#define off64_t off_t
-#endif
-
#define min(a, b) \
({ typeof(a) _a = (a); typeof(b) _b = (b); (_a < _b) ? _a : _b; })
static int file_skip(struct output_file *out, int64_t cnt)
{
- off64_t ret;
+ off_t ret;
struct output_file_normal *outn = to_output_file_normal(out);
- ret = lseek64(outn->fd, cnt, SEEK_CUR);
+ ret = lseek(outn->fd, cnt, SEEK_CUR);
if (ret < 0) {
- error_errno("lseek64");
+ error_errno("lseek");
return -1;
}
return 0;
int ret;
struct output_file_normal *outn = to_output_file_normal(out);
- ret = ftruncate64(outn->fd, len);
+ ret = ftruncate(outn->fd, len);
if (ret < 0) {
return -errno;
}
static int gz_file_skip(struct output_file *out, int64_t cnt)
{
- off64_t ret;
+ off_t ret;
struct output_file_gz *outgz = to_output_file_gz(out);
ret = gzseek(outgz->gz_fd, cnt, SEEK_CUR);
static int gz_file_pad(struct output_file *out, int64_t len)
{
- off64_t ret;
+ off_t ret;
struct output_file_gz *outgz = to_output_file_gz(out);
ret = gztell(outgz->gz_fd);
aligned_diff = offset - aligned_offset;
buffer_size = len + aligned_diff;
- char *data = mmap64(NULL, buffer_size, PROT_READ, MAP_SHARED, fd,
+ char *data = mmap(NULL, buffer_size, PROT_READ, MAP_SHARED, fd,
aligned_offset);
if (data == MAP_FAILED) {
return -errno;
#include "sparse_file.h"
#include "sparse_format.h"
-#if defined(__APPLE__) && defined(__MACH__)
-#define lseek64 lseek
-#define off64_t off_t
-#endif
-
#define SPARSE_HEADER_MAJOR_VER 1
#define SPARSE_HEADER_LEN (sizeof(sparse_header_t))
#define CHUNK_HEADER_LEN (sizeof(chunk_header_t))
len -= chunk;
}
} else {
- lseek64(fd, len, SEEK_CUR);
+ lseek(fd, len, SEEK_CUR);
}
return 0;
return 0;
}
-static int process_chunk(struct sparse_file *s, int fd, off64_t offset,
+static int process_chunk(struct sparse_file *s, int fd, off_t offset,
unsigned int chunk_hdr_sz, chunk_header_t *chunk_header,
unsigned int cur_block, uint32_t *crc_ptr)
{
uint32_t crc32 = 0;
uint32_t *crc_ptr = 0;
unsigned int cur_block = 0;
- off64_t offset;
+ off_t offset;
if (!copybuf) {
copybuf = malloc(COPY_BUF_SIZE);
/* Skip the remaining bytes in a header that is longer than
* we expected.
*/
- lseek64(fd, sparse_header.file_hdr_sz - SPARSE_HEADER_LEN, SEEK_CUR);
+ lseek(fd, sparse_header.file_hdr_sz - SPARSE_HEADER_LEN, SEEK_CUR);
}
for (i = 0; i < sparse_header.total_chunks; i++) {
/* Skip the remaining bytes in a header that is longer than
* we expected.
*/
- lseek64(fd, sparse_header.chunk_hdr_sz - CHUNK_HEADER_LEN, SEEK_CUR);
+ lseek(fd, sparse_header.chunk_hdr_sz - CHUNK_HEADER_LEN, SEEK_CUR);
}
- offset = lseek64(fd, 0, SEEK_CUR);
+ offset = lseek(fd, 0, SEEK_CUR);
ret = process_chunk(s, fd, offset, sparse_header.chunk_hdr_sz, &chunk_header,
cur_block, crc_ptr);
return NULL;
}
- ret = lseek64(fd, 0, SEEK_SET);
+ ret = lseek(fd, 0, SEEK_SET);
if (ret < 0) {
verbose_error(verbose, ret, "seeking");
sparse_file_destroy(s);
return s;
}
- len = lseek64(fd, 0, SEEK_END);
+ len = lseek(fd, 0, SEEK_END);
if (len < 0) {
return NULL;
}
- lseek64(fd, 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
s = sparse_file_new(4096, len);
if (!s) {