我写了这个:
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include <errno.h>
int main( void )
{
int fd;
char buf[4]="abc";
fd = open("/dev/mtd0", O_RDWR);
lseek(fd, 1, SEEK_SET);
write(fd, &buf, 4);
close(fd);
perror("perror output:");
return 0;
}
文件 /dev/mtd0 是使用 nandsim 内核模块创建的,并运行
mtdinfo /dev/mtd0
得到有意义的输出。在我运行我的程序后,它的输出:
perror output:: Invalid argument
如果我的程序有任何错误?