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; ino_nr = m_in->m_vfs_fs_putnode.inode;
count = m_in->m_vfs_fs_putnode.count; count = m_in->m_vfs_fs_putnode.count;
if (fdp->fdr_putnode == NULL)
return ENOSYS;
if (count == 0 || count > INT_MAX) { if (count == 0 || count > INT_MAX) {
printf("fsdriver: invalid reference count\n"); printf("fsdriver: invalid reference count\n");
return EINVAL; return EINVAL;
} }
if (fdp->fdr_putnode != NULL)
return fdp->fdr_putnode(ino_nr, count); return fdp->fdr_putnode(ino_nr, count);
else
return OK;
} }
/* /*

View file

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