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 /libnetfs | |
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 'libnetfs')
-rw-r--r-- | libnetfs/file-get-translator.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c index f4022504..63c74c0b 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; |