fs: Implment link as a normal function instead macro
so "using ::link;" can pass the compiling. This change also simplify the implementation of the hard link in the future.
This commit is contained in:
parent
1e3af48fff
commit
a2a542562f
@ -96,6 +96,7 @@ CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PSEUDOFS_SOFTLINKS=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
@ -33,7 +33,7 @@ CSRCS += fs_fsync.c fs_truncate.c
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_PSEUDOFS_SOFTLINKS),0)
|
||||
CSRCS += fs_symlink.c fs_readlink.c
|
||||
CSRCS += fs_link.c fs_symlink.c fs_readlink.c
|
||||
endif
|
||||
|
||||
# Stream support
|
||||
|
64
fs/vfs/fs_link.c
Normal file
64
fs/vfs/fs_link.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* fs/vfs/fs_link.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: link
|
||||
*
|
||||
* Description:
|
||||
* The link function provides a wrapper to symlink. Solely to provide
|
||||
* compatibility to posix compatibility layer.
|
||||
*
|
||||
* See symlink for details on limitations.
|
||||
*
|
||||
* Input Parameters:
|
||||
* path1 - Points to a pathname naming an existing file.
|
||||
* path2 - Points to a pathname naming the new directory entry to be
|
||||
* created.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero (OK) is returned. Otherwise, -1 (ERROR) is returned
|
||||
* the errno variable is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int link(FAR const char *path1, FAR const char *path2)
|
||||
{
|
||||
return symlink(path1, path2);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
@ -252,6 +252,7 @@ SYSCALL_LOOKUP(futimens, 2)
|
||||
SYSCALL_LOOKUP(munmap, 2)
|
||||
|
||||
#if defined(CONFIG_PSEUDOFS_SOFTLINKS)
|
||||
SYSCALL_LOOKUP(link, 2)
|
||||
SYSCALL_LOOKUP(symlink, 2)
|
||||
SYSCALL_LOOKUP(readlink, 3)
|
||||
#endif
|
||||
|
@ -259,7 +259,6 @@
|
||||
|
||||
/* Helpers and legacy compatibility definitions */
|
||||
|
||||
#define link(p1, p2) symlink((p1), (p2))
|
||||
#define syncfs(f) fsync(f)
|
||||
#define fdatasync(f) fsync(f)
|
||||
#define getdtablesize(f) ((int)sysconf(_SC_OPEN_MAX))
|
||||
@ -372,6 +371,7 @@ int access(FAR const char *path, int amode);
|
||||
int rmdir(FAR const char *pathname);
|
||||
int unlink(FAR const char *pathname);
|
||||
int truncate(FAR const char *path, off_t length);
|
||||
int link(FAR const char *path1, FAR const char *path2);
|
||||
int symlink(FAR const char *path1, FAR const char *path2);
|
||||
ssize_t readlink(FAR const char *path, FAR char *buf, size_t bufsize);
|
||||
int chown(FAR const char *path, uid_t owner, gid_t group);
|
||||
|
@ -50,6 +50,7 @@
|
||||
"kill","signal.h","","int","pid_t","int"
|
||||
"lchmod","sys/stat.h","","int","FAR const char *","mode_t"
|
||||
"lchown","unistd.h","","int","FAR const char *","uid_t","gid_t"
|
||||
"link","unistd.h","defined(CONFIG_PSEUDOFS_SOFTLINKS)","int","FAR const char *","FAR const char *"
|
||||
"listen","sys/socket.h","defined(CONFIG_NET)","int","int","int"
|
||||
"lseek","unistd.h","","off_t","int","off_t","int"
|
||||
"lstat","sys/stat.h","","int","FAR const char *","FAR struct stat *"
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
Loading…
x
Reference in New Issue
Block a user