Mercurial > hg > octave-kai > gnulib-hg
diff lib/openat-priv.h @ 7389:0f8d70c02f29
[lib/ChangeLog]
Work around bug in Solaris 10 /proc file system:
/proc/self/fd/NNN/.. isn't the parent directory of
the directory whose file descriptor is NNN. This needs to
be worked around at run time, not compile time, since a
program might be built on Solaris 8, where things work, and
run on Solaris 10.
* openat-priv.h (BUILD_PROC_NAME): Remove. All callers changed
to use the following interface instead:
(OPENAT_BUFFER_SIZE): New macro.
(openat_proc_name): New function.
* at-func.c (AT_FUNC_NAME): Adjust to above changes.
* openat.c (openat_permissive, openat_needs_fchdir, fdopendir):
Likewise.
* openat-proc.c: New file.
[ChangeLog]
* modules/openat (Files): Add lib/openat-proc.c.
(Depends-on): Add same-inode, stdbool.
[m4/ChangeLog]
* openat.m4 (gl_FUNC_OPENAT): Add AC_LIBOBJ(openat-proc).
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 30 Sep 2006 00:37:48 +0000 (2006-09-30) |
parents | 43e3888c56c4 |
children | 4d22e9da1fe7 |
line wrap: on
line diff
--- a/lib/openat-priv.h +++ b/lib/openat-priv.h @@ -1,5 +1,6 @@ -/* macros used by openat-like functions - Copyright (C) 2005 Free Software Foundation, Inc. +/* Internals for openat-like functions. + + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,30 +18,11 @@ /* written by Jim Meyering */ -#include <stdio.h> -#include <string.h> #include <errno.h> -#include "alloca.h" -#include "intprops.h" +#include <stdlib.h> -/* Set PROC_FD_FILENAME to the expansion of "/proc/self/fd/%d/%s" in - alloca'd memory, using FD and FILE, respectively for %d and %s. */ -#define BUILD_PROC_NAME(Proc_fd_filename, Fd, File) \ - do \ - { \ - size_t filelen = strlen (File); \ - static const char procfd[] = "/proc/self/fd/%d/%s"; \ - /* Buffer for the file name we are going to use. It consists of \ - - the string /proc/self/fd/ \ - - the file descriptor number \ - - the file name provided. \ - The final NUL is included in the sizeof. \ - Subtract 4 to account for %d and %s. */ \ - size_t buflen = sizeof (procfd) - 4 + INT_STRLEN_BOUND (Fd) + filelen; \ - (Proc_fd_filename) = alloca (buflen); \ - snprintf ((Proc_fd_filename), buflen, procfd, (Fd), (File)); \ - } \ - while (0) +#define OPENAT_BUFFER_SIZE 512 +char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); /* Some systems don't have ENOSYS. */ #ifndef ENOSYS