|
写了一个简单的程序:
#include<stdio.h>
#include<string.h>
#include<linux/unistd.h>
#include<unistd.h>
_syscall3(long,open,char *,name,int,mode,int,flags)
int main()
{
int dest,len,fid;
char buffer[3]={'c','c','c'};
int i;
fid=open("/root/abc",0,10700);
dest=lseek(fid,2,0);
printf("%s\n",buffer);
printf("%d\n",dest);
if(dest!=2)
{
printf("Error:seek error.\n");
return 0;
}
len=write(fid,buffer,1);
printf("%d\n%d\n",fid,len);
close(fid);
return 1;
}
程序无法写入文件abc, 调用write后返回的len总是-1, abc内内容是abc, abc的属性是-rw-r-r
实在找不出原因, 请教了,谢谢 |
|