From 50d2a0d2a9130d627794fc8ef31ac97fccc94afa Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 20 Jun 1995 15:52:20 +0000 Subject: (diskfs_S_file_set_translator): Remove assignment from if test. --- libdiskfs/file-set-trans.c | 50 ++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'libdiskfs/file-set-trans.c') diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c index 43665dcc..10bb8899 100644 --- a/libdiskfs/file-set-trans.c +++ b/libdiskfs/file-set-trans.c @@ -32,6 +32,7 @@ diskfs_S_file_set_translator (struct protid *cred, { struct node *np; error_t error; + mach_port_t control = MACH_PORT_NULL; if (!cred) return EOPNOTSUPP; @@ -46,24 +47,36 @@ diskfs_S_file_set_translator (struct protid *cred, mutex_lock (&np->lock); - if (error = diskfs_isowner (np, cred)) + error = diskfs_isowner (np, cred); + if (error) { mutex_unlock (&np->lock); return error; } - /* Handle exclusive bits */ - if ((passive_flags & FS_TRANS_SET) - && (passive_flags & FS_TRANS_EXCL) - && np->istranslated) + if (active_flags & FS_TRANS_SET) { - mutex_unlock (&np->lock); - return EBUSY; + error = fshelp_fetch_control (&np->transbox, &control); + if (error) + { + mutex_unlock (&np->lock); + return error; + } + + if (control != MACH_PORT_NULL && (active_flags & FS_TRANS_EXCL == 0)) + { + mutex_unlock (&np->lock); + error = fsys_goaway (control, killtrans_flags); + if (error) + return error; + mutex_lock (&np->lock); + } } - if ((active_flags & FS_TRANS_SET) - && (active_flags & FS_TRANS_EXCL) - && np->transbox.active != MACH_PORT_NULL) + /* Handle exclusive passive bit *first*. */ + if ((passive_flags & FS_TRANS_SET) + && (passive_flags & FS_TRANS_EXCL) + && np->istranslated) { mutex_unlock (&np->lock); return EBUSY; @@ -71,22 +84,15 @@ diskfs_S_file_set_translator (struct protid *cred, if (active_flags & FS_TRANS_SET) { - if (active != np->transbox.active - && np->transbox.active != MACH_PORT_NULL) + error = fshelp_set_active (&np->transbox, active, + active_flags & FS_TRANS_EXCL); + if (error) { - mach_port_t control; - - error = fshelp_fetch_control (&np->transbox, &control); mutex_unlock (&np->lock); - if (!error) - error = fsys_goaway (control, killtrans_flags); - if (error) - return error; - mutex_lock (&np->lock); + return error; } - fshelp_set_active (&np->transbox, active); } - + /* Set passive translator */ if (passive_flags & FS_TRANS_SET) { -- cgit v1.2.3