libfsdriver: default to noop for putnode

While putnode requests should always succeed, very simple file system
services may not care about reference counts and thus about putnode
requests at all.  For this reason, we now default to an OK response if
no fdr_putnode implementation is given.

Change-Id: I01f6421abf4546a1f69d8c21900a92d6acc45745
This commit is contained in:
David van Moolenbroek 2015-06-21 17:53:53 +00:00
parent 22840dea11
commit 3f30eb69f0
2 changed files with 9 additions and 7 deletions

View file

@ -99,15 +99,15 @@ fsdriver_putnode(const struct fsdriver * __restrict fdp,
ino_nr = m_in->m_vfs_fs_putnode.inode;
count = m_in->m_vfs_fs_putnode.count;
if (fdp->fdr_putnode == NULL)
return ENOSYS;
if (count == 0 || count > INT_MAX) {
printf("fsdriver: invalid reference count\n");
return EINVAL;
}
return fdp->fdr_putnode(ino_nr, count);
if (fdp->fdr_putnode != NULL)
return fdp->fdr_putnode(ino_nr, count);
else
return OK;
}
/*

View file

@ -259,7 +259,8 @@ fsdriver_lookup(const struct fsdriver * __restrict fdp,
else
r = ELOOP;
fdp->fdr_putnode(next_node.fn_ino_nr, 1);
if (fdp->fdr_putnode != NULL)
fdp->fdr_putnode(next_node.fn_ino_nr, 1);
if (r != OK)
break;
@ -276,7 +277,8 @@ fsdriver_lookup(const struct fsdriver * __restrict fdp,
}
/* We have found a new node. Continue from this node. */
fdp->fdr_putnode(cur_node.fn_ino_nr, 1);
if (fdp->fdr_putnode != NULL)
fdp->fdr_putnode(cur_node.fn_ino_nr, 1);
cur_node = next_node;
@ -324,7 +326,7 @@ fsdriver_lookup(const struct fsdriver * __restrict fdp,
m_out->m_fs_vfs_lookup.uid = cur_node.fn_uid;
m_out->m_fs_vfs_lookup.gid = cur_node.fn_gid;
m_out->m_fs_vfs_lookup.device = cur_node.fn_dev;
} else
} else if (fdp->fdr_putnode != NULL)
fdp->fdr_putnode(cur_node.fn_ino_nr, 1);
return r;