Switch to OpenBSD flags.c.
Change-Id: I0a35e5bd9f8edba27e0c73e5c8150636346d6a81
This commit is contained in:
parent
c57e5c8289
commit
a71b4c3f14
@ -241,7 +241,6 @@ libc_upstream_freebsd_src_files := \
|
||||
upstream-freebsd/lib/libc/gen/sleep.c \
|
||||
upstream-freebsd/lib/libc/gen/usleep.c \
|
||||
upstream-freebsd/lib/libc/stdio/fclose.c \
|
||||
upstream-freebsd/lib/libc/stdio/flags.c \
|
||||
upstream-freebsd/lib/libc/stdio/fopen.c \
|
||||
upstream-freebsd/lib/libc/stdlib/abs.c \
|
||||
upstream-freebsd/lib/libc/stdlib/getopt_long.c \
|
||||
@ -399,6 +398,7 @@ libc_upstream_openbsd_src_files := \
|
||||
upstream-openbsd/lib/libc/stdio/fgetws.c \
|
||||
upstream-openbsd/lib/libc/stdio/fileno.c \
|
||||
upstream-openbsd/lib/libc/stdio/findfp.c \
|
||||
upstream-openbsd/lib/libc/stdio/flags.c \
|
||||
upstream-openbsd/lib/libc/stdio/fmemopen.c \
|
||||
upstream-openbsd/lib/libc/stdio/fprintf.c \
|
||||
upstream-openbsd/lib/libc/stdio/fpurge.c \
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* $OpenBSD: flags.c,v 1.8 2014/08/31 02:21:18 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -30,22 +31,15 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)flags.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "local.h"
|
||||
|
||||
/*
|
||||
* Return the (stdio) flags for a given mode. Store the flags
|
||||
* to be passed to an _open() syscall through *optr.
|
||||
* to be passed to an open() syscall through *optr.
|
||||
* Return 0 on error.
|
||||
*/
|
||||
int
|
||||
@ -78,34 +72,33 @@ __sflags(const char *mode, int *optr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* 'b' (binary) is ignored */
|
||||
if (*mode == 'b')
|
||||
mode++;
|
||||
|
||||
/* [rwa][b]\+ means read and write */
|
||||
if (*mode == '+') {
|
||||
mode++;
|
||||
while (*mode != '\0')
|
||||
switch (*mode++) {
|
||||
case 'b':
|
||||
break;
|
||||
case '+':
|
||||
ret = __SRW;
|
||||
m = O_RDWR;
|
||||
}
|
||||
|
||||
/* 'b' (binary) can appear here, too -- and is ignored again */
|
||||
if (*mode == 'b')
|
||||
mode++;
|
||||
|
||||
/* 'x' means exclusive (fail if the file exists) */
|
||||
if (*mode == 'x') {
|
||||
mode++;
|
||||
if (m == O_RDONLY) {
|
||||
break;
|
||||
case 'e':
|
||||
o |= O_CLOEXEC;
|
||||
break;
|
||||
case 'x':
|
||||
if (o & O_CREAT)
|
||||
o |= O_EXCL;
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Lots of software passes other extension mode
|
||||
* letters, like Window's 't'
|
||||
*/
|
||||
#if 0
|
||||
errno = EINVAL;
|
||||
return (0);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
o |= O_EXCL;
|
||||
}
|
||||
|
||||
/* set close-on-exec */
|
||||
if (*mode == 'e')
|
||||
o |= O_CLOEXEC;
|
||||
|
||||
*optr = m | o;
|
||||
return (ret);
|
Loading…
x
Reference in New Issue
Block a user