bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] trans: populate the mtab on demand


From: Justus Winter
Subject: [PATCH 2/3] trans: populate the mtab on demand
Date: Wed, 20 Nov 2013 11:10:07 +0100

Previously the mtab content was generated in the open hook. Delay this
until the data is needed. A follow up patch will take advantage of
this to both simplify the logic in mtab_populate and make it more
robust at the same time.

* trans/mtab.c (open_hook): Do not eagerly populate the mtab.
(trivfs_S_io_read): Populate the mtab struct on demand.
(trivfs_S_io_seek): Likewise.
(trivfs_S_io_readable): Likewise.
---
 trans/mtab.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/trans/mtab.c b/trans/mtab.c
index 4d10632..b1a3939 100644
--- a/trans/mtab.c
+++ b/trans/mtab.c
@@ -598,7 +598,7 @@ open_hook (struct trivfs_peropen *peropen)
   mtab->contents = NULL;
   mtab->contents_len = 0;
 
-  return mtab_populate (mtab, target_path, insecure);
+  return 0;
 }
 
 static void
@@ -628,6 +628,14 @@ trivfs_S_io_read (struct trivfs_protid *cred,
 
   /* Get the offset.  */
   op = cred->po->hook;
+
+  if (op->contents == NULL)
+    {
+      error_t err = mtab_populate (op, target_path, insecure);
+      if (err)
+        return err;
+    }
+
   if (offs == -1)
     offs = op->offs;
 
@@ -670,6 +678,13 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
 
   struct mtab *op = cred->po->hook;
 
+  if (op->contents == NULL)
+    {
+      error_t err = mtab_populate (op, target_path, insecure);
+      if (err)
+        return err;
+    }
+
   switch (whence)
     {
     case SEEK_CUR:
@@ -715,6 +730,13 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
 
   struct mtab *op = cred->po->hook;
 
+  if (op->contents == NULL)
+    {
+      error_t err = mtab_populate (op, target_path, insecure);
+      if (err)
+        return err;
+    }
+
   *amount = op->contents_len - op->offs;
   return 0;
 }
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]