Landry wrote:
> I just checked on a linux system, where getdents() exists, and the
> manual says :
> This is not the function you are interested in. Look at readdir(3) for
> the POSIX conforming C library interface. This page documents the bare
> kernel system call interface.
>
> Apparently, getdents() is not POSIX-compatible (maybe that's why it's
> not implemented on openbsd).
Sure, that's because its in thunar-vfs-os-bsd.c. Looks like OpenBSD
lacks both getdents() and whiteout inodes. Try the attached patch
(remember to rerun autogen.sh), it should fix the problem.
> Landry
Benedikt
Index: configure.in.in
===================================================================
--- configure.in.in (revision 22616)
+++ configure.in.in (working copy)
@@ -113,7 +113,7 @@
dnl *** Check for standard functions ***
dnl ************************************
AC_FUNC_MMAP()
-AC_CHECK_FUNCS([attropen extattr_get_fd fgetxattr lchmod localeconv \
+AC_CHECK_FUNCS([attropen extattr_get_fd fgetxattr getdents lchmod localeconv \
localtime_r mbrtowc mkdtemp mkfifo posix_madvise pread \
pwrite readdir_r sched_yield setgroupent setpassent \
statfs statvfs statvfs1 strcoll strlcpy strptime symlink])
Index: thunar-vfs/thunar-vfs-os-bsd.c
===================================================================
--- thunar-vfs/thunar-vfs-os-bsd.c (revision 22616)
+++ thunar-vfs/thunar-vfs-os-bsd.c (working copy)
@@ -65,6 +65,9 @@
_thunar_vfs_os_is_dir_empty (const gchar *absolute_path)
{
struct dirent *dp;
+#ifndef HAVE_GETDENTS
+ glong basep = 0;
+#endif
gchar dbuf[8 * DIRBLKSIZ];
gint size = 0;
gint loc = 0;
@@ -80,8 +83,15 @@
/* check if we need to fill the buffer again */
if (loc >= size)
{
- /* read the next chunk */
+#ifdef HAVE_GETDENTS
+ /* read the next chunk (no base pointer needed) */
size = getdents (fd, dbuf, sizeof (dbuf));
+#else
+ /* read the next chunk (OpenBSD fallback) */
+ size = getdirentries (fd, dbuf, sizeof (dbuf), &basep);
+#endif
+
+ /* check for eof/error */
if (size <= 0)
break;
loc = 0;
@@ -103,10 +113,16 @@
/* adjust the location pointer */
loc += dp->d_reclen;
- /* verify the inode and type */
- if (G_UNLIKELY (dp->d_fileno == 0 || dp->d_type == DT_WHT))
+ /* verify the inode */
+ if (G_UNLIKELY (dp->d_fileno == 0))
continue;
+#ifdef DT_WHT
+ /* verify the type (OpenBSD lacks whiteout) */
+ if (dp->d_type == DT_WHT)
+ continue;
+#endif
+
/* ignore '.' and '..' entries */
if (G_UNLIKELY (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))))
continue;
@@ -163,6 +179,9 @@
{
struct dirent *dp;
struct stat statb;
+#ifndef HAVE_GETDENTS
+ glong basep = 0;
+#endif
GList *path_list = NULL;
gchar *filename;
gchar *dbuf;
@@ -229,8 +248,15 @@
/* check if we need to fill the buffer again */
if (loc >= size)
{
- /* read the next chunk */
+#ifdef HAVE_GETDENTS
+ /* read the next chunk (no need for a base pointer) */
size = getdents (fd, dbuf, dlen);
+#else
+ /* read the next chunk (OpenBSD fallback) */
+ size = getdirentries (fd, dbuf, dlen, &basep);
+#endif
+
+ /* check for eof/error */
if (size <= 0)
break;
loc = 0;
@@ -248,10 +274,16 @@
/* adjust the location pointer */
loc += dp->d_reclen;
- /* verify the inode and type */
- if (G_UNLIKELY (dp->d_fileno == 0 || dp->d_type == DT_WHT))
+ /* verify the inode */
+ if (G_UNLIKELY (dp->d_fileno == 0))
continue;
+#ifdef DT_WHT
+ /* verify the type (OpenBSD lacks whiteout) */
+ if (dp->d_type == DT_WHT)
+ continue;
+#endif
+
/* ignore '.' and '..' entries */
if (G_UNLIKELY (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))))
continue;
_______________________________________________
Thunar-dev mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/thunar-dev