[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH glibc 08/34] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rt
From: |
Sergey Bugaev |
Subject: |
[RFC PATCH glibc 08/34] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld |
Date: |
Sun, 19 Mar 2023 18:09:51 +0300 |
hurd/lookup-retry.c is compiled into rtld, the dynamic linker/loader. To
avoid pulling in file_set_size, file_utimens, tty/ctty stuff, more
string/memory code (memmove, strncpy, strcpy), and more strtoul/itoa
code, compile out support for O_TRUNC and FS_RETRY_MAGICAL when building
hurd/lookup-retry.c for rtld. None of that functionality is useful to
rtld during startup anyway. Keep support for FS_RETRY_MAGICAL("/"),
since that does not pull in much, and is required for following absolute
symlinks.
The large number of extra code being pulled into rtld was noticed by
reviewing librtld.map & elf/librtld.os.map in the build tree.
It is worth noting that once libc.so is loaded, the real __open, __stat,
etc. replace the minimal versions used initially by rtld -- this is
especially important in the Hurd port, where the minimal rtld versions
do not use the dtable and just pass real Mach port names as fds. Thus,
once libc.so is loaded, rtld will gain access to the full
__hurd_file_name_lookup_retry () version, complete with FS_RETRY_MAGICAL
support, which is important in case the program decides to
dlopen ("/proc/self/fd/...") or some such.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
hurd/lookup-retry.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c
index 8850c4fd..99c98104 100644
--- a/hurd/lookup-retry.c
+++ b/hurd/lookup-retry.c
@@ -177,7 +177,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
/* We got a successful translation. Now apply any open-time
action flags we were passed. */
-
+#if !IS_IN (rtld)
if (!err && (flags & O_TRUNC))
{
/* Asked to truncate the file. */
@@ -189,6 +189,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
__file_utimens (*result, atime, mtime);
}
}
+#endif
if (err)
__mach_port_deallocate (__mach_task_self (), *result);
@@ -214,6 +215,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
file_name = &retryname[1];
break;
+#if !IS_IN (rtld)
case 'f':
if (retryname[1] == 'd' && retryname[2] == '/')
{
@@ -358,8 +360,9 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
goto bad_magic;
break;
- default:
bad_magic:
+#endif /* !IS_IN (rtld) */
+ default:
err = EGRATUITOUS;
goto out;
}
--
2.39.2
- [RFC PATCH glibc 05/34] hurd: Remove __hurd_threadvar_stack_{offset, mask}, (continued)
- [RFC PATCH glibc 05/34] hurd: Remove __hurd_threadvar_stack_{offset, mask}, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 09/34] hurd: Fix _hurd_setup_sighandler () signature, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 06/34] hurd: Swap around two function calls, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 07/34] hurd: Fix file name in #error, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 12/34] hurd: More 64-bit integer casting fixes, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 13/34] x86-64: Disable prefer_map_32bit_exec tunable on non-Linux, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 14/34] hurd: Move rtld-strncpy-c.c out of mach/hurd/, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 15/34] hurd: Use uintptr_t for register values in trampoline.c, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 10/34] stdio-common: Fix building when !IS_IN (libc), Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 11/34] mach, hurd: Drop __libc_lock_self0, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 08/34] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld,
Sergey Bugaev <=
- [RFC PATCH glibc 17/34] hurd: Implement x86_64/intr-msg.h, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 16/34] hurd: Add sys/ucontext.h and sigcontext.h for x86_64, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 18/34] hurd: Port trampoline.c to x86_64, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 19/34] hurd: Move a couple of singal-related files to x86, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 24/34] hurd: Only check for TLS initialization inside rtld or in static builds, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 21/34] x86_64: Add rtld-stpncpy & rtld-strncpy, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 23/34] elf: Stop including tls.h in ldsodefs.h, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 25/34] hurd: Improve reply port handling when exiting signal handlers, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 22/34] htl: Implement thread_set_pcsptp for x86_64, Sergey Bugaev, 2023/03/19
- [RFC PATCH glibc 29/34] hurd: Add vm_param.h for x86_64, Sergey Bugaev, 2023/03/19