Probably broke the wii/cube support, but wii u should work now!

This commit is contained in:
Maschell 2017-09-09 16:04:54 +02:00
parent 844e936067
commit bb10015e70
23 changed files with 616 additions and 500 deletions

View File

@ -27,18 +27,18 @@
extern "C" { extern "C" {
#endif #endif
#if defined(__gamecube__) || defined (__wii__) /*#if defined(__gamecube__) || defined (__wii__)
#include <gctypes.h> #include <gctypes.h>
#include <ogc/disc_io.h> #include <ogc/disc_io.h>
#include <gccore.h> #include <gccore.h>
#elif defined (__wiiu__) #elif defined (__wiiu__)*/
#include <iosuhax_disc_interface.h> #include <iosuhax_disc_interface.h>
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16; typedef uint16_t u16;
typedef int32_t s32; typedef int32_t s32;
typedef uint32_t u32; typedef uint32_t u32;
typedef int mutex_t; typedef int mutex_t;
#endif /*#endif*/
/* NTFS errno values */ /* NTFS errno values */
#define ENOPART 3000 /* No partition was found */ #define ENOPART 3000 /* No partition was found */

View File

@ -8,7 +8,7 @@ $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>dev
endif endif
ifeq ($(PLATFORM),wiiu) ifeq ($(PLATFORM),wiiu)
include $(DEVKITPPC)/wii_rules include $(DEVKITPPC)/wiiu_rules
endif endif
ifeq ($(PLATFORM),wii) ifeq ($(PLATFORM),wii)
@ -32,7 +32,7 @@ LIBDIR := ../lib
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
CFLAGS = -Os -Wall -ffast-math -pipe $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H CFLAGS = -Wall -ffast-math -pipe $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
ASFLAGS := -g ASFLAGS := -g
export NTFSBIN := $(LIBDIR)/$(PLATFORM)/libntfs.a export NTFSBIN := $(LIBDIR)/$(PLATFORM)/libntfs.a
@ -87,11 +87,9 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \ -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include
-I$(LIBOGC_INC)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib
-L$(LIBOGC_LIB)
.PHONY: $(BUILD) clean .PHONY: $(BUILD) clean

View File

@ -92,7 +92,7 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
i = (u32)le16_to_cpu(b->bpb.bytes_per_sector) * i = (u32)le16_to_cpu(b->bpb.bytes_per_sector) *
b->bpb.sectors_per_cluster; b->bpb.sectors_per_cluster;
if (i > 65536) { if (i > 65536) {
ntfs_log_error("Unexpected cluster size (%d).\n", i); ntfs_log_error("Unexpected cluster size (%d).\n", (int)i);
goto not_ntfs; goto not_ntfs;
} }
@ -109,7 +109,7 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
le16_to_cpu(b->bpb.root_entries), le16_to_cpu(b->bpb.root_entries),
le16_to_cpu(b->bpb.sectors), le16_to_cpu(b->bpb.sectors),
le16_to_cpu(b->bpb.sectors_per_fat), le16_to_cpu(b->bpb.sectors_per_fat),
le32_to_cpu(b->bpb.large_sectors), (int)le32_to_cpu(b->bpb.large_sectors),
b->bpb.fats); b->bpb.fats);
goto not_ntfs; goto not_ntfs;
} }
@ -227,7 +227,7 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
vol->cluster_size = sectors_per_cluster * vol->sector_size; vol->cluster_size = sectors_per_cluster * vol->sector_size;
if (vol->cluster_size & (vol->cluster_size - 1)) { if (vol->cluster_size & (vol->cluster_size - 1)) {
ntfs_log_error("cluster_size (%d) is not a power of 2.\n", ntfs_log_error("cluster_size (%d) is not a power of 2.\n",
vol->cluster_size); (int)vol->cluster_size);
return -1; return -1;
} }
vol->cluster_size_bits = ffs(vol->cluster_size) - 1; vol->cluster_size_bits = ffs(vol->cluster_size) - 1;
@ -252,7 +252,7 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
vol->mft_record_size = c << vol->cluster_size_bits; vol->mft_record_size = c << vol->cluster_size_bits;
if (vol->mft_record_size & (vol->mft_record_size - 1)) { if (vol->mft_record_size & (vol->mft_record_size - 1)) {
ntfs_log_error("mft_record_size (%d) is not a power of 2.\n", ntfs_log_error("mft_record_size (%d) is not a power of 2.\n",
vol->mft_record_size); (int)vol->mft_record_size);
return -1; return -1;
} }
vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1; vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1;

