sendfile()시스템 콜 이렇게 이용하는거 맞나요??
글쓴이: 토끼아빠 / 작성시간: 토, 2008/02/23 - 1:06오후
안녕하세요~~
sendfile()이라는 시스템 콜 어떻게 이용하는건지 모르겠네요~~
"Advanced linux programming"책에서 아래의 코드를 참조하여 실행하였는데 빈 파일 하나 가 창조되기만 하고 복사는 되지 않네요...
여러 고수님들 부디 저의 미숙한 코드를 검토해주세요~~~
잘못된 부분을 찾으시면 제꺽 가르쳐주시기 바랍니다..
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int read_fd, write_fd;
struct stat stat_buf;
off_t offset = 0;
read_fd = open(argv[1], O_RDONLY);
fstat(read_fd, &stat_buf);
write_fd = open(argv[2], O_WRONLY | O_CREAT, stat_buf.st_mode);
sys_sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
close(read_fd);
close(write_fd);
return 0;
}좋은 하루 되세요
Forums:


댓글 달기