* BEntry::GetStat() and BNode::GetStat() used sizeof(struct stat) for the kernel

syscall, but they could not know if R5 code called them (in which case the stat
  size has a different size). We now always only return the R5 stat structure here.
  This fixes bug #420. We might want to find a different solution to this problem,
  though.
* Be got SYMLINK_MAX wrong - it's not the maximum number of links (that's SYMLOOP_MAX),
  but the maximum size of a symlink buffer. Added missing SYMLOOP_MAX and SYMLINK_MAX
  constants to limits.h.
* Fixes MAXSYMLINKS to use SYMLOOP_MAX, instead of SYMLINKS_MAX (which doesn't exist
  in POSIX specs, but we (intentionally) break source compatibility here).
* Reenabled the Haiku versions of stat(), fstat(), and lstat() when build for Haiku.
* Removed OpenBeOS namespace stuff from the files I touched.
* Removed superfluous StorageDefs.Private.h, whyever that ended up in a public header
  is beyond me.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-06-21 13:49:16 +00:00
parent dbd51bbab9
commit 7b3d36e5aa
12 changed files with 227 additions and 336 deletions
+28 -29
View File
@@ -1,18 +1,18 @@
//----------------------------------------------------------------------
// This software is part of the Haiku distribution and is covered
// by the MIT license.
//---------------------------------------------------------------------
/*
* Copyright 2002-2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tyler Dauwalder
* Ingo Weinhold, [email protected]
*/
/*!
\file Entry.cpp
BEntry and entry_ref implementations.
*/
#include <fcntl.h>
#include <new>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <Directory.h>
#include <Entry.h>
#include <Path.h>
@@ -21,21 +21,17 @@
#include <syscalls.h>
#ifdef USE_OPENBEOS_NAMESPACE
using namespace OpenBeOS;
#endif
#include <fcntl.h>
#include <new>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
using namespace std;
// SYMLINK_MAX is needed by B_SYMLINK_MAX
// I don't know, why it isn't defined.
#ifndef SYMLINK_MAX
#define SYMLINK_MAX (16)
#endif
//----------------------------------------------------------------------------
// struct entry_ref
//----------------------------------------------------------------------------
// #pragma mark - struct entry_ref
/*! \struct entry_ref
\brief A filesystem entry represented as a name in a concrete directory.
@@ -184,9 +180,8 @@ entry_ref::operator=(const entry_ref &ref)
*/
//----------------------------------------------------------------------------
// BEntry
//----------------------------------------------------------------------------
// #pragma mark - BEntry
/*!
\class BEntry
@@ -219,9 +214,10 @@ entry_ref::operator=(const entry_ref &ref)
- operator=(const BEntry&)
*/
BEntry::BEntry()
: fDirFd(-1),
fName(NULL),
fCStatus(B_NO_INIT)
:
fDirFd(-1),
fName(NULL),
fCStatus(B_NO_INIT)
{
}
@@ -322,9 +318,10 @@ BEntry::Exists() const
{
// just stat the beast
struct stat st;
return (GetStat(&st) == B_OK);
return GetStat(&st) == B_OK;
}
/*! \brief Fills in a stat structure for the entry. The information is copied into
the \c stat structure pointed to by \a result.
@@ -341,9 +338,11 @@ BEntry::GetStat(struct stat *result) const
{
if (fCStatus != B_OK)
return B_NO_INIT;
return _kern_read_stat(fDirFd, fName, false, result, sizeof(struct stat));
return _kern_read_stat(fDirFd, fName, false, result, R5_STAT_SIZE);
}
/*! \brief Reinitializes the BEntry to the path or directory path combination,
resolving symlinks if traverse is true
+22 -17
View File
@@ -1,34 +1,39 @@
//----------------------------------------------------------------------
// This software is part of the Haiku distribution and is covered
// by the MIT license.
//----------------------------------------------------------------------
/*
* Copyright 2002-2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tyler Dauwalder
* Ingo Weinhold, bonefish@users.sf.net
*/
/*!
\file Node.cpp
BNode implementation.
*/
#include <errno.h>
#include <fcntl.h>
#include <fs_attr.h> // for struct attr_info
#include <new>
#include <string.h>
#include <unistd.h>
#include "storage_support.h"
#include <Directory.h>
#include <Entry.h>
#include <fs_attr.h>
#include <Node.h>
#include <String.h>
#include <TypeConstants.h>
#include <syscalls.h>
#include "storage_support.h"
#include <errno.h>
#include <fcntl.h>
#include <new>
#include <string.h>
#include <unistd.h>
// #pragma mark - node_ref
//----------------------------------------------------------------------
// node_ref
//----------------------------------------------------------------------
// constructor
/*! \brief Creates an uninitialized node_ref object.
*/
node_ref::node_ref()
@@ -84,7 +89,7 @@ node_ref::operator=(const node_ref &ref)
}
// #pragma mark -
// #pragma mark - BNode
/*! \brief Creates an uninitialized BNode object
@@ -196,7 +201,7 @@ BNode::GetStat(struct stat *st) const
{
return fCStatus != B_OK
? fCStatus
: _kern_read_stat(fFd, NULL, false, st, sizeof(struct stat));
: _kern_read_stat(fFd, NULL, false, st, R5_STAT_SIZE);
}
+6 -6
View File
@@ -1,11 +1,12 @@
/*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <syscalls.h>
#include <sys/stat.h>
#include <syscalls.h>
#include <errno.h>
@@ -18,7 +19,6 @@
// R5 compatibility
#define R5_STAT_SIZE 60
#undef stat
#undef fstat