diff options
-rw-r--r-- | libdiskfs/file-syncfs.c | 36 | ||||
-rw-r--r-- | libnetfs/file-syncfs.c | 35 |
2 files changed, 38 insertions, 33 deletions
diff --git a/libdiskfs/file-syncfs.c b/libdiskfs/file-syncfs.c index 8cd4003b..d271ab1e 100644 --- a/libdiskfs/file-syncfs.c +++ b/libdiskfs/file-syncfs.c @@ -19,33 +19,35 @@ #include "fs_S.h" #include <hurd/fsys.h> -struct args -{ - int wait; -}; - -static error_t -helper (void *cookie, const char *name, mach_port_t control) -{ - struct args *args = cookie; - (void) name; - fsys_syncfs (control, args->wait, 1); - return 0; -} - /* Implement file_syncfs as described in <hurd/fs.defs>. */ kern_return_t diskfs_S_file_syncfs (struct protid *cred, int wait, int dochildren) { - struct args args = { wait }; - if (!cred) return EOPNOTSUPP; if (dochildren) - fshelp_map_active_translators (helper, &args); + { + error_t err; + char *n = NULL; + size_t n_len = 0; + mach_port_t *c; + size_t c_count, i; + + err = fshelp_get_active_translators (&n, &n_len, &c, &c_count); + if (err) + return err; + free(n); + + for (i = 0; i < c_count; i++) + fsys_syncfs (c[i], wait, 1); + + free(c); + if (err) + return err; + } if (diskfs_synchronous) wait = 1; diff --git a/libnetfs/file-syncfs.c b/libnetfs/file-syncfs.c index 0b14bb87..6a388daa 100644 --- a/libnetfs/file-syncfs.c +++ b/libnetfs/file-syncfs.c @@ -22,33 +22,36 @@ #include "fs_S.h" #include <hurd/fsys.h> -struct args -{ - int wait; -}; - -static error_t -helper (void *cookie, const char *name, mach_port_t control) -{ - struct args *args = cookie; - (void) name; - fsys_syncfs (control, args->wait, 1); - return 0; -} - error_t netfs_S_file_syncfs (struct protid *user, int wait, int dochildren) { error_t err; - struct args args = { wait }; if (!user) return EOPNOTSUPP; if (dochildren) - fshelp_map_active_translators (helper, &args); + { + char *n = NULL; + size_t n_len = 0; + mach_port_t *c; + size_t c_count, i; + + err = fshelp_get_active_translators (&n, &n_len, &c, &c_count); + if (err) + return err; + free(n); + + for (i = 0; i < c_count; i++) + fsys_syncfs (c[i], wait, 1); + + free(c); + if (err) + return err; + } + pthread_mutex_lock (&user->po->np->lock); err = netfs_attempt_syncfs (user->user, wait); |