Added support for "ln" switch "-n" (no dereference).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16353 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
468009f830
commit
2d0e3b12b1
@ -1557,6 +1557,7 @@ do_link(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
bool force = false;
|
bool force = false;
|
||||||
bool symbolic = false;
|
bool symbolic = false;
|
||||||
|
bool dereference = true;
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters
|
||||||
int argi = 1;
|
int argi = 1;
|
||||||
@ -1578,6 +1579,9 @@ do_link(int argc, char **argv)
|
|||||||
case 's':
|
case 's':
|
||||||
symbolic = true;
|
symbolic = true;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
dereference = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown option `-%c'\n", arg[i]);
|
fprintf(stderr, "Unknown option `-%c'\n", arg[i]);
|
||||||
return FS_EINVAL;
|
return FS_EINVAL;
|
||||||
@ -1596,7 +1600,7 @@ do_link(int argc, char **argv)
|
|||||||
// check, if the the target is an existing directory
|
// check, if the the target is an existing directory
|
||||||
struct my_stat st;
|
struct my_stat st;
|
||||||
char targetBuffer[B_PATH_NAME_LENGTH];
|
char targetBuffer[B_PATH_NAME_LENGTH];
|
||||||
status_t error = sys_rstat(true, -1, target, &st, true);
|
status_t error = sys_rstat(true, -1, target, &st, dereference);
|
||||||
if (error == FS_OK) {
|
if (error == FS_OK) {
|
||||||
if (MY_S_ISDIR(st.mode)) {
|
if (MY_S_ISDIR(st.mode)) {
|
||||||
// get source leaf
|
// get source leaf
|
||||||
@ -1623,10 +1627,10 @@ do_link(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check, if the target exists
|
// check, if the target exists
|
||||||
error = sys_rstat(true, -1, target, &st, true);
|
error = sys_rstat(true, -1, target, &st, false);
|
||||||
if (error == FS_OK) {
|
if (error == FS_OK) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
fprintf(stderr, "Can't create link. `%s' is in the way.", target);
|
fprintf(stderr, "Can't create link. `%s' is in the way.\n", target);
|
||||||
return FS_FILE_EXISTS;
|
return FS_FILE_EXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user