[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: |
Wed, 8 Jul 2009 22:30:41 +0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>From 61e2ab02f39e70732884c53b959cb4cf0b4c92a2 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.
---
unionfs does not implement the syncing libnetfs stubs. This patch
fixes this in a way that seems most natural: by syncing every writable
directory included in the node to be synced in response to file_sync
and by syncing the root node in response to fsys_getopts.
---
netfs.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/netfs.c b/netfs.c
index 89d1bf6..d8211e0 100644
--- a/netfs.c
+++ b/netfs.c
@@ -1,7 +1,10 @@
/* 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>.
+ Modified by Sergiu Ivanov <unlimitedscolobb@gmail.com>.
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
@@ -282,7 +285,36 @@ error_t
netfs_attempt_sync (struct iouser *cred, struct node *np,
int wait)
{
- return EOPNOTSUPP;
+ error_t 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`. */
+ node_ulfs_iterate_unlocked (np)
+ {
+ /* Get the information about the current filesystem. */
+ err = ulfs_get_num (i, &ulfs);
+ if (err)
+ break;
+
+ if (ulfs->flags & FLAG_ULFS_WRITABLE)
+ {
+ err = file_sync (node_ulfs->port, wait, 0);
+ if (err)
+ break;
+ }
+
+ ++i;
+ }
+
+ mutex_unlock (&ulfs_lock);
+ return err;
}
/* This should sync the entire remote filesystem. If WAIT is set,
@@ -290,7 +322,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
- [PATCH] Implement the sync libnetfs stubs.,
Sergiu Ivanov <=