View File

@ -35,7 +35,11 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <ogc/lwp_watchdog.h> #if defined (__wiiu__)
#elif defined(__gamecube__) || defined (__wii__)
#include <ogc/lwp_watchdog.h>
#endif
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>

View File

@ -49,6 +49,7 @@
typedef uint16_t u16; typedef uint16_t u16;
typedef int32_t s32; typedef int32_t s32;
typedef uint32_t u32; typedef uint32_t u32;
typedef uint64_t u64;
typedef int mutex_t; typedef int mutex_t;
#elif defined(__gamecube__) || defined (__wii__) #elif defined(__gamecube__) || defined (__wii__)
#include <gctypes.h> #include <gctypes.h>

View File

@ -69,7 +69,7 @@ extern char *strsep(char **stringp, const char *delim);
#define O_BINARY 0 /* unix is binary by default */ #define O_BINARY 0 /* unix is binary by default */
#endif #endif
#ifdef GEKKO #if defined(GEKKO) || defined (__wiiu__)
#include "mem_allocate.h" #include "mem_allocate.h"

View File

@ -27,7 +27,7 @@
#ifndef __CYGWIN32__ #ifndef __CYGWIN32__
/* Not on Cygwin; use standard Unix style low level device operations. */ /* Not on Cygwin; use standard Unix style low level device operations. */
#include "unix_io.c" //#include "unix_io.c"
#else /* __CYGWIN32__ */ #else /* __CYGWIN32__ */

View File

