Remove MinGW support code

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2015-04-08 06:45:09 +02:00
parent 5e571bcba6
commit d8400e132c
9 changed files with 3 additions and 69 deletions

View File

@ -30,10 +30,6 @@
#include "extent.h" #include "extent.h"
#include "indirect.h" #include "indirect.h"
#ifdef USE_MINGW
#define S_IFLNK 0 /* used by make_link, not needed under mingw */
#endif
static struct block_allocation* saved_allocation_head = NULL; static struct block_allocation* saved_allocation_head = NULL;
struct block_allocation* get_saved_allocation_chain() { struct block_allocation* get_saved_allocation_chain() {

View File

@ -29,12 +29,8 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#ifdef USE_MINGW
#include <winsock2.h>
#else
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif
#if defined(__linux__) #if defined(__linux__)
#include <linux/fs.h> #include <linux/fs.h>
@ -443,16 +439,12 @@ u64 get_block_device_size(int fd)
int is_block_device_fd(int fd) int is_block_device_fd(int fd)
{ {
#ifdef USE_MINGW
return 0;
#else
struct stat st; struct stat st;
int ret = fstat(fd, &st); int ret = fstat(fd, &st);
if (ret < 0) if (ret < 0)
return 0; return 0;
return S_ISBLK(st.st_mode); return S_ISBLK(st.st_mode);
#endif
} }
u64 get_file_size(int fd) u64 get_file_size(int fd)

View File

@ -24,13 +24,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#ifndef USE_MINGW
#include <sys/mman.h>
#endif
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#define lseek64 lseek #define lseek64 lseek
#define off64_t off_t #define off64_t off_t

View File

@ -699,39 +699,16 @@ int write_fd_chunk(struct output_file *out, unsigned int len,
aligned_diff = offset - aligned_offset; aligned_diff = offset - aligned_offset;
buffer_size = len + aligned_diff; buffer_size = len + aligned_diff;
#ifndef USE_MINGW
char *data = mmap64(NULL, buffer_size, PROT_READ, MAP_SHARED, fd, char *data = mmap64(NULL, buffer_size, PROT_READ, MAP_SHARED, fd,
aligned_offset); aligned_offset);
if (data == MAP_FAILED) { if (data == MAP_FAILED) {
return -errno; return -errno;
} }
ptr = data + aligned_diff; ptr = data + aligned_diff;
#else
off64_t pos;
char *data = malloc(len);
if (!data) {
return -errno;
}
pos = lseek64(fd, offset, SEEK_SET);
if (pos < 0) {
free(data);
return -errno;
}
ret = read_all(fd, data, len);
if (ret < 0) {
free(data);
return ret;
}
ptr = data;
#endif
ret = out->sparse_ops->write_data_chunk(out, len, ptr); ret = out->sparse_ops->write_data_chunk(out, len, ptr);
#ifndef USE_MINGW
munmap(data, buffer_size); munmap(data, buffer_size);
#else
free(data);
#endif
return ret; return ret;
} }

View File

@ -78,12 +78,9 @@ static void verbose_error(bool verbose, int err, const char *fmt, ...)
s = " at "; s = " at ";
} }
if (verbose) { if (verbose) {
#ifndef USE_MINGW
if (err == -EOVERFLOW) { if (err == -EOVERFLOW) {
sparse_print_verbose("EOF while reading file%s%s\n", s, at); sparse_print_verbose("EOF while reading file%s%s\n", s, at);
} else } else if (err == -EINVAL) {
#endif
if (err == -EINVAL) {
sparse_print_verbose("Invalid sparse file format%s%s\n", s, at); sparse_print_verbose("Invalid sparse file format%s%s\n", s, at);
} else if (err == -ENOMEM) { } else if (err == -ENOMEM) {
sparse_print_verbose("Failed allocation while reading file%s%s\n", sparse_print_verbose("Failed allocation while reading file%s%s\n",

View File

@ -66,7 +66,6 @@ static u32 build_default_directory_structure(const char *dir_path)
return root_inode; return root_inode;
} }
#ifndef USE_MINGW
/* Read a local directory and create the same tree in the generated filesystem. /* Read a local directory and create the same tree in the generated filesystem.
Calls itself recursively with each directory in the given directory. Calls itself recursively with each directory in the given directory.
full_path is an absolute or relative path, with a trailing slash, to the full_path is an absolute or relative path, with a trailing slash, to the
@ -255,7 +254,6 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
free(dentries); free(dentries);
return inode; return inode;
} }
#endif
static u32 compute_block_size() static u32 compute_block_size()
{ {
@ -522,17 +520,11 @@ int make_ext4fs_internal(int fd, const char *_directory,
if (info.feat_compat & EXT4_FEATURE_COMPAT_RESIZE_INODE) if (info.feat_compat & EXT4_FEATURE_COMPAT_RESIZE_INODE)
ext4_create_resize_inode(); ext4_create_resize_inode();
#ifdef USE_MINGW
// Windows needs only 'create an empty fs image' functionality
assert(!directory);
root_inode_num = build_default_directory_structure(mountpoint);
#else
if (directory) if (directory)
root_inode_num = build_directory_structure(directory, mountpoint, 0, root_inode_num = build_directory_structure(directory, mountpoint, 0,
fs_config_func, verbose, fixed_time); fs_config_func, verbose, fixed_time);
else else
root_inode_num = build_default_directory_structure(mountpoint); root_inode_num = build_default_directory_structure(mountpoint);
#endif
root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
inode_set_permissions(root_inode_num, root_mode, 0, 0, 0); inode_set_permissions(root_inode_num, root_mode, 0, 0, 0);

2
sha1.c
View File

@ -17,9 +17,7 @@
#define SHA1HANDSOFF /* Copies data before messing with it. */ #define SHA1HANDSOFF /* Copies data before messing with it. */
#ifndef USE_MINGW
#include <sys/cdefs.h> #include <sys/cdefs.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>

13
sha1.h
View File

@ -10,19 +10,8 @@
#define _SYS_SHA1_H_ #define _SYS_SHA1_H_
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#ifdef USE_MINGW
typedef unsigned char u_char;
typedef unsigned int uint32_t;
typedef unsigned int u_int32_t;
typedef unsigned int u_int;
#define __BEGIN_DECLS
#define __END_DECLS
#else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#endif #include <stdint.h>
#define SHA1_DIGEST_LENGTH 20 #define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH 41 #define SHA1_DIGEST_STRING_LENGTH 41

4
uuid.c
View File

@ -16,11 +16,7 @@
#include <string.h> #include <string.h>
#ifdef USE_MINGW
#include <winsock2.h>
#else
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
#include "ext4_utils.h" #include "ext4_utils.h"
#include "sha1.h" #include "sha1.h"