Opened on 12/02/21 at 15:47:45
Closed on 02/08/23 at 03:15:24
#4559 closed defect (wontfix)
ln command problem in shell of RTEMS4.13/5.1
Reported by: | chenjin_zhong | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 5.3 |
Component: | shell | Version: | 5 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
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)).
Change History (3)
comment:1 Changed on 11/10/22 at 00:51:03 by Chris Johns
Milestone: | 5.1 → 5.3 |
---|
comment:2 Changed on 01/30/23 at 02:32:20 by Chris Johns
comment:3 Changed on 02/08/23 at 03:15:24 by Chris Johns
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I am closing this because the change will not be backwards compatible to 5.2 and 5.1. It is suitable for 6.
The latest code in FreeBSD has the values swapped:
https://github.com/freebsd/freebsd-src/blob/main/bin/ln/ln.c#L152
https://github.com/freebsd/freebsd-src/blob/main/bin/ln/ln.c#L225
Can we swap them in a release or will that break existing scripts?