diff options
author | Justus Winter <justus@gnupg.org> | 2016-10-05 15:38:58 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-09-12 10:41:35 +0200 |
commit | 5fef1b7f22ec0ee3730b80bbf972dbf9a8995091 (patch) | |
tree | 29890aef362b5a8ebffb4721a1967b818a22a3af /libnetfs/fsys-set-options.c | |
parent | 116552c075abf1d22057a608fee9d27684bcbbe5 (diff) | |
download | hurd-5fef1b7f22ec0ee3730b80bbf972dbf9a8995091.tar.gz hurd-5fef1b7f22ec0ee3730b80bbf972dbf9a8995091.tar.bz2 hurd-5fef1b7f22ec0ee3730b80bbf972dbf9a8995091.zip |
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.
Diffstat (limited to 'libnetfs/fsys-set-options.c')
-rw-r--r-- | libnetfs/fsys-set-options.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/libnetfs/fsys-set-options.c b/libnetfs/fsys-set-options.c index fb1c87ef..afa480f8 100644 --- a/libnetfs/fsys-set-options.c +++ b/libnetfs/fsys-set-options.c @@ -26,8 +26,24 @@ #include "netfs.h" #include "fsys_S.h" -/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET' - are pending libnetfs being fleshed out some more. */ +struct args +{ + char *data; + mach_msg_type_number_t len; + int do_children; +}; + +static error_t +helper (void *cookie, const char *name, mach_port_t control) +{ + struct args *args = cookie; + error_t err; + (void) name; + err = fsys_set_options (control, args->data, args->len, args->do_children); + if (err == MIG_SERVER_DIED || err == MACH_SEND_INVALID_DEST) + err = 0; + return err; +} /* Implement fsys_set_options as described in <hurd/fsys.defs>. */ error_t @@ -38,40 +54,21 @@ netfs_S_fsys_set_options (struct netfs_control *pt, int do_children) { error_t err = 0; + struct args args = { data, data_len, do_children }; + if (!pt) return EOPNOTSUPP; - 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_set_options (control, data, data_len, do_children); - 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; - } - -#if NOT_YET if (do_children) { +#if NOT_YET pthread_rwlock_wrlock (&netfs_fsys_lock); - err = netfs_node_iterate (helper); +#endif + err = fshelp_map_active_translators (helper, &args); +#if NOT_YET pthread_rwlock_unlock (&netfs_fsys_lock); - } #endif + } if (!err) { |