@ -66,6 +66,11 @@
#include <sys/xattr.h> #include <sys/xattr.h>
#endif #endif
#if defined(__wiiu__)
#define major(dev) ((int)(((unsigned int) (dev) >> 8) & 0xff))
#define minor(dev) ((int)((dev) & 0xff))
#endif // defined
/* /*
* The little endian Unicode strings "$I30", "$SII", "$SDH", "$O" * The little endian Unicode strings "$I30", "$SII", "$SDH", "$O"
* and "$Q" as global constants. * and "$Q" as global constants.

View File

@ -54,6 +54,8 @@
#include <locale.h> #include <locale.h>
#endif #endif
typedef double f64;
#include "ntfs.h" #include "ntfs.h"
#include "types.h" #include "types.h"
#include "logging.h" #include "logging.h"
@ -62,6 +64,7 @@
#include "cache.h" #include "cache.h"
#include "device.h" #include "device.h"
#include "bootsect.h" #include "bootsect.h"
#include "mem_allocate.h"
#define DEV_FD(dev) ((gekko_fd *)dev->d_private) #define DEV_FD(dev) ((gekko_fd *)dev->d_private)
@ -119,7 +122,7 @@ static int ntfs_device_gekko_io_open(struct ntfs_device *dev, int flags)
} }
if (!interface->readSectors(fd->startSector, 1, boot)) { if (!interface->readSectors(fd->startSector, 1, boot)) {
ntfs_log_perror("read failure @ sector %d\n", fd->startSector); ntfs_log_perror("read failure @ sector %d\n", (int)fd->startSector);
errno = EIO; errno = EIO;
ntfs_free(boot); ntfs_free(boot);
return -1; return -1;
@ -318,7 +321,7 @@ static s64 ntfs_device_gekko_io_readbytes(struct ntfs_device *dev, s64 offset, s
// Read from the device // Read from the device
ntfs_log_trace("direct read from sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_trace("direct read from sector %d (%d sector(s) long)\n", sec_start, sec_count);
if (!ntfs_device_gekko_io_readsectors(dev, sec_start, sec_count, buf)) { if (!ntfs_device_gekko_io_readsectors(dev, sec_start, sec_count, buf)) {
ntfs_log_perror("direct read failure @ sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_perror("direct read failure @ sector %d (%d sector(s) long)\n", (int)sec_start, (int)sec_count);
errno = EIO; errno = EIO;
return -1; return -1;
} }
@ -336,10 +339,10 @@ static s64 ntfs_device_gekko_io_readbytes(struct ntfs_device *dev, s64 offset, s
} }
// Read from the device // Read from the device
ntfs_log_trace("buffered read from sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_trace("buffered read from sector %d (%d sector(s) long)\n", (int)sec_start, (int)sec_count);
ntfs_log_trace("count: %d sec_count:%d fd->sectorSize: %d )\n", (u32)count, (u32)sec_count,(u32)fd->sectorSize); ntfs_log_trace("count: %d sec_count:%d fd->sectorSize: %d )\n", (u32)count, (u32)sec_count,(u32)fd->sectorSize);
if (!ntfs_device_gekko_io_readsectors(dev, sec_start, sec_count, buffer)) { if (!ntfs_device_gekko_io_readsectors(dev, sec_start, sec_count, buffer)) {
ntfs_log_perror("buffered read failure @ sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_perror("buffered read failure @ sector %d (%d sector(s) long)\n", (int)sec_start, (int)sec_count);
ntfs_free(buffer); ntfs_free(buffer);
errno = EIO; errno = EIO;
return -1; return -1;
@ -406,9 +409,9 @@ static s64 ntfs_device_gekko_io_writebytes(struct ntfs_device *dev, s64 offset,
if((buffer_offset == 0) && (count % fd->sectorSize == 0)) if((buffer_offset == 0) && (count % fd->sectorSize == 0))
{ {
// Write to the device // Write to the device
ntfs_log_trace("direct write to sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_trace("direct write to sector %d (%d sector(s) long)\n", (int)sec_start, (int)sec_count);
if (!ntfs_device_gekko_io_writesectors(dev, sec_start, sec_count, buf)) { if (!ntfs_device_gekko_io_writesectors(dev, sec_start, sec_count, buf)) {
ntfs_log_perror("direct write failure @ sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_perror("direct write failure @ sector %d (%d sector(s) long)\n", (int)sec_start, (int)sec_count);
errno = EIO; errno = EIO;
return -1; return -1;
} }
@ -428,7 +431,7 @@ static s64 ntfs_device_gekko_io_writebytes(struct ntfs_device *dev, s64 offset,
if(buffer_offset != 0) if(buffer_offset != 0)
{ {
if (!ntfs_device_gekko_io_readsectors(dev, sec_start, 1, buffer)) { if (!ntfs_device_gekko_io_readsectors(dev, sec_start, 1, buffer)) {
ntfs_log_perror("read failure @ sector %d\n", sec_start); ntfs_log_perror("read failure @ sector %d\n", (int)sec_start);
ntfs_free(buffer); ntfs_free(buffer);
errno = EIO; errno = EIO;
return -1; return -1;
@ -437,7 +440,7 @@ static s64 ntfs_device_gekko_io_writebytes(struct ntfs_device *dev, s64 offset,
if((buffer_offset+count) % fd->sectorSize != 0) if((buffer_offset+count) % fd->sectorSize != 0)
{ {
if (!ntfs_device_gekko_io_readsectors(dev, sec_start + sec_count - 1, 1, buffer + ((sec_count-1) * fd->sectorSize))) { if (!ntfs_device_gekko_io_readsectors(dev, sec_start + sec_count - 1, 1, buffer + ((sec_count-1) * fd->sectorSize))) {
ntfs_log_perror("read failure @ sector %d\n", sec_start + sec_count - 1); ntfs_log_perror("read failure @ sector %d\n", (int)sec_start + (int)sec_count - 1);
ntfs_free(buffer); ntfs_free(buffer);
errno = EIO; errno = EIO;
return -1; return -1;
@ -450,7 +453,7 @@ static s64 ntfs_device_gekko_io_writebytes(struct ntfs_device *dev, s64 offset,
// Write to the device // Write to the device
ntfs_log_trace("buffered write to sector %d (%d sector(s) long)\n", sec_start, sec_count); ntfs_log_trace("buffered write to sector %d (%d sector(s) long)\n", sec_start, sec_count);
if (!ntfs_device_gekko_io_writesectors(dev, sec_start, sec_count, buffer)) { if (!ntfs_device_gekko_io_writesectors(dev, sec_start, sec_count, buffer)) {
ntfs_log_perror("buffered write failure @ sector %d\n", sec_start); ntfs_log_perror("buffered write failure @ sector %d\n", (int)sec_start);
ntfs_free(buffer); ntfs_free(buffer);
errno = EIO; errno = EIO;
return -1; return -1;

View File

@ -59,6 +59,7 @@ typedef struct _gekko_fd {
u32 cachePageSize; /* The number of sectors per cache page */ u32 cachePageSize; /* The number of sectors per cache page */
} gekko_fd; } gekko_fd;
/* Forward declarations */ /* Forward declarations */
struct ntfs_device_operations; struct ntfs_device_operations;

