2GB 이상의 파일을 다루는 문제

익명 사용자의 이미지

2GB 이상의 파일을 다루는 문제

파일 시스템의 한계를 떠나서, 2GB 이상의 파일을
다루는 데 필요한 다음 두 함수에 대한 것입니다.

lseek, ftruncate

1. off_t 가 long long 이 되지 않는 한, 두 함수는
2GB 이상의 파일을 다룰 수 없습니다. long long 이
모든 유닉스 컴파일러에서 지원되는 것도 아니구요.
그래서 2GB 이상을 다루는 데 지원되는 함수가 별도로
있는 지 알고 싶습니다. 저는 못 찾았습니다.

2. 윈32 API 는 다음 두 함수를 지원함으로써, 2GB
이상의 파일을 다룰 수 있도록 합니다.

SetFilePointer, SetEndOfFile

SetFilePointer 는 8바이트 오프셋을 입력받기 위해
하위 4바이트 오프셋은 그대로 받아오고, 상위 4바이트에
대한 포인터를 받아오도록 해서, 2GB 이상인 파일의
오프셋을 찾아갈 수 있습니다.

SetEndOfFile 은 현재 파일 포인터를 파일의 끝으로
만듭니다. 즉, ftruncate처럼 off_t 와는 무관하게 정의된
프로토타입입니다. 그래서, ftruncate 보다는 합리적인 것
같은 데 이 부분에 대해서는 어떻게 생각하시는 지 알고
싶습니다.

익명 사용자의 이미지

뭔 애기인지는 모르겠지만,
왜 문제가 되죠...
잘만 되는데.

sun을 예로 들겠습니다....

lf64 - transitional interfaces for 64-bit file offsets


struct aiocb struct aiocb64
off_t aio_offset; off64_t aio_offset;


struct dirent struct dirent64
ino_t d_ino; ino64_t d_ino;
off_t d_off; off64_t d_off;


struct flock struct flock64
off_t l_start; off64_t l_start;
off_t l_len; off64_t l_len;
F_SETLK F_SETLK64
F_SETLKW F_SETLKW64
F_GETLK F_GETLK64
F_FREESP F_FREESP64
O_LARGEFILE


fpos_t fpos64_t


rlim_t rlim64_t
struct rlimit struct rlimit64
rlim_t rlim_cur; rlim64_t rlim_cur;
rlim_t rlim_max; rlim64_t rlim_max;
RLIM_INFINITY RLIM64_INFINITY
RLIM_SAVED_MAX RLIM64_SAVED_MAX
RLIM_SAVED_CUR RLIM64_SAVED_CUR


struct stat struct stat64
ino_t st_ino; ino64_t st_ino;
off_t st_size; off64_t st_size;
blkcnt_t st_blocks; blkcnt64_t st_blocks;


struct statvfs struct statvfs64
fsblkcnt_t f_blocks; fsblkcnt64_t f_blocks;
fsblkcnt_t f_bfree; fsblkcnt64_t f_bfree;
fsblkcnt_t f_bavial; fsblkcnt64_t f_bavial;
fsfilcnt_t f_files; fsfilcnt64_t f_files;
fsfilcnt_t f_ffree; fsfilcnt64_t f_ffree;
fsfilcnt_t f_favail; fsfilcnt64_t f_favail;


off_t; off64_t;
ino_t; ino64_t;
blkcnt_t; blkcnt64_t;
fsblkcnt_t; fsblkcnt64_t;
fsfilcnt_t; fsfilcnt64_t;


_LFS64_LARGEFILE
_LFS64_STDIO


_CS_LFS64_CFLAGS
_CS_LFS64_LDFLAGS
_CS_LFS64_LIBS
_CS_LFS64_LINTFLAGS

64bit Handle에 대한 IF입니다. 참고 하세요.

그리고 sun의 경우 compile시 64bit로 compile하면 long은
4 byte -> 8 byte로 설정됩니다.

많은 unix들이 64bit를 지원하는걸로 보이는데요.

익명 사용자의 이미지

저는 이미 두가지 항목으로 문제점을 제시했습니다만,
뭐가 문제인지 모르시겠다는 것은, 제 글에 문제가
있는 모양이군요. 간단히 요약하면, lseek 이나 ftruncate
의 64 bit 버젼 함수가 별도로 있는지, 그리고 윈API 와
비교해서 어떤 프로토타입이 더 합리적이라 생각하는지
두가지 입니다. 이것을 표현하는 데 제 글이 문제가
있었는지요?

컴파일 타임 처리로 64비트가 지원된다는 것은 이미
알고 있습니다만, 컴파일 타임에 처리하는 방법은 배제하고
싶습니다. 32 비트 머쉰에서 작동하는 프로그램에서 long 을
모두 64비트로 만들고 싶진 않으니까요. 모듈화를 잘해서,
64비트 long 을 쓰는 모듈을 별도로 만들 수 있겠지만,
좋은 방법이라 생각되진 않는군요.

또하나는 sun 에 그런 정의가 있다해도 sun 의 일례에 지나지
않습니다. ANSI 나 다른 표준에서 정의하는 함수가 있는지가
제 질문의 요지 중 하나였습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.