问题描述
来自here:
/*
* Set bootfs_vnode.
*
* Bootfs_vnode is the vnode used for beginning path translation of
* pathnames starting with /.
*
* It is also incidentally the system's first current directory.
*/
int
vfs_setbootfs(const char *fsname)
{
char tmp[NAME_MAX+1];
char *s;
int result;
struct vnode *newguy;
vfs_biglock_acquire();
snprintf(tmp,sizeof(tmp)-1,"%s",fsname);
s = strchr(tmp,':');
if (s) {
/* If there's a colon,it must be at the end */
if (strlen(s)>0) {
vfs_biglock_release();
return EINVAL;
}
}
else {
strcat(tmp,":");
}
result = vfs_chdir(tmp);
if (result) {
vfs_biglock_release();
return result;
}
result = vfs_getcurdir(&newguy);
if (result) {
vfs_biglock_release();
return result;
}
change_bootfs(newguy);
vfs_biglock_release();
return 0;
}
为什么strlen(s)
等于零?换句话说,为什么它大于零然后返回错误?由于冒号应该在末尾(如评论所述)存在,所以它的大小不应该为1吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)