bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] Implement the sync libnetfs stubs.


From: Sergiu Ivanov
Subject: [PATCH] Implement the sync libnetfs stubs.
Date: Fri, 14 Aug 2009 16:38:56 +0300
User-agent: Mutt/1.5.16 (2007-06-09)

>From d814b3960af9a1cda9c92f1323662a1f2ce02a54 Mon Sep 17 00:00:00 2001
From: Sergiu Ivanov <unlimitedscolobb@gmail.com>
Date: Wed, 8 Jul 2009 18:46:58 +0000
Subject: [PATCH] Implement the sync libnetfs stubs.

* netfs.c (netfs_attempt_sync): Sync every writable directory
associated with the supplied node.
(netfs_attempt_syncfs): Sync the root node.
---
 netfs.c |   48 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/netfs.c b/netfs.c
index 89d1bf6..1ac16b3 100644
--- a/netfs.c
+++ b/netfs.c
@@ -1,5 +1,6 @@
 /* Hurd unionfs
-   Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
+
    Written by Moritz Schulte <moritz@duesseldorf.ccc.de>.
 
    This program is free software; you can redistribute it and/or
@@ -282,7 +283,45 @@ error_t
 netfs_attempt_sync (struct iouser *cred, struct node *np,
                    int wait)
 {
-  return EOPNOTSUPP;
+  error_t err = 0;
+
+  /* A pessimistic combination (failure wins) of the results of all
+     calls to file_sync.  */
+  error_t combined_err = 0;
+
+  /* The index of the currently analyzed filesystem.  */
+  int i = 0;
+
+  /* The information about the currently analyzed filesystem.  */
+  ulfs_t * ulfs;
+
+  mutex_lock (&ulfs_lock);
+
+  /* Sync every writable directory associated with `np`.
+
+     TODO: Rewrite this after having modified ulfs.c and node.c to
+     store the paths and ports to the underlying directories in one
+     place, because now iterating over both lists looks ugly.  */
+  node_ulfs_iterate_unlocked (np)
+  {
+    /* Get the information about the current filesystem.  */
+    err = ulfs_get_num (i, &ulfs);
+    if (err)
+      combined_err = err;
+
+    if ((node_ulfs->port != MACH_PORT_NULL)
+       && (ulfs->flags & FLAG_ULFS_WRITABLE))
+      {
+       err = file_sync (node_ulfs->port, wait, 0);
+       if (err)
+         combined_err = err;
+      }
+
+    ++i;
+  }
+
+  mutex_unlock (&ulfs_lock);
+  return combined_err;
 }
 
 /* This should sync the entire remote filesystem.  If WAIT is set,
@@ -290,7 +329,10 @@ netfs_attempt_sync (struct iouser *cred, struct node *np,
 error_t
 netfs_attempt_syncfs (struct iouser *cred, int wait)
 {
-  return 0;
+  /* The complete list of ports to the merged filesystems is
+     maintained in the root node of unionfs, so if we sync it, we sync
+     every single merged directory.  */
+  return netfs_attempt_sync (cred, netfs_root_node, wait);
 }
 
 /* lookup */
-- 
1.6.3.3





reply via email to

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