개요
OS 가 32bit 이던 시절에는 File system 의 file size 를 32 bit integer 로 기술하였다.
이에 따라 개별 파일의 최대 크기는 4G - 1(unsigned integer일 경우), 2G - 1(signed integer일 경우) 였다.
OS 가 64 bit 로 변경되고 disk 용량과 처리 데이타의 크기가 늘어나면서 큰 파일을 처리할 수 있는 요구사항이 생겨났지만 아직도 app 은 32bit 가 많고 하위 호환성때문에 Large File Support(이하 LFS) 란
기법을 통해 하위호환성을 확보하면서 큰 파일을 처리할 수 있는 방법이 대두되었다.
제약 사항
- 일단 OS 가 64bit 이어야 하고 사용하는 file system 의 file size 항목이 64 bit 여야 한다. 예로 Windows가 64bit 라도 FAT32 같은 파일 시스템은 file size 가 32bit unsigned integer 이므로 4G - 1 이상의 파일을 지원하지 못하므로 NTFS 를 사용해야 한다.
- LFS는 보통 이식성과 호환성을 위해 특별한 pre-processor macro 를 통해 동작하게 설계되어 있다. 예로 fseek 나 ftell 등의 IO API 를 사용한다면 macro 를 통해 64관련 API 로 compile 되게 OS 나 compiler 별 macro 를 알고 있어야 한다.
OS 별 지원
compile 된 app의 bit 수 알아내기
Linux나 Un*x 계열에서 현재 app 가 몇 비트인지는 다음 명령어를 통해 알아낼 수 있다.
$ file command
Solaris 9 - 64bit
$ file $ORACLE_HOME/bin/sqlplus /oracle/app/oracle/product/920/bin/sqlplus: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped $ file /usr/bin/awk /usr/bin/awk: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped
CentOS 6.3 - 64bits
$ file /bin/gawk /bin/gawk: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
gcc는 64비트로 동작하므로 -m32 옵션으로 32bit 로 컴파일
$ echo "int main(void) { return 0; }" > a.c $ gcc -m32 a.c -o ./a.out-32 $ file ./a.out-32 ./a.out-32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
Linux의 LFS
현재 Linux 가 64 bit 인지는 다음 명령어를 통해서 알아 본다.
$ uname -m x86_64
- 현재 Linux의 FILESIZEBITS 알아 보기
- getconf FILESIZEBITS /usr
__USE_LARGEFILE Define correct standard I/O things. __USE_LARGEFILE64 Define LFS things with separate names. __USE_FILE_OFFSET64 Define 64bit interface as default.
Solaris
- lfcompile