* HostSymLink::fPath wasn't set to NULL by the constructor, which could
cause a segfault if Init() failed early. * The -d (don't dereference symlinks) option of cp shall only take effect on the top level. When descending into directories, symlinks shall never be dereferenced. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -300,7 +300,8 @@ class HostSymLink : public SymLink, public HostNode {
|
|||||||
public:
|
public:
|
||||||
HostSymLink()
|
HostSymLink()
|
||||||
: SymLink(),
|
: SymLink(),
|
||||||
HostNode()
|
HostNode(),
|
||||||
|
fPath(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +859,8 @@ private:
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
static fssh_status_t copy_entry(FSDomain *sourceDomain, const char *source,
|
static fssh_status_t copy_entry(FSDomain *sourceDomain, const char *source,
|
||||||
FSDomain *targetDomain, const char *target, const Options &options);
|
FSDomain *targetDomain, const char *target, const Options &options,
|
||||||
|
bool dereference);
|
||||||
|
|
||||||
static FSDomain *
|
static FSDomain *
|
||||||
get_file_domain(const char *target, const char *&fsTarget)
|
get_file_domain(const char *target, const char *&fsTarget)
|
||||||
@@ -931,7 +933,7 @@ copy_dir_contents(FSDomain *sourceDomain, const char *source,
|
|||||||
PathDeleter targetDeleter(targetEntry);
|
PathDeleter targetDeleter(targetEntry);
|
||||||
|
|
||||||
fssh_status_t error = copy_entry(sourceDomain, sourceEntry,
|
fssh_status_t error = copy_entry(sourceDomain, sourceEntry,
|
||||||
targetDomain, targetEntry, options);
|
targetDomain, targetEntry, options, false);
|
||||||
if (error != FSSH_B_OK)
|
if (error != FSSH_B_OK)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -1032,12 +1034,13 @@ copy_attributes(const char *source, Node *sourceNode, const char *target,
|
|||||||
|
|
||||||
static fssh_status_t
|
static fssh_status_t
|
||||||
copy_entry(FSDomain *sourceDomain, const char *source,
|
copy_entry(FSDomain *sourceDomain, const char *source,
|
||||||
FSDomain *targetDomain, const char *target, const Options &options)
|
FSDomain *targetDomain, const char *target, const Options &options,
|
||||||
|
bool dereference)
|
||||||
{
|
{
|
||||||
// open the source node
|
// open the source node
|
||||||
Node *sourceNode;
|
Node *sourceNode;
|
||||||
fssh_status_t error = sourceDomain->Open(source,
|
fssh_status_t error = sourceDomain->Open(source,
|
||||||
FSSH_O_RDONLY | (options.dereference ? 0 : FSSH_O_NOTRAVERSE),
|
FSSH_O_RDONLY | (dereference ? 0 : FSSH_O_NOTRAVERSE),
|
||||||
sourceNode);
|
sourceNode);
|
||||||
if (error != FSSH_B_OK) {
|
if (error != FSSH_B_OK) {
|
||||||
fprintf(stderr, "Error: Failed to open source path `%s': %s\n", source,
|
fprintf(stderr, "Error: Failed to open source path `%s': %s\n", source,
|
||||||
@@ -1365,7 +1368,7 @@ command_cp(int argc, const char* const* argv)
|
|||||||
PathDeleter targetDeleter(targetEntry);
|
PathDeleter targetDeleter(targetEntry);
|
||||||
|
|
||||||
error = copy_entry(sourceDomain, source, targetDomain,
|
error = copy_entry(sourceDomain, source, targetDomain,
|
||||||
targetEntry, options);
|
targetEntry, options, options.dereference);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 1.2. target is no dir:
|
// 1.2. target is no dir:
|
||||||
@@ -1377,7 +1380,7 @@ command_cp(int argc, const char* const* argv)
|
|||||||
// -> we create the target as a clone of the source
|
// -> we create the target as a clone of the source
|
||||||
// (copy_entry(<source>, <target>))
|
// (copy_entry(<source>, <target>))
|
||||||
error = copy_entry(sourceDomain, source, targetDomain, target,
|
error = copy_entry(sourceDomain, source, targetDomain, target,
|
||||||
options);
|
options, options.dereference);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user