* 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:
Ingo Weinhold 2007-09-05 03:06:04 +00:00
parent d249fa1b2c
commit fd51b44e2d

View File

@ -300,7 +300,8 @@ class HostSymLink : public SymLink, public HostNode {
public:
HostSymLink()
: SymLink(),
HostNode()
HostNode(),
fPath(NULL)
{
}
@ -858,7 +859,8 @@ private:
// #pragma mark -
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 *
get_file_domain(const char *target, const char *&fsTarget)
@ -931,7 +933,7 @@ copy_dir_contents(FSDomain *sourceDomain, const char *source,
PathDeleter targetDeleter(targetEntry);
fssh_status_t error = copy_entry(sourceDomain, sourceEntry,
targetDomain, targetEntry, options);
targetDomain, targetEntry, options, false);
if (error != FSSH_B_OK)
return error;
}
@ -1032,12 +1034,13 @@ copy_attributes(const char *source, Node *sourceNode, const char *target,
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)
{
// open the source node
Node *sourceNode;
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);
if (error != FSSH_B_OK) {
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);
error = copy_entry(sourceDomain, source, targetDomain,
targetEntry, options);
targetEntry, options, options.dereference);
}
} else {
// 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
// (copy_entry(<source>, <target>))
error = copy_entry(sourceDomain, source, targetDomain, target,
options);
options, options.dereference);
}
if (error != 0)