[RTEMS Project] #4559: ln command problem in shell of RTEMS4.13/5.1
RTEMS trac
trac at rtems.org
Thu Dec 2 15:47:45 UTC 2021
#4559: ln command problem in shell of RTEMS4.13/5.1
----------------------------+--------------------
Reporter: chenjin_zhong | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone: 5.1
Component: shell | Version: 5
Severity: normal | Keywords:
Blocked By: | Blocking:
----------------------------+--------------------
Hi, when I use ln -s /tmp/file in shell. Ithink the meaning of this
instruction is to creates a symbolic link, which points to /tmp/file in
current directory.But I find that the code implements this function is
**exit(linkit(globals, argv[0], ".", 1)). **
The src code of linkit function is listed as follows.
int linkit(rtems_shell_ln_globals* globals, const char *source, const
char
*target, int isdir).
if (isdir ||
(!lstat(source, &sb) && S_ISDIR(sb.st_mode)) ||
(!hflag && !stat(source, &sb) && S_ISDIR(sb.st_mode))) {
if ((p = strrchr(target, '/')) == NULL)
p = target;
else
++p;
(void)snprintf(path, sizeof(path), "%s/%s", source, p);
**source = path;**
}
**if ((*linkf)(target, source))** {
warn("%s", source);
return (1);
}
As shown in black bold, variable source is a directory. Therefore, I think
the target is argv[0]. the source is ".". Therefore, the code
**exit(linkit(globals, argv[0], ".", 1))** should be replaced with
**exit(linkit(globals, ".",argv[0], 1))**.
--
Ticket URL: <http://devel.rtems.org/ticket/4559>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list