diff --git a/gui.pnproj b/gui.pnproj
index 931f250b..11e2d938 100644
--- a/gui.pnproj
+++ b/gui.pnproj
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/source/libs/libntfs/device_io.h b/source/libs/libntfs/device_io.h
index 1a39e7df..fad4d85f 100644
--- a/source/libs/libntfs/device_io.h
+++ b/source/libs/libntfs/device_io.h
@@ -33,8 +33,8 @@
#ifndef GEKKO
/* Not on Cygwin; use standard Unix style low level device operations. */
#define ntfs_device_default_io_ops ntfs_device_unix_io_ops
-#else /* GEKKO */
-/* On Nintendo GameCube/Wii; use Gekko low level device operations. */
+#else
+/* Wii i/o device. */
#define ntfs_device_default_io_ops ntfs_device_gekko_io_ops
#endif
@@ -79,3 +79,4 @@ extern struct ntfs_device_operations ntfs_device_default_io_ops;
#endif /* NO_NTFS_DEVICE_DEFAULT_IO_OPS */
#endif /* defined _NTFS_DEVICE_IO_H */
+
diff --git a/source/libs/libntfs/ntfsfile.h b/source/libs/libntfs/ntfsfile.h
index 33e97887..8e5ffcc6 100644
--- a/source/libs/libntfs/ntfsfile.h
+++ b/source/libs/libntfs/ntfsfile.h
@@ -6,7 +6,7 @@
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
+ * by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
@@ -43,9 +43,7 @@ typedef struct _ntfs_file_state {
bool compressed; /* True if file data is compressed */
bool encrypted; /* True if file data is encryted */
off_t pos; /* Current position within the file (in bytes) */
- //size_t len; /* Total length of the file (in bytes) */
- //size_t is 32 bit, off_t is signed, so use u64 for len!
- u64 len;
+ u64 len; /* Total length of the file (in bytes) */
struct _ntfs_file_state *prevOpenFile; /* The previous entry in a double-linked FILO list of open files */
struct _ntfs_file_state *nextOpenFile; /* The next entry in a double-linked FILO list of open files */
} ntfs_file_state;
diff --git a/source/libs/libntfs/security.c b/source/libs/libntfs/security.c
index ecf3ca07..138764ba 100644
--- a/source/libs/libntfs/security.c
+++ b/source/libs/libntfs/security.c
@@ -2995,7 +2995,9 @@ int ntfs_set_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
count = 0;
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) != const_cpu_to_le16(0);
newpxdesc = (struct POSIX_SECURITY*)NULL;
- if (!deflt || isdir || !size) {
+ if ((!value
+ || (((const struct POSIX_ACL*)value)->version == POSIX_VERSION))
+ && (!deflt || isdir || (!size && !value))) {
cached = fetch_cache(scx, ni);
if (cached) {
uid = cached->uid;
diff --git a/source/libs/libntfs/security.h b/source/libs/libntfs/security.h
index 4f3b5c54..83d7c0e1 100644
--- a/source/libs/libntfs/security.h
+++ b/source/libs/libntfs/security.h
@@ -166,14 +166,14 @@ struct POSIX_ACE {
u16 tag;
u16 perms;
s32 id;
-} ;
+} __attribute__((__packed__));
struct POSIX_ACL {
u8 version;
u8 flags;
u16 filler;
struct POSIX_ACE ace[0];
-} ;
+} __attribute__((__packed__));
struct POSIX_SECURITY {
mode_t mode;
diff --git a/source/libs/libntfs/unistr.c b/source/libs/libntfs/unistr.c
index cc3a1b8d..eb72f0ff 100644
--- a/source/libs/libntfs/unistr.c
+++ b/source/libs/libntfs/unistr.c
@@ -830,12 +830,15 @@ int ntfs_ucstombs(const ntfschar *ins, const int ins_len, char **outs,
int outs_len)
{
char *mbs;
+ int mbs_len;
+#ifdef MB_CUR_MAX
wchar_t wc;
- int i, o, mbs_len;
+ int i, o;
int cnt = 0;
#ifdef HAVE_MBSINIT
mbstate_t mbstate;
#endif
+#endif /* MB_CUR_MAX */
if (!ins || !outs) {
errno = EINVAL;
@@ -849,6 +852,7 @@ int ntfs_ucstombs(const ntfschar *ins, const int ins_len, char **outs,
}
if (use_utf8)
return ntfs_utf16_to_utf8(ins, ins_len, outs, outs_len);
+#ifdef MB_CUR_MAX
if (!mbs) {
mbs_len = (ins_len + 1) * MB_CUR_MAX;
mbs = ntfs_malloc(mbs_len);
@@ -914,6 +918,9 @@ err_out:
free(mbs);
errno = eo;
}
+#else /* MB_CUR_MAX */
+ errno = EILSEQ;
+#endif /* MB_CUR_MAX */
return -1;
}
@@ -942,6 +949,7 @@ err_out:
*/
int ntfs_mbstoucs(const char *ins, ntfschar **outs)
{
+#ifdef MB_CUR_MAX
ntfschar *ucs;
const char *s;
wchar_t wc;
@@ -949,6 +957,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs)
#ifdef HAVE_MBSINIT
mbstate_t mbstate;
#endif
+#endif /* MB_CUR_MAX */
if (!ins || !outs) {
errno = EINVAL;
@@ -958,6 +967,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs)
if (use_utf8)
return ntfs_utf8_to_utf16(ins, outs);
+#ifdef MB_CUR_MAX
/* Determine the size of the multi-byte string in bytes. */
ins_size = strlen(ins);
/* Determine the length of the multi-byte string. */
@@ -1047,6 +1057,9 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs)
return o;
err_out:
free(ucs);
+#else /* MB_CUR_MAX */
+ errno = EILSEQ;
+#endif /* MB_CUR_MAX */
return -1;
}
diff --git a/source/main.cpp b/source/main.cpp
index edbe0dd5..6cf53549 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -103,12 +103,12 @@ int main(int argc, char *argv[])
// Loading now the cios setup in the settings
IosLoader::LoadAppCios();
- printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
// Remount devices after reloading IOS.
SDCard_Init();
USBDevice_Init_Loop();
}
+ printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
//if a ID was passed via args copy it and try to boot it after the partition is mounted
//its not really a headless mode. more like hairless.
diff --git a/source/menu/menu_disclist.cpp b/source/menu/menu_disclist.cpp
index fee839f4..3453401c 100644
--- a/source/menu/menu_disclist.cpp
+++ b/source/menu/menu_disclist.cpp
@@ -1510,7 +1510,7 @@ int MenuDiscList()
else if (Settings.gameDisplay == CAROUSEL_MODE) mainWindow->Append(gameCarousel);
mainWindow->Append(&w);
ResumeGui();
- if (settret == 1) //if deleted
+ if (settret == MENU_DISCLIST) //if deleted
{
menu = MENU_DISCLIST;
break;
diff --git a/source/settings/menus/FlyingButtonsMenu.cpp b/source/settings/menus/FlyingButtonsMenu.cpp
index 15bc8db1..136e719d 100644
--- a/source/settings/menus/FlyingButtonsMenu.cpp
+++ b/source/settings/menus/FlyingButtonsMenu.cpp
@@ -41,6 +41,7 @@ FlyingButtonsMenu::FlyingButtonsMenu(const char * menu_title)
{
currentPage = 0;
returnMenu = MENU_NONE;
+ ParentMenu = MENU_DISCLIST;
CurrentMenu = NULL;
titleTxt = NULL;
GoLeftImg = NULL;
@@ -390,7 +391,7 @@ int FlyingButtonsMenu::MainLoop()
}
else
{
- return MENU_DISCLIST;
+ return ParentMenu;
}
backBtn->ResetState();
}
diff --git a/source/settings/menus/FlyingButtonsMenu.hpp b/source/settings/menus/FlyingButtonsMenu.hpp
index 369c681a..49644660 100644
--- a/source/settings/menus/FlyingButtonsMenu.hpp
+++ b/source/settings/menus/FlyingButtonsMenu.hpp
@@ -50,6 +50,7 @@ class FlyingButtonsMenu : public GuiWindow
int currentPage;
int returnMenu;
+ int ParentMenu;
std::string MenuTitle;
enum
{
diff --git a/source/settings/menus/GameSettingsMenu.cpp b/source/settings/menus/GameSettingsMenu.cpp
index 37ec3cc5..1f187aa2 100644
--- a/source/settings/menus/GameSettingsMenu.cpp
+++ b/source/settings/menus/GameSettingsMenu.cpp
@@ -35,6 +35,8 @@ GameSettingsMenu::GameSettingsMenu(struct discHdr * header)
: FlyingButtonsMenu(GameTitles.GetTitle(header))
{
DiscHeader = header;
+ //! Don't switch menu's by default but return to disc window.
+ ParentMenu = -2;
}
GameSettingsMenu::~GameSettingsMenu()
diff --git a/source/settings/menus/UninstallSM.cpp b/source/settings/menus/UninstallSM.cpp
index d3531edb..c3326712 100644
--- a/source/settings/menus/UninstallSM.cpp
+++ b/source/settings/menus/UninstallSM.cpp
@@ -72,7 +72,6 @@ void UninstallSM::SetOptionValues()
//! Settings: Delete Cheat GCT
Options->SetValue(Idx++, " ");
-
}
int UninstallSM::GetMenuInternal()
@@ -90,6 +89,7 @@ int UninstallSM::GetMenuInternal()
int choice = WindowPrompt(tr( "Do you really want to delete:" ), GameTitles.GetTitle(DiscHeader), tr( "Yes" ), tr( "Cancel" ));
if (choice == 1)
{
+ std::string Title = GameTitles.GetTitle(DiscHeader);
GameSettings.Remove(DiscHeader->id);
GameSettings.Save();
GameStatistics.Remove(DiscHeader->id);
@@ -98,9 +98,9 @@ int UninstallSM::GetMenuInternal()
if(!mountMethod)
ret = WBFS_RemoveGame(DiscHeader->id);
if (ret < 0)
- WindowPrompt(tr( "Can't delete:" ), GameTitles.GetTitle(DiscHeader), tr( "OK" ));
+ WindowPrompt(tr( "Can't delete:" ), Title.c_str(), tr( "OK" ));
else
- WindowPrompt(tr( "Successfully deleted:" ), GameTitles.GetTitle(DiscHeader), tr( "OK" ));
+ WindowPrompt(tr( "Successfully deleted:" ), Title.c_str(), tr( "OK" ));
return MENU_DISCLIST;
}
diff --git a/source/usbloader/usbstorage2.c b/source/usbloader/usbstorage2.c
index b69dd99e..19027a7a 100644
--- a/source/usbloader/usbstorage2.c
+++ b/source/usbloader/usbstorage2.c
@@ -56,7 +56,7 @@
#define isMEM2Buffer(p) (((u32) p & 0x10000000) != 0)
#define MAX_BUFFER_SECTORS 256
-#define UMS_HEAPSIZE 0x8000
+#define UMS_HEAPSIZE 0x1000
/* Variables */
static char fs[] ATTRIBUTE_ALIGN(32) = "/dev/usb2";
@@ -93,8 +93,11 @@ s32 USBStorage2_Init(void)
if (ret < 0) goto err;
/* Get device capacity */
- ret = USBStorage2_GetCapacity(§or_size);
- if (ret < 0) goto err;
+ if (USBStorage2_GetCapacity(§or_size) == 0 || sector_size != 512)
+ {
+ ret = IPC_ENOENT;
+ goto err;
+ }
return ret; // 0->HDD, 1->DVD
@@ -153,8 +156,6 @@ s32 USBStorage2_GetCapacity(u32 *_sector_size)
s32 USBStorage2_ReadSectors(u32 sector, u32 numSectors, void *buffer)
{
u8 *buf = (u8 *) buffer;
- u32 len = (sector_size * numSectors);
-
s32 ret = -1;
/* Device not opened */
@@ -163,33 +164,34 @@ s32 USBStorage2_ReadSectors(u32 sector, u32 numSectors, void *buffer)
if (!mem2_ptr)
mem2_ptr = (u8 *) MEM2_alloc(sector_size * MAX_BUFFER_SECTORS);
- // Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
- if (!isMEM2Buffer(buffer))
+ s32 read_secs, read_size;
+
+ while(numSectors > 0)
{
- buf = mem2_ptr;
- s32 read_size;
- s32 sectors_done = 0;
+ read_secs = numSectors > MAX_BUFFER_SECTORS ? MAX_BUFFER_SECTORS : numSectors;
+ read_size = read_secs*sector_size;
- while(sectors_done < numSectors)
+ // Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
+ if (!isMEM2Buffer(buffer))
{
- read_size = numSectors-sectors_done < MAX_BUFFER_SECTORS ? numSectors-sectors_done : MAX_BUFFER_SECTORS;
-
- ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector+sectors_done, read_size, buf, read_size*sector_size);
+ ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector, read_secs, mem2_ptr, read_size);
if(ret < 0)
return ret;
- memcpy(((u8 *) buffer) + sectors_done*sector_size, buf, read_size*sector_size);
-
- sectors_done += read_size;
+ memcpy(buf, mem2_ptr, read_size);
+ }
+ else
+ {
+ /* Read data */
+ ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector, read_secs, buf, read_size);
+ if(ret < 0)
+ return ret;
}
- }
- else
- {
- /* Read data */
- ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_READ_SECTORS, "ii:d", sector, numSectors, buf, len);
- }
- /* Copy data */
+ sector += read_secs;
+ numSectors -= read_secs;
+ buf += read_size;
+ }
return ret;
}
@@ -197,8 +199,6 @@ s32 USBStorage2_ReadSectors(u32 sector, u32 numSectors, void *buffer)
s32 USBStorage2_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
{
u8 *buf = (u8 *) buffer;
- u32 len = (sector_size * numSectors);
-
s32 ret = -1;
/* Device not opened */
@@ -208,31 +208,34 @@ s32 USBStorage2_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
if (!mem2_ptr)
mem2_ptr = (u8 *) MEM2_alloc(sector_size * MAX_BUFFER_SECTORS);
- /* MEM1 buffer */
- if (!isMEM2Buffer(buffer))
+ s32 write_size, write_secs;
+
+ while(numSectors > 0)
{
- // Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
- buf = mem2_ptr;
- s32 write_size;
- s32 sectors_done = 0;
+ write_secs = numSectors > MAX_BUFFER_SECTORS ? MAX_BUFFER_SECTORS : numSectors;
+ write_size = write_secs*sector_size;
- while(sectors_done < numSectors)
+ /* MEM1 buffer */
+ if (!isMEM2Buffer(buffer))
{
- write_size = numSectors-sectors_done < MAX_BUFFER_SECTORS ? numSectors-sectors_done : MAX_BUFFER_SECTORS;
+ // Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
+ memcpy(mem2_ptr, buf, write_size);
- memcpy(buf, ((u8 *) buffer) + sectors_done*sector_size, write_size*sector_size);
-
- ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector+sectors_done, write_size, buf, write_size*sector_size);
+ ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, write_secs, mem2_ptr, write_size);
if(ret < 0)
return ret;
-
- sectors_done += write_size;
}
- }
- else
- {
- /* Write data */
- ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, numSectors, buf, len);
+ else
+ {
+ /* Write data */
+ ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, write_secs, buf, write_size);
+ if(ret < 0)
+ return ret;
+ }
+
+ sector += write_secs;
+ numSectors -= write_secs;
+ buf += write_size;
}
return ret;
@@ -245,7 +248,7 @@ static bool __usbstorage_Startup(void)
static bool __usbstorage_IsInserted(void)
{
- return (USBStorage2_GetCapacity(NULL) >= 0);
+ return (USBStorage2_GetCapacity(NULL) != 0);
}
static bool __usbstorage_ReadSectors(u32 sector, u32 numSectors, void *buffer)