summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/makebuf.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1998-11-25 05:18:49 +0000
committermillert <millert@openbsd.org>1998-11-25 05:18:49 +0000
commitf10dd2c968f780ebc77d6d2354d9528121adaced (patch)
tree0a5e712ee61b12847c78b5f4557713ad338efeb7 /lib/libc/stdio/makebuf.c
parentremove bogus comment about pty use; chris@sefl.satelnet.org (diff)
downloadwireguard-openbsd-f10dd2c968f780ebc77d6d2354d9528121adaced.tar.xz
wireguard-openbsd-f10dd2c968f780ebc77d6d2354d9528121adaced.zip
Changes from NetBSD:
o Use S_ISCHR instead of doing it by hand o st_blksize cannot be negative (christos)
Diffstat (limited to 'lib/libc/stdio/makebuf.c')
-rw-r--r--lib/libc/stdio/makebuf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c
index 7b244324702..4ebc3e93362 100644
--- a/lib/libc/stdio/makebuf.c
+++ b/lib/libc/stdio/makebuf.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: makebuf.c,v 1.2 1996/08/19 08:32:54 tholo Exp $";
+static char rcsid[] = "$OpenBSD: makebuf.c,v 1.3 1998/11/25 05:18:49 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -100,8 +100,8 @@ __swhatbuf(fp, bufsize, couldbetty)
}
/* could be a tty iff it is a character device */
- *couldbetty = (st.st_mode & S_IFMT) == S_IFCHR;
- if (st.st_blksize <= 0) {
+ *couldbetty = S_ISCHR(st.st_mode);
+ if (st.st_blksize == 0) {
*bufsize = BUFSIZ;
return (__SNPT);
}
@@ -111,8 +111,10 @@ __swhatbuf(fp, bufsize, couldbetty)
* __sseek is mainly paranoia.) It is safe to set _blksize
* unconditionally; it will only be used if __SOPT is also set.
*/
- *bufsize = st.st_blksize;
- fp->_blksize = st.st_blksize;
+ if ((fp->_flags & __SSTR) == 0) {
+ *bufsize = st.st_blksize;
+ fp->_blksize = st.st_blksize;
+ }
return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ?
__SOPT : __SNPT);
}