2

From 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;
}

Why should strlen(s) be equal to zero? In other words, why if it's bigger than zero then return an error? Since the colon should be at the end if exists (as the comment says), shouldn't its size be 1?

StackExchange123
  • 1,871
  • 9
  • 24

0 Answers0