View File

@ -417,8 +417,8 @@ static int ntfs_ia_check(ntfs_index_context *icx, INDEX_BLOCK *ib, VCN vcn)
ntfs_log_error("Corrupt index block : VCN (%lld) of inode %llu " ntfs_log_error("Corrupt index block : VCN (%lld) of inode %llu "
"has a size (%u) differing from the index " "has a size (%u) differing from the index "
"specified size (%u)\n", (long long)vcn, "specified size (%u)\n", (long long)vcn,
(unsigned long long)icx->ni->mft_no, ib_size, (unsigned long long)icx->ni->mft_no, (unsigned int) ib_size,
icx->block_size); (unsigned int) icx->block_size);
return -1; return -1;
} }
return 0; return 0;
@ -694,7 +694,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ntfs_index_context *ic
if (icx->block_size < NTFS_BLOCK_SIZE) { if (icx->block_size < NTFS_BLOCK_SIZE) {
errno = EINVAL; errno = EINVAL;
ntfs_log_perror("Index block size (%d) is smaller than the " ntfs_log_perror("Index block size (%d) is smaller than the "
"sector size (%d)", icx->block_size, NTFS_BLOCK_SIZE); "sector size (%d)", (int) icx->block_size, NTFS_BLOCK_SIZE);
goto err_out; goto err_out;
} }

View File

@ -243,7 +243,7 @@ static ntfs_inode *ntfs_inode_real_open(ntfs_volume *vol, const MFT_REF mref)
if (l != ni->attr_list_size) { if (l != ni->attr_list_size) {
errno = EIO; errno = EIO;
ntfs_log_perror("Unexpected attrlist size (%lld <> %u), inode " ntfs_log_perror("Unexpected attrlist size (%lld <> %u), inode "
"%lld", (long long)l, ni->attr_list_size, "%lld", (long long)l, (unsigned int) ni->attr_list_size,
(long long)MREF(mref)); (long long)MREF(mref));
goto put_err_out; goto put_err_out;
} }

28
source/lock.c Normal file
View File

@ -0,0 +1,28 @@
#ifndef USE_LWP_LOCK
#ifndef mutex_t
typedef int mutex_t;
#endif
void __attribute__ ((weak)) _NTFS_lock_init(mutex_t *mutex, int unkwn)
{
return;
}
void __attribute__ ((weak)) _NTFS_lock_deinit(mutex_t *mutex)
{
return;
}
void __attribute__ ((weak)) _NTFS_lock(mutex_t *mutex)
{
return;
}
void __attribute__ ((weak)) _NTFS_unlock(mutex_t *mutex)
{
return;
}
#endif // USE_LWP_LOCK

71
source/lock.h Normal file
View File

@ -0,0 +1,71 @@
/*
lock.h
Copyright (c) 2008 Sven Peter <svpe@gmx.net>
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.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE.
*/
#ifndef _LOCK_H
#define _LOCK_H
#ifdef USE_LWP_LOCK
static inline void _NTFS_lock_init(mutex_t *mutex, int unkwn)
{
LWP_MutexInit(mutex, false);
}
static inline void _NTFS_lock_deinit(mutex_t *mutex)
{
LWP_MutexDestroy(*mutex);
}
static inline void _NTFS_lock(mutex_t *mutex)
{
LWP_MutexLock(*mutex);
}
static inline void _NTFS_unlock(mutex_t *mutex)
{
LWP_MutexUnlock(*mutex);
}
#else
// We still need a blank lock type
#ifndef mutex_t
typedef int mutex_t;
#endif
void _NTFS_lock_init(mutex_t *mutex,int unkwn);
void _NTFS_lock_deinit(mutex_t *mutex);
void _NTFS_lock(mutex_t *mutex);
void _NTFS_unlock(mutex_t *mutex);
#endif // USE_LWP_LOCK
#endif // _LOCK_H

