Libraries updates and cleanup
* Updating common/lib * Updating lib/csu * Updating lib/libc * Updating libexec/ld.elf_so * Corrected test on __minix in featuretest to actually follow the meaning of the comment. * Cleaned up _REENTRANT-related defintions. * Disabled -D_REENTRANT for libfetch * Removing some unneeded __NBSD_LIBC defines and tests Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
+10
-12
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fdopen.c,v 1.15 2008/03/13 15:40:00 christos Exp $ */
|
||||
/* $NetBSD: fdopen.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fdopen.c,v 1.15 2008/03/13 15:40:00 christos Exp $");
|
||||
__RCSID("$NetBSD: fdopen.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -59,9 +59,7 @@ __weak_alias(fdopen,_fdopen)
|
||||
#endif
|
||||
|
||||
FILE *
|
||||
fdopen(fd, mode)
|
||||
int fd;
|
||||
const char *mode;
|
||||
fdopen(int fd, const char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
int flags, oflags, fdflags, tmp;
|
||||
@@ -81,30 +79,30 @@ fdopen(fd, mode)
|
||||
}
|
||||
|
||||
if ((flags = __sflags(mode, &oflags)) == 0)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
/* Make sure the mode the user wants is a subset of the actual mode. */
|
||||
if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
tmp = fdflags & O_ACCMODE;
|
||||
if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (oflags & O_NONBLOCK) {
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == -1) {
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
errno = EFTYPE;
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp = __sfp()) == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
fp->_flags = flags;
|
||||
/*
|
||||
* If opened for appending, but underlying descriptor does not have
|
||||
@@ -119,5 +117,5 @@ fdopen(fd, mode)
|
||||
fp->_write = __swrite;
|
||||
fp->_seek = __sseek;
|
||||
fp->_close = __sclose;
|
||||
return (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user