红联Linux门户
Linux帮助

用c语言如何实现statfs()系统调用返回错误值ELOOP

发布时间:2006-04-25 16:04:38来源:红联作者:romalql
下面是我写的代码,其中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;
}

}
文章评论

共有 0 条评论