[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile 1.7.91 has been released.
From: |
Kevin Ryde |
Subject: |
Re: Guile 1.7.91 has been released. |
Date: |
Tue, 14 Feb 2006 11:58:54 +1100 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
"Bill Schottstaedt" <address@hidden> writes:
>
> I found some examples by Googling for readdir_r and _PC_NAME_MAX.
Incomplete bit of code below, it's not pretty but I guess it's what
has to be done.
#if HAVE_READDIR_R
/* On Solaris 2.7, struct dirent only contains "char d_name[1]" and the
application is expected to provide a buffer of "sizeof(struct dirent)
+ NAME_MAX" bytes.
The glibc 2.3.2 manual notes this sort of thing too, and advises
"offsetof(struct dirent,d_name) + NAME_MAX + 1".
On Solaris 2.10, there's no NAME_MAX because it varies according to
the filesystem, one is expected to use pathconf().
So the code below tries a plain struct dirent, plus all three of the
above possibly bigger sizes, to establish the buffer. If we're not
using pathconf then the size is a constant and we don't need to
malloc/free, but let's assume for modern systems pathconf is usual so
most of the time we'll be wanting a dynamic size. */
size_t bufsize = sizeof (struct dirent);
char *buf;
int old_errno;
#ifdef NAME_MAX
bufsize = SCM_MAX (bufsize, sizeof(struct dirent) + NAME_MAX);
bufsize = SCM_MAX (bufsize, offsetof (struct dirent, d_name) + NAME_MAX +
1\);
#endif
#ifdef _PC_NAME_MAX
{
char *c_dirname = scm_to_locale_string (SCM_FILENAME (port));
long name_max = pathconf (c_dirname, _PC_NAME_MAX);
old_errno = errno;
free (c_dirname);
errno = old_errno;
if (name_max == -1)
SCM_SYSERROR;
bufsize = SCM_MAX (bufsize, name_max);
}
#endif
buf = scm_malloc (bufsize);
SCM_SYSCALL (readdir_r ((DIR *) SCM_CELL_WORD_1 (port),
(struct dirent *) buf,
&rdent));
...
- Re: Guile 1.7.91 has been released., (continued)
- Re: Guile 1.7.91 has been released., Bill Schottstaedt, 2006/02/13
- Re: Guile 1.7.91 has been released., Kevin Ryde, 2006/02/13
- Re: Guile 1.7.91 has been released., Bill Schottstaedt, 2006/02/13
- Re: Guile 1.7.91 has been released., Kevin Ryde, 2006/02/13
- Re: Guile 1.7.91 has been released., Bill Schottstaedt, 2006/02/13
- Re: Guile 1.7.91 has been released.,
Kevin Ryde <=
- Re: Guile 1.7.91 has been released., Kevin Ryde, 2006/02/13
- Re: Guile 1.7.91 has been released., Bill Schottstaedt, 2006/02/14
- Re: Guile 1.7.91 has been released., Kevin Ryde, 2006/02/14
- Re: Guile 1.7.91 has been released., Ludovic Courtès, 2006/02/15
- Re: Guile 1.7.91 has been released (x86-64 segfault), Bill Schottstaedt, 2006/02/15
Re: Guile 1.7.91 has been released., Ludovic Courtès, 2006/02/14
Re: Guile 1.7.91 has been released., Bill Schottstaedt, 2006/02/13