1
0
Fork 0
forked from nuttx/nuttx-update

From Lorenz Meier: The implementation of access() as vararg macro has the issue that any function call with the same name (even in a C++ class) will match with it and result in a compile error. I have replaced it with a small function, and tried to have decent documentation as well. This resolves the compile issue, and shouldn’t have negative side effects for users of the function.

This commit is contained in:
Gregory Nutt 2014-11-11 11:52:24 -06:00
parent 333824c32b
commit c23b7ec93d
3 changed files with 96 additions and 4 deletions

View file

@ -167,8 +167,9 @@ FAR char *getcwd(FAR char *buf, size_t size);
/* File path operations */
int unlink(FAR const char *pathname);
int access(FAR const char *path, int amode);
int rmdir(FAR const char *pathname);
int unlink(FAR const char *pathname);
/* Execution of programs from files */
@ -190,8 +191,6 @@ FAR char **getoptargp(void); /* Optional argument following option */
int *getoptindp(void); /* Index into argv */
int *getoptoptp(void); /* unrecognized option character */
#define access(...) (0)
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -35,7 +35,8 @@
# Add the unistd C files to the build
CSRCS += lib_getopt.c lib_getoptargp.c lib_getoptindp.c lib_getoptoptp.c
CSRCS += lib_access.c lib_getopt.c lib_getoptargp.c lib_getoptindp.c
CSRCS += lib_getoptoptp.c
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
ifneq ($(CONFIG_DISABLE_ENVIRON),y)

92
libc/unistd/lib_access.c Normal file
View file

@ -0,0 +1,92 @@
/****************************************************************************
* lib/unistd/lib_access.c
*
* Copyright (C) 2014 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(FAR const char *path, int amode)
{
return 0;
}