From c23b7ec93d0dea8484e40368ef3593a6f45681b8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 11 Nov 2014 11:52:24 -0600 Subject: [PATCH] =?UTF-8?q?From=20Lorenz=20Meier:=20The=20implementation?= =?UTF-8?q?=20of=20access()=20as=20vararg=20macro=20has=20the=20issue=20th?= =?UTF-8?q?at=20any=20function=20call=20with=20the=20same=20name=20(even?= =?UTF-8?q?=20in=20a=20C++=20class)=20will=20match=20with=20it=20and=20res?= =?UTF-8?q?ult=20in=20a=20compile=20error.=20I=20have=20replaced=20it=20wi?= =?UTF-8?q?th=20a=20small=20function,=20and=20tried=20to=20have=20decent?= =?UTF-8?q?=20documentation=20as=20well.=20This=20resolves=20the=20compile?= =?UTF-8?q?=20issue,=20and=20shouldn=E2=80=99t=20have=20negative=20side=20?= =?UTF-8?q?effects=20for=20users=20of=20the=20function.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/unistd.h | 5 +-- libc/unistd/Make.defs | 3 +- libc/unistd/lib_access.c | 92 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 libc/unistd/lib_access.c diff --git a/include/unistd.h b/include/unistd.h index 5108faa5173..3fbf5698dad 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -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) } diff --git a/libc/unistd/Make.defs b/libc/unistd/Make.defs index 323e0a3b8ed..10cf5f0be26 100644 --- a/libc/unistd/Make.defs +++ b/libc/unistd/Make.defs @@ -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) diff --git a/libc/unistd/lib_access.c b/libc/unistd/lib_access.c new file mode 100644 index 00000000000..4871179507e --- /dev/null +++ b/libc/unistd/lib_access.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * lib/unistd/lib_access.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +/**************************************************************************** + * 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; +}