后NULL我使用vmalloc的分配一个连续的虚拟存储器块。然后,我使用memset将该块的所有字节设置为0。然后,我用我创建的大小为16字节的数据结构填充此内存区域。指针变为递增
然后,我的功能之一时,我把一个指向这些结构中的一个,并开始走在存储区域找到的第0字节,这样我可以在这里放置另一个数据结构。我的第一个指针正确地获取了以前放置的结构,并且我可以看到地址。这是打印输出:
点的文件名/ //文件名 ffffc9001095b500 //地址
这是对这种结构的正确的存储区(因为我把它放在这里)。
然后,我增加我的指针,这应该带我到内存区域ffffc9001095b510, ,但相反,我的指针返回的地址为NULL。为什么是这样?
下面的代码:
void * check_aux(char * upPath, int index, int location){
struct directory * point;
int i = 0;
int dirnum = 0;
//int lastaddr;
printk("Inside check_aux\n");
if(location > 117){
return NULL;
}
else if(upPath == NULL){
return NULL;
}
else{
point = getLocation(index, location);
printk("This is point's filename %s\n%p\n", point->filename, point);
while(point != NULL && dirnum < 16){
while(point->filename[i] == upPath[i] || (point->filename[i] == 0 && (upPath[i] =='/' || upPath[i] == 0))){
printk("%c == %c\n", point->filename[i], upPath[i]);
if(point->filename[i] == 0 && upPath[i] == 0){
return NULL;
}
else if(point->filename[i] == 0 && upPath[i] == '/'){
if(nodes[point->index].type[0] == 'd'){
return check_aux(&upPath[i+1], point->index, 0);
}
else{
return NULL;
}
}
else{
i++;
}
}
dirnum++;
(point++);
}
if(dirnum == 16){
return check_aux(upPath, index, location+1);
}
printk("Returning point %p\n", point);
return point;
}
}
的数据结构定义为
struct directory{
char filename[14];
short index;
};
和文件名不能以0
啊,这么一个简单的错误。 TY。 – Magn3s1um