#include <errno.h>
#include <fcntl.h>
+#include <fd_to_filename.h>
#include <not-cancel.h>
#include <stdio.h>
#include <sys/stat.h>
/* For most file systems, fchmod does not operate on O_PATH
descriptors, so go through /proc. */
- char buf[32];
- if (__snprintf (buf, sizeof (buf), "/proc/self/fd/%d", pathfd) < 0)
- {
- /* This also may report strange error codes to the caller
- (although snprintf really should not fail). */
- __close_nocancel (pathfd);
- return -1;
- }
-
- int ret = __chmod (buf, mode);
+ struct fd_to_filename filename;
+ int ret = __chmod (__fd_to_filename (pathfd, &filename), mode);
if (ret != 0)
{
if (errno == ENOENT)
#include <fcntl.h>
#include <sys/stat.h>
+#include <fd_to_filename.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <kernel-features.h>
#ifndef __ASSUME_EXECVEAT
/* We use the /proc filesystem to get the information. If it is not
- mounted we fail. */
- char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3];
- __snprintf (buf, sizeof (buf), "/proc/self/fd/%d", fd);
-
- /* We do not need the return value. */
- __execve (buf, argv, envp);
+ mounted we fail. We do not need the return value. */
+ struct fd_to_filename filename;
+ __execve (__fd_to_filename (fd, &filename), argv, envp);
int save = errno;