The cause of that error is rom_tool thinks the ROM has an incorrect size. It's possible retrieved values used to determine if the size is correct, may not be obtained properly in linux, I had to jump some hoops to get it to work on Mac OS X and that might have broken something for linux. I'll look at it tomorrow morning.
u64 GetFileSize_u64(char *filename)
{
u64 size;
#ifdef _WIN32
int fh;
u64 n;
fh = _open( filename, 0 );
n = _lseeki64(fh, 0, SEEK_END);
_close(fh);
size = (n / sizeof(short))*2;
#else
#ifdef __linux__
struct stat st;
stat(filename, &st);
size = st.st_size;
#else
FILE *file = fopen(filename,"rb");
fseeko(file, 0L, SEEK_END);
size = (u64)ftello(file);
fclose(file);
#endif //__linux__
#endif //_WIN32
return size;
}
I am running this on Linux, having gotten 3.1 from Github and built it with the Makefile.
Every single time I try to trim something which is 2G or larger in size, I get something like this:
% rom_tool -t "Shin Megami Tensei - Devil Survivor Overclocked.3ds"
CCI_FILE_SIZE = 0xffffffffffffffff
MEDIA_SIZE = 0x80000000
CCI_IMAGE_SIZE = 0x48085c00
CCI_S_TRIM_SIZE = 0x47ba3a00
[!] CCI is malformed
[+] Trimming CCI
[*] Completed Successfully
CCI file size is always all F's (which is -1 in hex).
Is it safe to ignore these errors?
No it's not, I'll have an update with the fix by bkifft pushed to Git soon.I am running this on Linux, having gotten 3.1 from Github and built it with the Makefile.
Every single time I try to trim something which is 2G or larger in size, I get something like this:
% rom_tool -t "Shin Megami Tensei - Devil Survivor Overclocked.3ds"
CCI_FILE_SIZE = 0xffffffffffffffff
MEDIA_SIZE = 0x80000000
CCI_IMAGE_SIZE = 0x48085c00
CCI_S_TRIM_SIZE = 0x47ba3a00
[!] CCI is malformed
[+] Trimming CCI
[*] Completed Successfully
CCI file size is always all F's (which is -1 in hex).
Is it safe to ignore these errors?
And is that bad? What does rom_tool say about the produced files?The new version no longer gives me the errors but the files produced are the same size and identical to the files produced by the 3.1 version...
And is that bad? What does rom_tool say about the produced files?
You said that it wasn't safe to ignore the errors in 3.1. But it's still producing the same trimmed ROM that I got when I ignored the errors in 3.1.
It's weird, but seems that _FILE_OFFSET_BITS 64 not working for truncate on my system. Failed with restore for files over 2Gb and with truncate for 4Gb files, until recompiled with changed to truncate64.
# cat /proc/version
Linux version 3.4.6 (root@NasX86-9) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Fri Apr 26 03:31:24 CST 2013
# ipkg list_installed | grep gcc
gcc - 4.2.1-5 - The GNU Compiler Collection.
# gcc --version
gcc (GCC) 4.2.1
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It is a QNAP NAS embedded linux
Code:# cat /proc/version Linux version 3.4.6 (root@NasX86-9) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Fri Apr 26 03:31:24 CST 2013 # ipkg list_installed | grep gcc gcc - 4.2.1-5 - The GNU Compiler Collection. # gcc --version gcc (GCC) 4.2.1 Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ldd --version
ldd (GNU libc) 2.6.1
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
# make
gcc --std=c99 -Wall -I. -c -o utils.o utils.c
[COLOR=#ff0000]utils.c: In function 'TruncateFile_u64':[/COLOR]
[COLOR=#ff0000]utils.c:198: warning: implicit declaration of function 'truncate'[/COLOR]
gcc --std=c99 -Wall -I. -c -o main.o main.c
gcc --std=c99 -Wall -I. -c -o ncsd.o ncsd.c
ncsd.c: In function 'GetNCSDData':
ncsd.c:261: warning: implicit declaration of function 'PrintCCIPartitionData'
ncsd.c: At top level:
ncsd.c:374: warning: conflicting types for 'PrintCCIPartitionData'
ncsd.c:261: warning: previous implicit declaration of 'PrintCCIPartitionData' was here
g++ -o rom_tool -static-libgcc -static-libstdc++ -lm utils.o main.o ncsd.o
g++: unrecognized option '-static-libstdc++'