I’m currently reading this:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=dirfd
What’s the difference between opendir() and dirfd() ?
Chris Evans, the author of vsftpd has provided “dirdf_extras.h” file to be
included on HPUX, AIX, IRIX:
#ifndef VSF_DIRFD_EXTRAS_H
#define VSF_DIRFD_EXTRAS_H
#define dirfd(x) ((x)->dd_fd)
#endif /* VSF_DIRFD_EXTRAS_H */
Here is the code in sysutil.c file to be ported:
void
vsf_sysutil_dir_stat(const struct vsf_sysutil_dir* p_dir,
struct vsf_sysutil_statbuf** p_ptr)
{
int fd = dirfd((DIR*) p_dir);
vsf_sysutil_fstat(fd, p_ptr);
}
If I just include “dirfd_extras.h”, I get “undefined symbol dirfd_”
warning.
If I put this dirfd.c source:
#include <sys/types.h>
#define _BSD_SOURCE
#include <dirent.h>
int dirfd(DIR* dirp) {
return dirp->fd;
}
I get “Name ‘fd’ not found in struct/union _dir” error, no matter if
“dirdf_extras.h” is included or not.
By the way, snip from fnctl.h, note that F_SETOWN and F_GETOWN are
commented out:
/*
- fcntl.h File control options used by open
-
- Copyright by WATCOM International Corp. 1988-1996. All rights
reserved.
- Copyright by QNX Software Systems Limited 1990-1996. All rights
reserved.
*/
/*
#define F_GETFL 3 /* Get file status flags /
#define F_SETFL 4 / Set file status flags */
/#define F_GETOWN 35/ /* get SIGIO/SIGURG proc/pgrp /
/#define F_SETOWN 36*/ /* set SIGIO/SIGURG proc/pgrp */
#define F_SETLK 6 /* Set record locking info /
#define F_SETLKW 7 / Set record locking info; */
Here is the code that needs them:
void
vsf_sysutil_activate_sigurg(int fd)
{
int retval = fcntl(fd, F_SETOWN, getpid());
if (retval != 0)
{
die(“fcntl”);
}
}
My I uncomment F_GETOWN and F_SETOWN? If not - what should I do?
Please comment.
Tony.