2002-09-19 Jeff Johnston <jjohnstn@redhat.com>
* libc/posix/opendir.c (opendir): Change code to check for HAVE_FCNTL before calling fcntl. * libc/search/hash.c (hash_open): Ditto. * libc/search/hash_page.c (open_tmp): Ditto. * libc/reent/Makefile.am: Add fcntlr.c. * libc/reent/Makefile.in: Regenerated. * libc/reent/fcntlr.c: New file. * libc/stdio/fdopen.c (_fdopen_r): Change to call _fcntl_r instead of _fcntl when HAVE_FCNTL flag is set. * libc/syscalls/sysfcntl.c (fcntl): Check for HAVE_FCNTL flag to see if _fcntl or _fcntl_r should be called. If flag is not set, default to ENOSYS stub.
This commit is contained in:
parent
0688e43db7
commit
50558bf3bd
|
@ -1,3 +1,18 @@
|
||||||
|
2002-09-19 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* libc/posix/opendir.c (opendir): Change code to check
|
||||||
|
for HAVE_FCNTL before calling fcntl.
|
||||||
|
* libc/search/hash.c (hash_open): Ditto.
|
||||||
|
* libc/search/hash_page.c (open_tmp): Ditto.
|
||||||
|
* libc/reent/Makefile.am: Add fcntlr.c.
|
||||||
|
* libc/reent/Makefile.in: Regenerated.
|
||||||
|
* libc/reent/fcntlr.c: New file.
|
||||||
|
* libc/stdio/fdopen.c (_fdopen_r): Change to call _fcntl_r
|
||||||
|
instead of _fcntl when HAVE_FCNTL flag is set.
|
||||||
|
* libc/syscalls/sysfcntl.c (fcntl): Check for HAVE_FCNTL flag
|
||||||
|
to see if _fcntl or _fcntl_r should be called. If flag is not
|
||||||
|
set, default to ENOSYS stub.
|
||||||
|
|
||||||
2002-09-16 Jeff Johnston <jjohnstn@redhat.com>
|
2002-09-16 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* libc/include/wchar.h (mbstate_t): Change protective flag to
|
* libc/include/wchar.h (mbstate_t): Change protective flag to
|
||||||
|
|
|
@ -52,10 +52,14 @@ opendir(name)
|
||||||
{
|
{
|
||||||
register DIR *dirp;
|
register DIR *dirp;
|
||||||
register int fd;
|
register int fd;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if ((fd = open(name, 0)) == -1)
|
if ((fd = open(name, 0)) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (fcntl(fd, F_SETFD, 1) == -1 ||
|
#ifdef HAVE_FCNTL
|
||||||
|
rc = fcntl(fd, F_SETFD, 1);
|
||||||
|
#endif
|
||||||
|
if (rc == -1 ||
|
||||||
(dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
|
(dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
|
||||||
close (fd);
|
close (fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -33,6 +33,7 @@ GENERAL_SOURCES = \
|
||||||
closer.c \
|
closer.c \
|
||||||
reent.c \
|
reent.c \
|
||||||
impure.c \
|
impure.c \
|
||||||
|
fcntlr.c \
|
||||||
fstatr.c \
|
fstatr.c \
|
||||||
getreent.c \
|
getreent.c \
|
||||||
linkr.c \
|
linkr.c \
|
||||||
|
@ -69,6 +70,7 @@ CHEWOUT_FILES = \
|
||||||
closer.def \
|
closer.def \
|
||||||
reent.def \
|
reent.def \
|
||||||
execr.def \
|
execr.def \
|
||||||
|
fcntlr.def \
|
||||||
fstatr.def \
|
fstatr.def \
|
||||||
linkr.def \
|
linkr.def \
|
||||||
lseekr.def \
|
lseekr.def \
|
||||||
|
|
|
@ -130,6 +130,7 @@ GENERAL_SOURCES = \
|
||||||
closer.c \
|
closer.c \
|
||||||
reent.c \
|
reent.c \
|
||||||
impure.c \
|
impure.c \
|
||||||
|
fcntlr.c \
|
||||||
fstatr.c \
|
fstatr.c \
|
||||||
getreent.c \
|
getreent.c \
|
||||||
linkr.c \
|
linkr.c \
|
||||||
|
@ -162,6 +163,7 @@ CHEWOUT_FILES = \
|
||||||
closer.def \
|
closer.def \
|
||||||
reent.def \
|
reent.def \
|
||||||
execr.def \
|
execr.def \
|
||||||
|
fcntlr.def \
|
||||||
fstatr.def \
|
fstatr.def \
|
||||||
linkr.def \
|
linkr.def \
|
||||||
lseekr.def \
|
lseekr.def \
|
||||||
|
@ -192,17 +194,17 @@ DEFS = @DEFS@ -I. -I$(srcdir)
|
||||||
CPPFLAGS = @CPPFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = closer.$(OBJEXT) reent.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = closer.$(OBJEXT) reent.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@impure.$(OBJEXT) fstatr.$(OBJEXT) getreent.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@impure.$(OBJEXT) fcntlr.$(OBJEXT) fstatr.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@linkr.$(OBJEXT) lseekr.$(OBJEXT) openr.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@getreent.$(OBJEXT) linkr.$(OBJEXT) lseekr.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@readr.$(OBJEXT) signalr.$(OBJEXT) signgam.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@openr.$(OBJEXT) readr.$(OBJEXT) signalr.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@sbrkr.$(OBJEXT) statr.$(OBJEXT) timer.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@signgam.$(OBJEXT) sbrkr.$(OBJEXT) statr.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@unlinkr.$(OBJEXT) writer.$(OBJEXT)
|
@USE_LIBTOOL_FALSE@timer.$(OBJEXT) unlinkr.$(OBJEXT) writer.$(OBJEXT)
|
||||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
|
|
||||||
@USE_LIBTOOL_TRUE@libreent_la_OBJECTS = closer.lo reent.lo impure.lo \
|
@USE_LIBTOOL_TRUE@libreent_la_OBJECTS = closer.lo reent.lo impure.lo \
|
||||||
@USE_LIBTOOL_TRUE@fstatr.lo getreent.lo linkr.lo lseekr.lo openr.lo \
|
@USE_LIBTOOL_TRUE@fcntlr.lo fstatr.lo getreent.lo linkr.lo lseekr.lo \
|
||||||
@USE_LIBTOOL_TRUE@readr.lo signalr.lo signgam.lo sbrkr.lo statr.lo \
|
@USE_LIBTOOL_TRUE@openr.lo readr.lo signalr.lo signgam.lo sbrkr.lo \
|
||||||
@USE_LIBTOOL_TRUE@timer.lo unlinkr.lo writer.lo
|
@USE_LIBTOOL_TRUE@statr.lo timer.lo unlinkr.lo writer.lo
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/* Reentrant versions of fcntl system call. This implementation just
|
||||||
|
calls the fcntl system call. */
|
||||||
|
|
||||||
|
#include <reent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <_syslist.h>
|
||||||
|
|
||||||
|
/* Some targets provides their own versions of these functions. Those
|
||||||
|
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||||
|
|
||||||
|
#ifdef _REENT_ONLY
|
||||||
|
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
#define REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
|
||||||
|
/* We use the errno variable used by the system dependent layer. */
|
||||||
|
#undef errno
|
||||||
|
extern int errno;
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
<<_fcntl_r>>---Reentrant version of fcntl
|
||||||
|
|
||||||
|
INDEX
|
||||||
|
_fcntl_r
|
||||||
|
|
||||||
|
ANSI_SYNOPSIS
|
||||||
|
#include <reent.h>
|
||||||
|
int _fcntl_r(struct _reent *<[ptr]>,
|
||||||
|
int <[fd]>, int <[cmd]>, <[arg]>);
|
||||||
|
|
||||||
|
TRAD_SYNOPSIS
|
||||||
|
#include <reent.h>
|
||||||
|
int _fcntl_r(<[ptr]>, <[fd]>, <[cmd]>, <[arg]>)
|
||||||
|
struct _reent *<[ptr]>;
|
||||||
|
int <[fd]>;
|
||||||
|
int <[cmd]>;
|
||||||
|
int <[arg]>;
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
This is a reentrant version of <<fcntl>>. It
|
||||||
|
takes a pointer to the global data block, which holds
|
||||||
|
<<errno>>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
_fcntl_r (ptr, fd, cmd, arg)
|
||||||
|
struct _reent *ptr;
|
||||||
|
int fd;
|
||||||
|
int cmd;
|
||||||
|
int arg;
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
if ((ret = _fcntl (fd, cmd, arg)) == -1 && errno != 0)
|
||||||
|
ptr->_errno = errno;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
|
@ -143,7 +143,9 @@ __hash_open(file, flags, mode, info, dflags)
|
||||||
fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
|
fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
|
||||||
new_table = 1;
|
new_table = 1;
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL
|
||||||
(void)fcntl(hashp->fp, F_SETFD, 1);
|
(void)fcntl(hashp->fp, F_SETFD, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (new_table) {
|
if (new_table) {
|
||||||
if (!(hashp = init_hash(hashp, file, (HASHINFO *)info)))
|
if (!(hashp = init_hash(hashp, file, (HASHINFO *)info)))
|
||||||
|
|
|
@ -869,7 +869,9 @@ open_temp(hashp)
|
||||||
(void)sigprocmask(SIG_BLOCK, &set, &oset);
|
(void)sigprocmask(SIG_BLOCK, &set, &oset);
|
||||||
if ((hashp->fp = mkstemp(namestr)) != -1) {
|
if ((hashp->fp = mkstemp(namestr)) != -1) {
|
||||||
(void)unlink(namestr);
|
(void)unlink(namestr);
|
||||||
|
#ifdef HAVE_FCNTL
|
||||||
(void)fcntl(hashp->fp, F_SETFD, 1);
|
(void)fcntl(hashp->fp, F_SETFD, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
|
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
|
||||||
return (hashp->fp != -1 ? 0 : -1);
|
return (hashp->fp != -1 ? 0 : -1);
|
||||||
|
|
|
@ -64,7 +64,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode),
|
||||||
|
|
||||||
/* make sure the mode the user wants is a subset of the actual mode */
|
/* make sure the mode the user wants is a subset of the actual mode */
|
||||||
#ifdef HAVE_FCNTL
|
#ifdef HAVE_FCNTL
|
||||||
if ((fdflags = _fcntl (fd, F_GETFL, 0)) < 0)
|
if ((fdflags = _fcntl_r (ptr, fd, F_GETFL, 0)) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
fdmode = fdflags & O_ACCMODE;
|
fdmode = fdflags & O_ACCMODE;
|
||||||
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE)))
|
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE)))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
/* only called from stdio/fdopen.c, so arg can be int. */
|
/* only called from stdio/fdopen.c, so arg can be int. */
|
||||||
|
|
||||||
#include <reent.h>
|
#include <reent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
fcntl (fd, flag, arg)
|
fcntl (fd, flag, arg)
|
||||||
|
@ -9,9 +10,14 @@ fcntl (fd, flag, arg)
|
||||||
int flag;
|
int flag;
|
||||||
int arg;
|
int arg;
|
||||||
{
|
{
|
||||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
#ifdef HAVE_FCNTL
|
||||||
|
# ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||||
return _fcntl_r (_REENT, fd, flag, arg);
|
return _fcntl_r (_REENT, fd, flag, arg);
|
||||||
#else
|
# else
|
||||||
return _fcntl (fd, flag, arg);
|
return _fcntl (fd, flag, arg);
|
||||||
#endif
|
# endif
|
||||||
|
#else /* !HAVE_FCNTL */
|
||||||
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#endif /& !HAVE_FCNTL */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue