]> Zhao Yanbai Git Server - minix.git/commitdiff
libfsdriver: default to noop for putnode 06/3006/1
authorDavid van Moolenbroek <david@minix3.org>
Sun, 21 Jun 2015 17:53:53 +0000 (17:53 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Tue, 23 Jun 2015 14:38:28 +0000 (14:38 +0000)
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

minix/lib/libfsdriver/call.c
minix/lib/libfsdriver/lookup.c

index 7b43673968c26d7e61a987e8444d2223f150ced3..6b0e78ddb297bf3be9e1b685af62d66acc78806b 100644 (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;
 }
 
 /*
index b3bee1a90df51e7b44ef6d02540cff16ef1c7d85..b8e2ae08044aa77338bcadf0cc6543eed7316241 100644 (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;