From 5fef1b7f22ec0ee3730b80bbf972dbf9a8995091 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 5 Oct 2016 15:38:58 +0200 Subject: libfshelp: Add function to map over all active translators. * libdiskfs/file-syncfs.c (diskfs_S_file_syncfs): Use the new function. * libdiskfs/fsys-options.c (diskfs_S_fsys_set_options): Likewise. * libdiskfs/fsys-syncfs.c (diskfs_S_fsys_syncfs): Likewise. * libdiskfs/shutdown.c (diskfs_shutdown): Likewise. * libfshelp/fshelp.h (fshelp_map_active_translators): New declaration. * libfshelp/translator-list.c (fshelp_map_active_translators): New function. * libnetfs/file-syncfs.c (netfs_S_file_syncfs): Use the new function. * libnetfs/fsys-set-options.c (netfs_S_fsys_set_options): Likewise. * libnetfs/fsys-syncfs.c (netfs_S_fsys_syncfs): Likewise. * libnetfs/shutdown.c (netfs_shutdown): Likewise. --- libdiskfs/file-syncfs.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'libdiskfs/file-syncfs.c') diff --git a/libdiskfs/file-syncfs.c b/libdiskfs/file-syncfs.c index 2faab6ad..8cd4003b 100644 --- a/libdiskfs/file-syncfs.c +++ b/libdiskfs/file-syncfs.c @@ -19,34 +19,33 @@ #include "fs_S.h" #include +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 . */ kern_return_t diskfs_S_file_syncfs (struct protid *cred, int wait, int dochildren) { - error_t - helper (struct node *np) - { - error_t err; - mach_port_t control; - - err = fshelp_fetch_control (&np->transbox, &control); - pthread_mutex_unlock (&np->lock); - if (!err && (control != MACH_PORT_NULL)) - { - fsys_syncfs (control, wait, 1); - mach_port_deallocate (mach_task_self (), control); - } - pthread_mutex_lock (&np->lock); - return 0; - } - + struct args args = { wait }; + if (!cred) return EOPNOTSUPP; if (dochildren) - diskfs_node_iterate (helper); + fshelp_map_active_translators (helper, &args); if (diskfs_synchronous) wait = 1; -- cgit v1.2.3