*Fixed support for drives >= 1TB size (and probably some others as well)

*Reworked the USB handle read/write functions
*Fixed crash on deleting games
*Updated NTFS3G of libntfs to Version 2010.10.02
This commit is contained in:
dimok321 2010-12-05 19:09:32 +00:00
parent 777e0394d0
commit 71c47c23bb
13 changed files with 83 additions and 62 deletions

File diff suppressed because one or more lines are too long

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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.

View File

@ -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;

View File

@ -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();
}

View File

@ -50,6 +50,7 @@ class FlyingButtonsMenu : public GuiWindow
int currentPage;
int returnMenu;
int ParentMenu;
std::string MenuTitle;
enum
{

View File

@ -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()

View File

@ -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;
}

View File

@ -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(&sector_size);
if (ret < 0) goto err;
if (USBStorage2_GetCapacity(&sector_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)