我已经在用户空间上编写了主管应用程序c
,我将白名单 id 保留在超级块上。它从 superblock 读取数据:
filepath = "/dev/flashSSD"
char soz[15];
int i=1;
fp = open(filepath,O_RDONLY);
if (fp<0) {printf("Unable to open %s block.\n",filepath);exit(EXIT_FAILURE);}
off_t off = lseek(fp,0,SEEK_SET);
ssize_t len = read(fp,prc,sizeof prc);
sscanf(prc[0],"%d",sany);
并在管理(插入,删除)ID后,它在退出时写回超级块:
fp = open(filepath,O_RDWR);
if (fp<0) {printf("Unable to open %s block.\n",filepath);exit(EXIT_FAILURE);}
if (lseek(fp,0,SEEK_SET)<0) {perror("write1: ");}
if (write(fp,&prc,sizeof(prc))<0) {perror("write2: ");}
close(fp);
现在,我如何从超级块中读取数据kernel
?