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/shutdown.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'libdiskfs/shutdown.c') diff --git a/libdiskfs/shutdown.c b/libdiskfs/shutdown.c index 2436d528..3f774c31 100644 --- a/libdiskfs/shutdown.c +++ b/libdiskfs/shutdown.c @@ -22,35 +22,30 @@ #include "priv.h" #include +struct args +{ + int flags; +}; + +static error_t +helper (void *cookie, const char *name, mach_port_t control) +{ + struct args *args = cookie; + error_t err; + (void) name; + err = fsys_goaway (control, args->flags); + if (err == MIG_SERVER_DIED || err == MACH_SEND_INVALID_DEST) + err = 0; + return err; +} + /* Shutdown the filesystem; flags are as for fsys_goaway. */ error_t diskfs_shutdown (int flags) { int nports = -1; - int err; - - error_t - helper (struct node *np) - { - error_t error; - mach_port_t control; - - error = fshelp_fetch_control (&np->transbox, &control); - pthread_mutex_unlock (&np->lock); - if (!error && (control != MACH_PORT_NULL)) - { - error = fsys_goaway (control, flags); - mach_port_deallocate (mach_task_self (), control); - } - else - error = 0; - pthread_mutex_lock (&np->lock); - - if ((error == MIG_SERVER_DIED) || (error == MACH_SEND_INVALID_DEST)) - error = 0; - - return error; - } + error_t err; + struct args args = { flags }; if ((flags & FSYS_GOAWAY_UNLINK) && S_ISDIR (diskfs_root_node->dn_stat.st_mode)) @@ -58,7 +53,7 @@ diskfs_shutdown (int flags) if (flags & FSYS_GOAWAY_RECURSE) { - err = diskfs_node_iterate (helper); + err = fshelp_map_active_translators (helper, &args); if (err) return err; } -- cgit v1.2.3