|
@@ -1937,7 +1936,32 @@ losetup d <dev-path>
+
+ Command Syntax:
+
+link [-s] <target> <link>
+
+
+ Synopsis.
+ The link command will create a new symbolic link at <link> for the existing file or directory, <target>.
+ This implementation is simplied for use with NuttX in these ways:
+
+
+ - Links may be created only within the NuttX top-level, pseudo file system.
+ No file system currently supported by NuttX provides symbolic links.
+ - For the same reason, only soft links are implemented.
+ - File privileges are ignored.
+ c_time is not updated.
+
+
+
@@ -1975,7 +1999,7 @@ ls [-lRs] <dir-path>
@@ -2008,7 +2032,7 @@ mydriver 20404659 20404625 0 20404580 552 204047a8 0
@@ -2025,7 +2049,7 @@ md5 [-f] <string or filepath>
@@ -2079,7 +2103,7 @@ nsh>
@@ -2113,7 +2137,7 @@ nsh> mount -t procfs /proc
@@ -2148,7 +2172,7 @@ nsh>
@@ -2173,7 +2197,7 @@ mkfatfs [-F <fatsize>] <block-driver>
@@ -2211,7 +2235,7 @@ nsh>
@@ -2262,7 +2286,7 @@ nsh>
@@ -2341,7 +2365,7 @@ nsh> mount
@@ -2359,7 +2383,7 @@ mv <old-path> <new-path>
@@ -2378,7 +2402,7 @@ nfsmount <server-address> <mount-point> <remote-path>
@@ -2395,7 +2419,7 @@ nslookup <host-name>
@@ -2412,7 +2436,7 @@ passwd <username> <password>
@@ -2449,7 +2473,7 @@ nsh>
@@ -2471,7 +2495,7 @@ poweroff
@@ -2506,7 +2530,7 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
@@ -2536,7 +2560,7 @@ nsh>
@@ -2558,7 +2582,7 @@ reboot
@@ -2592,7 +2616,7 @@ nsh>
@@ -2627,7 +2651,7 @@ nsh>
@@ -2655,7 +2679,7 @@ nsh>
@@ -2681,7 +2705,7 @@ nsh>
@@ -2700,7 +2724,7 @@ sh <script-path>
@@ -2721,7 +2745,7 @@ shutdown [--reboot]
@@ -2738,7 +2762,7 @@ sleep <sec>
@@ -2797,7 +2821,7 @@ nsh>
@@ -2827,7 +2851,7 @@ nsh>
@@ -2894,7 +2918,7 @@ uname [-a | -imnoprsv]
@@ -2920,7 +2944,7 @@ nsh>
@@ -2937,7 +2961,7 @@ urldecode [-f] <string or filepath>
@@ -2954,7 +2978,7 @@ urlencode [-f] <string or filepath>
@@ -2971,7 +2995,7 @@ useradd <username> <password>
@@ -2988,7 +3012,7 @@ userdel <username>
@@ -3005,7 +3029,7 @@ usleep <usec>
@@ -3032,7 +3056,7 @@ wget [-o <local-path>] <url>
@@ -3241,10 +3265,15 @@ nsh>
| !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_DEV_LOOP |
CONFIG_NSH_DISABLE_LOSETUP |
+
lsmod |
@@ -5165,10 +5194,10 @@ xxd -i romfs_img >nsh_romfsimg.h
CONFIG_NSH_ROMFSETC
CONFIG_NSH_ARCHROMFS
CONFIG_NSH_ROMFSMOUNTPT
+ CONFIG_NSH_ROMFSSECTSIZE
- CONFIG_NSH_ROMFSSECTSIZE
CONFIG_NSH_STRERROR
CONFIG_NSH_TELNET
CONFIG_NSH_TMPDIR
@@ -5218,6 +5247,7 @@ xxd -i romfs_img >nsh_romfsimg.h
insmod
kill
losetup
+ - ln
- ls
mb
- Login
diff --git a/arch/sim/src/nuttx-names.dat b/arch/sim/src/nuttx-names.dat
index f1373f1d9c1..bfede730667 100644
--- a/arch/sim/src/nuttx-names.dat
+++ b/arch/sim/src/nuttx-names.dat
@@ -32,6 +32,7 @@ gettimeofday NXgettimeofday
ioctl NXioctl
isatty NXisatty
kill NXkill
+link NXlink
listen NXlisten
lseek NXlseek
mallinfo NXmallinfo
diff --git a/fs/Makefile b/fs/Makefile
index 5ef45f84ee2..6ab682d28f2 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -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
#
# Redistribution and use in source and binary forms, with or without
diff --git a/fs/vfs/Make.defs b/fs/vfs/Make.defs
index 9b5e6911afb..9209da62983 100644
--- a/fs/vfs/Make.defs
+++ b/fs/vfs/Make.defs
@@ -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
diff --git a/fs/vfs/fs_softlink.c b/fs/vfs/fs_link.c
similarity index 90%
rename from fs/vfs/fs_softlink.c
rename to fs/vfs/fs_link.c
index b40a5ea9727..285db3bae8c 100644
--- a/fs/vfs/fs_softlink.c
+++ b/fs/vfs/fs_link.c
@@ -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
@@ -41,6 +41,7 @@
#include
#include
+#include
#include
#include
@@ -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)
diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h
index 584ccef287f..955d1b2c111 100644
--- a/include/nuttx/fs/fs.h
+++ b/include/nuttx/fs/fs.h
@@ -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
};
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
index eb53fdf9787..ac1dde570bf 100644
--- a/include/sys/syscall.h
+++ b/include/sys/syscall.h
@@ -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
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index 1b6917d5f38..d8ff96cf034 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -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"
diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h
index f8286ca6b1d..b302a928296 100644
--- a/syscall/syscall_lookup.h
+++ b/syscall/syscall_lookup.h
@@ -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
diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c
index 59c4515ac40..950553c7425 100644
--- a/syscall/syscall_stublookup.c
+++ b/syscall/syscall_stublookup.c
@@ -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);
|