|
Hi there!
i'm using redhat 7.1 (kernel 2.4.2-2)
I
was binding 4scsi disks to /dev/raw/raw1 ~ /dev/raw/raw4.
Here is the
query about raw :
[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
then i make a
sample code like below :
#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\n",
path) ; exit(0)
; }
printf("FD is %d\n", fd)
; stat(path, &f_stat) ;
printf("File size = %d\n", f_stat.st_size) ;
buf =
(char*) malloc(512) ; memset(buf, 'a', 512)
;
lseek(fd, 0, SEEK_SET) ; len =
write(fd, buf, 512) ;
if(len < 0)
{ printf("Can't Write...!!\n")
; printf("Error No => %s\n",
strerror(errno)) ; exit(0)
; }
printf("Write %d bytes\n",
len) ;
return 0 ; }
but the result
is
[root@cetus codes]# ./ex01 FD is 3 File size
= 0 Can't Write...!! Error No => Invalid argument
Why
...?
Of cource i had read FAQ but i couldn't understand that.
Can
you explain more detail..?
Thank for your help.....^^
|