View File

@ -226,8 +226,8 @@ int ntfs_mft_record_check(const ntfs_volume *vol, const MFT_REF mref,
if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) { if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) {
ntfs_log_error("Record %llu has corrupt allocation size " ntfs_log_error("Record %llu has corrupt allocation size "
"(%u <> %u)\n", (unsigned long long)MREF(mref), "(%u <> %u)\n", (unsigned long long)MREF(mref),
vol->mft_record_size, (unsigned int) vol->mft_record_size,
le32_to_cpu(m->bytes_allocated)); (unsigned int) le32_to_cpu(m->bytes_allocated));
goto err_out; goto err_out;
} }

View File

@ -101,7 +101,7 @@ int ntfs_mst_post_read_fixup_warn(NTFS_RECORD *b, const u32 size,
errno = EIO; errno = EIO;
ntfs_log_perror("Incomplete multi-sector transfer: " ntfs_log_perror("Incomplete multi-sector transfer: "
"magic: 0x%08x size: %d usa_ofs: %d usa_count:" "magic: 0x%08x size: %d usa_ofs: %d usa_count:"
" %d data: %d usn: %d", *(le32 *)b, size, " %d data: %d usn: %d", (unsigned int)*(le32 *)b, (int)size,
usa_ofs, usa_count, *data_pos, usn); usa_ofs, usa_count, *data_pos, usn);
b->magic = magic_BAAD; b->magic = magic_BAAD;
return -1; return -1;

View File

@ -37,9 +37,12 @@
#include "ntfsinternal.h" #include "ntfsinternal.h"
#include "ntfsfile.h" #include "ntfsfile.h"
#include "ntfsdir.h" #include "ntfsdir.h"
#include "gekko_io.h" #include "gekko_io.h"
#include "cache.h" #include "cache.h"
// NTFS device driver devoptab // NTFS device driver devoptab
static const devoptab_t devops_ntfs = { static const devoptab_t devops_ntfs = {
NULL, /* Device name */ NULL, /* Device name */
@ -197,7 +200,7 @@ int ntfsFindPartitions (const DISC_INTERFACE *interface, sec_t **partitions)
if (sector.boot.oem_id == NTFS_OEM_ID) { if (sector.boot.oem_id == NTFS_OEM_ID) {
ntfs_log_debug("Logical Partition @ %d: Valid NTFS boot sector found\n", part_lba); ntfs_log_debug("Logical Partition @ %d: Valid NTFS boot sector found\n", part_lba);
if(sector.ebr.partition.type != PARTITION_TYPE_NTFS) { if(sector.ebr.partition.type != PARTITION_TYPE_NTFS) {
ntfs_log_warning("Logical Partition @ %d: Is NTFS but type is 0x%x; 0x%x was expected\n", part_lba, sector.ebr.partition.type, PARTITION_TYPE_NTFS); ntfs_log_warning("Logical Partition @ %d: Is NTFS but type is 0x%x; 0x%x was expected\n", (int) part_lba, sector.ebr.partition.type, PARTITION_TYPE_NTFS);
} }
if (partition_count < NTFS_MAX_PARTITIONS) { if (partition_count < NTFS_MAX_PARTITIONS) {
partition_starts[partition_count] = part_lba; partition_starts[partition_count] = part_lba;

View File

@ -220,7 +220,7 @@ int ntfs_open_r (struct _reent *r, void *fileStruct, const char *path, int flags
return (int)fileStruct; return (int)fileStruct;
} }
int ntfs_close_r (struct _reent *r, int fd) int ntfs_close_r (struct _reent *r, void * fd)
{ {
ntfs_log_trace("fd %p\n", (void *) fd); ntfs_log_trace("fd %p\n", (void *) fd);
@ -253,7 +253,7 @@ int ntfs_close_r (struct _reent *r, int fd)
return 0; return 0;
} }
ssize_t ntfs_write_r (struct _reent *r, int fd, const char *ptr, size_t len) ssize_t ntfs_write_r (struct _reent *r, void * fd, const char *ptr, size_t len)
{ {
ntfs_log_trace("fd %p, ptr %p, len %u\n", (void *) fd, ptr, len); ntfs_log_trace("fd %p, ptr %p, len %u\n", (void *) fd, ptr, len);
@ -319,7 +319,7 @@ ssize_t ntfs_write_r (struct _reent *r, int fd, const char *ptr, size_t len)
return written; return written;
} }
ssize_t ntfs_read_r (struct _reent *r, int fd, char *ptr, size_t len) ssize_t ntfs_read_r (struct _reent *r, void * fd, char *ptr, size_t len)
{ {
ntfs_log_trace("fd %p, ptr %p, len %u\n", (void *) fd, ptr, len); ntfs_log_trace("fd %p, ptr %p, len %u\n", (void *) fd, ptr, len);
@ -378,7 +378,7 @@ ssize_t ntfs_read_r (struct _reent *r, int fd, char *ptr, size_t len)
return read; return read;
} }
off_t ntfs_seek_r (struct _reent *r, int fd, off_t pos, int dir) off_t ntfs_seek_r (struct _reent *r, void * fd, off_t pos, int dir)
{ {
ntfs_log_trace("fd %p, pos %llu, dir %i\n", (void *) fd, pos, dir); ntfs_log_trace("fd %p, pos %llu, dir %i\n", (void *) fd, pos, dir);
@ -406,7 +406,7 @@ off_t ntfs_seek_r (struct _reent *r, int fd, off_t pos, int dir)
return position; return position;
} }
int ntfs_fstat_r (struct _reent *r, int fd, struct stat *st) int ntfs_fstat_r (struct _reent *r, void * fd, struct stat *st)
{ {
ntfs_log_trace("fd %p\n", (void *) fd); ntfs_log_trace("fd %p\n", (void *) fd);
@ -431,7 +431,7 @@ int ntfs_fstat_r (struct _reent *r, int fd, struct stat *st)
return ret; return ret;
} }
int ntfs_ftruncate_r (struct _reent *r, int fd, off_t len) int ntfs_ftruncate_r (struct _reent *r, void * fd, off_t len)
{ {
ntfs_log_trace("fd %p, len %llu\n", (void *) fd, (u64) len); ntfs_log_trace("fd %p, len %llu\n", (void *) fd, (u64) len);
@ -498,7 +498,7 @@ int ntfs_ftruncate_r (struct _reent *r, int fd, off_t len)
return 0; return 0;
} }
int ntfs_fsync_r (struct _reent *r, int fd) int ntfs_fsync_r (struct _reent *r, void * fd)
{ {
ntfs_log_trace("fd %p\n", (void *) fd); ntfs_log_trace("fd %p\n", (void *) fd);

View File

@ -53,13 +53,13 @@ void ntfsCloseFile (ntfs_file_state *file);
/* Gekko devoptab file routines for NTFS-based devices */ /* Gekko devoptab file routines for NTFS-based devices */
extern int ntfs_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode); extern int ntfs_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
extern int ntfs_close_r (struct _reent *r, int fd); extern int ntfs_close_r (struct _reent *r, void *fd);
extern ssize_t ntfs_write_r (struct _reent *r, int fd, const char *ptr, size_t len); extern ssize_t ntfs_write_r (struct _reent *r, void * fd, const char *ptr, size_t len);
extern ssize_t ntfs_read_r (struct _reent *r, int fd, char *ptr, size_t len); extern ssize_t ntfs_read_r (struct _reent *r, void * fd, char *ptr, size_t len);
extern off_t ntfs_seek_r (struct _reent *r, int fd, off_t pos, int dir); extern off_t ntfs_seek_r (struct _reent *r, void * fd, off_t pos, int dir);
extern int ntfs_fstat_r (struct _reent *r, int fd, struct stat *st); extern int ntfs_fstat_r (struct _reent *r, void * fd, struct stat *st);
extern int ntfs_ftruncate_r (struct _reent *r, int fd, off_t len); extern int ntfs_ftruncate_r (struct _reent *r, void * fd, off_t len);
extern int ntfs_fsync_r (struct _reent *r, int fd); extern int ntfs_fsync_r (struct _reent *r, void * fd);
#endif /* _NTFSFILE_H */ #endif /* _NTFSFILE_H */

View File

@ -37,6 +37,7 @@
#include "ntfsinternal.h" #include "ntfsinternal.h"
#include "ntfsdir.h" #include "ntfsdir.h"
#include "ntfsfile.h" #include "ntfsfile.h"
#include "lock.h"
#if defined(__wii__) #if defined(__wii__)
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
@ -52,11 +53,11 @@ const INTERFACE_ID ntfs_disc_interfaces[] = {
}; };
#elif defined (__wiiu__) #elif defined (__wiiu__)
#include <iosuhax_disc_interface.h> #include <iosuhax_disc_interface.h>
const INTERFACE_ID ntfs_disc_interfaces[] = { const INTERFACE_ID ntfs_disc_interfaces[] = {
{"sd", get_io_wiiu_sd}, {"sd", &IOSUHAX_sdio_disc_interface},
{"usb", get_io_wiiu_usb}, {"usb", &IOSUHAX_usb_disc_interface},
{NULL, NULL} {NULL, NULL}
}; };
@ -199,7 +200,7 @@ int ntfsInitVolume (ntfs_vd *vd)
} }
// Initialise the volume lock // Initialise the volume lock
LWP_MutexInit(&vd->lock, false); _NTFS_lock_init(&vd->lock, false);
// Reset the volumes name cache // Reset the volumes name cache
vd->name[0] = '\0'; vd->name[0] = '\0';
@ -262,7 +263,7 @@ void ntfsDeinitVolume (ntfs_vd *vd)
ntfsUnlock(vd); ntfsUnlock(vd);
// Deinitialise the volume lock // Deinitialise the volume lock
LWP_MutexDestroy(vd->lock); _NTFS_lock_deinit((mutex_t *)vd->lock);
return; return;
} }

View File

@ -38,6 +38,7 @@
#include "reparse.h" #include "reparse.h"
#include "security.h" #include "security.h"
#include "efs.h" #include "efs.h"
#include "lock.h"
#include "unistr.h" #include "unistr.h"
#if defined (__wiiu__) #if defined (__wiiu__)
@ -151,13 +152,13 @@ typedef struct _ntfs_vd {
/* Lock volume */ /* Lock volume */
static inline void ntfsLock (ntfs_vd *vd) static inline void ntfsLock (ntfs_vd *vd)
{ {
LWP_MutexLock(vd->lock); _NTFS_lock((mutex_t *)vd->lock);
} }
/* Unlock volume */ /* Unlock volume */
static inline void ntfsUnlock (ntfs_vd *vd) static inline void ntfsUnlock (ntfs_vd *vd)
{ {
LWP_MutexUnlock(vd->lock); _NTFS_unlock((mutex_t *)vd->lock);
} }
/* Gekko device related routines */ /* Gekko device related routines */

View File

@ -40,7 +40,7 @@
/* /*
* assume "struct timespec" is not defined if st_mtime is not defined * assume "struct timespec" is not defined if st_mtime is not defined
*/ */
#if !defined(st_mtime) & !defined(__timespec_defined) #if !defined(st_mtime) & !defined(__timespec_defined) & !defined(__wiiu__)
struct timespec { struct timespec {
time_t tv_sec; time_t tv_sec;
long tv_nsec; long tv_nsec;

View File

@ -297,7 +297,7 @@ static int ntfs_mft_load(ntfs_volume *vol)
if (l != vol->mft_ni->attr_list_size) { if (l != vol->mft_ni->attr_list_size) {
ntfs_log_error("Partial read of $MFT/$ATTR_LIST (%lld != " ntfs_log_error("Partial read of $MFT/$ATTR_LIST (%lld != "
"%u).\n", (long long)l, "%u).\n", (long long)l,
vol->mft_ni->attr_list_size); (unsigned int) vol->mft_ni->attr_list_size);
goto io_error_exit; goto io_error_exit;
} }