diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-11 18:19:20 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-11 18:19:20 +0100 |
commit | 1e82fcb8e11e8a0b9947d825f0a9e74c25e508d0 (patch) | |
tree | f4bbbf87954261e1edc373ea0c20dacf34e0d6c1 | |
parent | 08564e1d8194a30157f5fd35e29b9cc397b38dd2 (diff) | |
download | px4-nuttx-1e82fcb8e11e8a0b9947d825f0a9e74c25e508d0.tar.gz px4-nuttx-1e82fcb8e11e8a0b9947d825f0a9e74c25e508d0.tar.bz2 px4-nuttx-1e82fcb8e11e8a0b9947d825f0a9e74c25e508d0.zip |
Replace macro with function to avoid having the macro match arbitrary function calls
-rw-r--r-- | nuttx/include/unistd.h | 2 | ||||
-rw-r--r-- | nuttx/libc/unistd/Make.defs | 2 | ||||
-rw-r--r-- | nuttx/libc/unistd/lib_access.c | 92 |
3 files changed, 94 insertions, 2 deletions
diff --git a/nuttx/include/unistd.h b/nuttx/include/unistd.h index 5108faa51..5888adebe 100644 --- a/nuttx/include/unistd.h +++ b/nuttx/include/unistd.h @@ -190,7 +190,7 @@ FAR char **getoptargp(void); /* Optional argument following option */ int *getoptindp(void); /* Index into argv */ int *getoptoptp(void); /* unrecognized option character */ -#define access(...) (0) +int access(const char *path, int amode); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/libc/unistd/Make.defs b/nuttx/libc/unistd/Make.defs index 323e0a3b8..4e601de0a 100644 --- a/nuttx/libc/unistd/Make.defs +++ b/nuttx/libc/unistd/Make.defs @@ -35,7 +35,7 @@ # Add the unistd C files to the build -CSRCS += lib_getopt.c lib_getoptargp.c lib_getoptindp.c lib_getoptoptp.c +CSRCS += lib_getopt.c lib_getoptargp.c lib_getoptindp.c lib_getoptoptp.c lib_access.c ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) ifneq ($(CONFIG_DISABLE_ENVIRON),y) diff --git a/nuttx/libc/unistd/lib_access.c b/nuttx/libc/unistd/lib_access.c new file mode 100644 index 000000000..cb2ba86fc --- /dev/null +++ b/nuttx/libc/unistd/lib_access.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * lib/lib_sleep.c + * + * Copyright (C) 2007, 2009, 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <unistd.h> + +/**************************************************************************** + * Preprocessor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Global Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: access + * + * Description: + * The access() function shall check the file named by the pathname pointed + * to by the path argument for accessibility according to the bit pattern + * contained in amode, using the real user ID in place of the effective user + * ID and the real group ID in place of the effective group ID. + * As there are no users in NuttX, the function always succeeds. + * + * Parameters: + * path - a pointer to the path + * amode - the access mode + * + * Returned Value: + * Always OK (zero) + * + * Assumptions: + * + ****************************************************************************/ + +int access(const char *path, int amode) +{ + return 0; +} |