>> Delete No. 30400 article
No. [질문]Raw device 문제...

등록 2001-05-15 16:11:00 By localhost     조회 2
이름 김일용    

		Linux 2.4.2.2를 사용하고 있습니다.
raw 라는 command를 이용해서 scsi disk를 bind 했구요...
[root@cetus codes]# raw -qa
/dev/raw/raw1:  bound to major 8, minor 1
/dev/raw/raw2:  bound to major 8, minor 2
/dev/raw/raw3:  bound to major 8, minor 3
/dev/raw/raw4:  bound to major 8, minor 4
 이렇게요...
 다음에 간단한 code를 작성해봤습니다.
 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
 int main()
{
        const char* path = "/dev/raw/raw1" ;
        char *buf ;
        struct stat f_stat ;
        int fd ;
        int len ;
         if((fd = open(path, O_RDWR, 0)) < 0) {
                printf("Can't open file : %s", path) ;
                exit(0) ;
        }
         printf("FD is %d", fd) ;
        stat(path, &f_stat) ;
        printf("File size = %d", f_stat.st_size) ;
         buf = (char*) malloc(4096) ;
        memset(buf, 'a', 4096) ;
         lseek(fd, 0, SEEK_SET) ;
        len = write(fd, buf, 4096) ;
         if(len < 0) {
                printf("Can't Write...!!") ;
                printf("Error No => %s", strerror(errno)) ;
                exit(0) ;
        }
         printf("Write %d bytes", len) ;
         return 0 ;
}
 컴파일하고 실행 했더니...
 [root@cetus codes]# ./ex01
FD is 3
File size = 0
Can't Write...!!
Error No => Invalid argument
 이런 결과가 나오는 군요....
 고민 끝에 mmap을 이용해봤는데..
 mmap자체가 되지 않더군요...
 혹시 여기에 대한 idea있으신분....--아자
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved