diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2024-07-10 17:05:34 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-07-10 22:32:32 +0200 |
commit | 50f494ee743a0892380eebfbf428f398bc3b40f5 (patch) | |
tree | 5e86cf37fd91960aa4be1eace544c4461e5b8a25 /libdiskfs | |
parent | 532d1e692e2e3ba5cae2bdcb0b0f0069ce05b92e (diff) | |
download | hurd-50f494ee743a0892380eebfbf428f398bc3b40f5.tar.gz hurd-50f494ee743a0892380eebfbf428f398bc3b40f5.tar.bz2 hurd-50f494ee743a0892380eebfbf428f398bc3b40f5.zip |
netfs and diskfs: make showtrans work correctly when translators are set on top of sylink/device/fifo/socket files.
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.
Message-ID: <b3ujoovkmz3iagqkmv6lyzgqsv3g5u2wiaqwktlttbalyd7oak@6qeiiupzzmag>
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/file-get-trans.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index b1ca6c00..7b204b76 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); |