Soft links: Update Documentation, rename file, add system calls

This commit is contained in:
Gregory Nutt
2017-02-02 17:11:08 -06:00
parent 35d738d85f
commit b39d962021
10 changed files with 147 additions and 105 deletions
File diff suppressed because it is too large Load Diff
+1
View File
@@ -32,6 +32,7 @@ gettimeofday NXgettimeofday
ioctl NXioctl
isatty NXisatty
kill NXkill
link NXlink
listen NXlisten
lseek NXlseek
mallinfo NXmallinfo
+1 -1
View File
@@ -1,7 +1,7 @@
############################################################################
# fs/Makefile
#
# Copyright (C) 2007, 2008, 2011-2014, 2016 Gregory Nutt. All rights reserved.
# Copyright (C) 2007, 2008, 2011-2014, 2016-2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
+1 -5
View File
@@ -43,10 +43,6 @@ ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
CSRCS += fs_close.c fs_read.c fs_write.c fs_ioctl.c
ifneq ($(CONFIG_PSEUDOFS_SOFTLINKS),0)
CSRCS += fs_softlink.c
endif
# Stream support
ifneq ($(CONFIG_NFILE_STREAMS),0)
@@ -91,7 +87,7 @@ endif
CSRCS += fs_pread.c fs_pwrite.c
ifneq ($(CONFIG_PSEUDOFS_SOFTLINKS),0)
CSRCS += fs_softlink.c
CSRCS += fs_link.c
endif
# Stream support
+11 -10
View File
@@ -1,5 +1,5 @@
/****************************************************************************
* fs/vfs/fs_softlink.c
* fs/vfs/fs_link.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -64,7 +65,7 @@
*
* Description:
* The link() function will create a new link (directory entry) for the
* existing file, path1. This implementation is simplied for use with
* existing file, path2. This implementation is simplied for use with
* NuttX in these ways:
*
* - Links may be created only within the NuttX top-level, pseudo file
@@ -90,21 +91,21 @@ int link(FAR const char *path1, FAR const char *path2)
int errcode;
int ret;
/* Both paths must be absolute. We need only check path2 here. path1 will
/* Both paths must be absolute. We need only check path1 here. path2 will
* be checked by inode find.
*/
if (path2 == NULL || *path2 != '/')
if (path1 == NULL || *path1 != '/')
{
errcode = EINVAL;
goto errout;
}
/* Check that no inode exists at the 'path2' and that the path up to 'path2'
/* Check that no inode exists at the 'path1' and that the path up to 'path1'
* does not lie on a mounted volume.
*/
inode = inode_find(path1, NULL);
inode = inode_find(path2, NULL);
if (inode != NULL)
{
#ifndef CONFIG_DISABLE_MOUNTPOINT
@@ -119,7 +120,7 @@ int link(FAR const char *path1, FAR const char *path2)
else
#endif
{
/* A node already exists in the pseudofs at 'path2' */
/* A node already exists in the pseudofs at 'path1' */
errcode = EEXIST;
}
@@ -133,9 +134,9 @@ int link(FAR const char *path1, FAR const char *path2)
else
{
/* Copy path2 */
/* Copy path1 */
FAR char *newpath2 = strdup(path2);
FAR char *newpath2 = strdup(path1);
if (newpath2 == NULL)
{
errcode = ENOMEM;
@@ -148,7 +149,7 @@ int link(FAR const char *path1, FAR const char *path2)
*/
inode_semtake();
ret = inode_reserve(path1, &inode);
ret = inode_reserve(path2, &inode);
inode_semgive();
if (ret < 0)
+1 -1
View File
@@ -328,7 +328,7 @@ union inode_ops_u
FAR struct mqueue_inode_s *i_mqueue; /* POSIX message queue */
#endif
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
FAR char *i_link; /* Full path to link */
FAR char *i_link; /* Full path to link target */
#endif
};
+11 -4
View File
@@ -323,11 +323,18 @@
# define SYS_statfs (__SYS_filedesc+12)
# define SYS_telldir (__SYS_filedesc+13)
# if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
# define SYS_pipe2 (__SYS_filedesc+14)
# define __SYS_mkfifo2 (__SYS_filedesc+15)
# if defined(CONFIG_PSEUDOFS_SOFTLINKS)
# define SYS_link (__SYS_filedesc+14)
# define __SYS_pipes (__SYS_filedesc+15)
# else
# define __SYS_mkfifo2 (__SYS_filedesc+14)
# define __SYS_pipes (__SYS_filedesc+14)
# endif
# if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
# define SYS_pipe2 (__SYS_pipes+0)
# define __SYS_mkfifo2 (__SYS_pipes+1)
# else
# define __SYS_mkfifo2 (__SYS_pipes+0)
# endif
# if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0
+1
View File
@@ -32,6 +32,7 @@
"insmod","nuttx/module.h","defined(CONFIG_MODULE)","FAR void *","FAR const char *","FAR const char *"
"ioctl","sys/ioctl.h","!defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","int","unsigned long"
"kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int"
"link","unistd.h","defined(CONFIG_PSEUDOFS_SOFTLINKS)","int","FAR const char *","FAR const char *"
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
"lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int"
"mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t"
1 _exit unistd.h void int
32 insmod nuttx/module.h defined(CONFIG_MODULE) FAR void * FAR const char *
33 ioctl sys/ioctl.h !defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0) int int
34 kill signal.h !defined(CONFIG_DISABLE_SIGNALS) int pid_t
35 link unistd.h defined(CONFIG_PSEUDOFS_SOFTLINKS) int FAR const char *
36 listen sys/socket.h CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET) int int
37 lseek unistd.h CONFIG_NFILE_DESCRIPTORS > 0 off_t int
38 mkdir sys/stat.h CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) int FAR const char*
+4
View File
@@ -232,6 +232,10 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
SYSCALL_LOOKUP(statfs, 2, STUB_statfs)
SYSCALL_LOOKUP(telldir, 1, STUB_telldir)
# if defined(CONFIG_PSEUDOFS_SOFTLINKS)
SYSCALL_LOOKUP(link, 2, STUB_link)
# endif
# if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
SYSCALL_LOOKUP(pipe2, 2, STUB_pipe2)
# endif
+2
View File
@@ -238,6 +238,8 @@ uintptr_t STUB_stat(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_statfs(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_telldir(int nbr, uintptr_t parm1);
uintptr_t STUB_link(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_pipe2(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_mkfifo2(int nbr, uintptr_t parm1, uintptr_t parm2,
uintptr_t parm3);