Applied, thanks! Flavio Cruz, le mer. 10 juil. 2024 17:05:34 +0100, a ecrit: > While these are short-circuited translators and simply change st_mode, > actual translators can be set on top. We want `showtrans` to > show the actual passive translator, not the short-circuited one. > --- > libdiskfs/file-get-trans.c | 37 ++++++++++++++++------------------ > libnetfs/file-get-translator.c | 30 +++++++++++++-------------- > 2 files changed, 32 insertions(+), 35 deletions(-) > > diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c > index b1ca6c0..7b204b7 100644 > --- a/libdiskfs/file-get-trans.c > +++ b/libdiskfs/file-get-trans.c > @@ -37,8 +37,22 @@ diskfs_S_file_get_translator (struct protid *cred, > > pthread_mutex_lock (&np->lock); > > - /* First look for short-circuited translators. */ > - if (S_ISLNK (np->dn_stat.st_mode)) > + if (np->dn_stat.st_mode & S_IPTRANS) > + { > + char *string; > + mach_msg_type_number_t len; > + err = diskfs_get_translator (np, &string, &len); > + if (!err) > + { > + if (len > *translen) > + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); > + memcpy (*trans, string, len); > + *translen = len; > + free (string); > + } > + } > + /* Check for short-circuited translators. */ > + else if (S_ISLNK (np->dn_stat.st_mode)) > { > unsigned int len = sizeof _HURD_SYMLINK + np->dn_stat.st_size + 1; > mach_msg_type_number_t amt; > @@ -113,24 +127,7 @@ diskfs_S_file_get_translator (struct protid *cred, > err = 0; > } > else > - { > - if (! (np->dn_stat.st_mode & S_IPTRANS)) > - err = EINVAL; > - else > - { > - char *string; > - mach_msg_type_number_t len; > - err = diskfs_get_translator (np, &string, &len); > - if (!err) > - { > - if (len > *translen) > - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); > - memcpy (*trans, string, len); > - *translen = len; > - free (string); > - } > - } > - } > + err = EINVAL; > > pthread_mutex_unlock (&np->lock); > > diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c > index f402250..63c74c0 100644 > --- a/libnetfs/file-get-translator.c > +++ b/libnetfs/file-get-translator.c > @@ -47,7 +47,21 @@ netfs_S_file_get_translator (struct protid *user, > return err; > } > > - if (S_ISLNK (np->nn_stat.st_mode)) > + if (np->nn_translated & S_IPTRANS) > + { > + char *string = NULL; > + mach_msg_type_number_t len = 0; > + err = netfs_get_translator (np, &string, &len); > + if (!err) > + { > + if (len > *translen) > + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); > + memcpy (*trans, string, len); > + *translen = len; > + free (string); > + } > + } > + else if (S_ISLNK (np->nn_stat.st_mode)) > { > unsigned int len = sizeof _HURD_SYMLINK + np->nn_stat.st_size + 1; > > @@ -113,20 +127,6 @@ netfs_S_file_get_translator (struct protid *user, > *translen = len; > err = 0; > } > - else if (np->nn_translated & S_IPTRANS) > - { > - char *string = NULL; > - mach_msg_type_number_t len = 0; > - err = netfs_get_translator (np, &string, &len); > - if (!err) > - { > - if (len > *translen) > - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); > - memcpy (*trans, string, len); > - *translen = len; > - free (string); > - } > - } > else > err = EINVAL; > > -- > 2.45.2 > >
-- Samuel <b> lisons de l'assembleur c -+- #sos - CrisC forever -+-