下面是我写的代码,其中path是由shell脚本传入的当前所在路径。但我怎么调试程序都得不出想要的结果,现在把程序发上来,望高手指点错误所在,不胜感激!!
/*Test the fs has many symbolic links*/
int many_links(const char* path, char* const argv[])
{
int result;
char bak_path[256];
char command[1024];
/* Create temporary file for test */
bzero(command, 1024);
sprintf(bak_path, "%s",path);
sprintf(command, "mv %s %s", path, bak_path);
bzero(command, 1024);
sprintf(command, "ln -s %s %s", path, path);
/* Start test the unexecutable file */
result=statfs(path, &buf);
if (result == -1 && errno == ELOOP)
{
printf("[+]statfs() error ELOOP test passed.\n");
return 0;
}
else
{
printf("[+]statfs() error ELOOP test failed.\n");
return 1;
}
}