Make sure we have a mkfifo symbol.
Bug: https://code.google.com/p/android/issues/detail?id=58888 Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
This commit is contained in:
parent
393484ab35
commit
594b1a4af2
@ -224,6 +224,7 @@ libc_bionic_src_files := \
|
||||
bionic/libc_init_common.cpp \
|
||||
bionic/libc_logging.cpp \
|
||||
bionic/libgen.cpp \
|
||||
bionic/mkfifo.cpp \
|
||||
bionic/pthread_attr.cpp \
|
||||
bionic/pthread_detach.cpp \
|
||||
bionic/pthread_equal.cpp \
|
||||
|
33
libc/bionic/mkfifo.cpp
Normal file
33
libc/bionic/mkfifo.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
int mkfifo(const char* path, mode_t mode) {
|
||||
return mknod(path, (mode & ~S_IFMT) | S_IFIFO, 0);
|
||||
}
|
@ -178,10 +178,7 @@ mode_t umask(mode_t mode) {
|
||||
#define fstat64 fstat
|
||||
#define lstat64 lstat
|
||||
|
||||
static __inline__ int mkfifo(const char *__p, mode_t __m)
|
||||
{
|
||||
return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0);
|
||||
}
|
||||
extern int mkfifo(const char*, mode_t);
|
||||
|
||||
extern int fstatat(int dirfd, const char *path, struct stat *buf, int flags);
|
||||
extern int mkdirat(int dirfd, const char *pathname, mode_t mode);
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "TemporaryFile.h"
|
||||
|
||||
TEST(sys_stat, futimens) {
|
||||
FILE* fp = tmpfile();
|
||||
ASSERT_TRUE(fp != NULL);
|
||||
@ -51,3 +53,18 @@ TEST(sys_stat, futimens_EBADF) {
|
||||
ASSERT_EQ(-1, futimens(-1, times));
|
||||
ASSERT_EQ(EBADF, errno);
|
||||
}
|
||||
|
||||
TEST(sys_stat, mkfifo) {
|
||||
// Racy but probably sufficient way to get a suitable filename.
|
||||
std::string path;
|
||||
{
|
||||
TemporaryFile tf;
|
||||
path = tf.filename;
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, mkfifo(path.c_str(), 0666));
|
||||
struct stat sb;
|
||||
ASSERT_EQ(0, stat(path.c_str(), &sb));
|
||||
ASSERT_TRUE(S_ISFIFO(sb.st_mode));
|
||||
unlink(path.c_str());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user