* 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:
@@ -1,114 +1,84 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
/*!
|
|
||||||
\file Directory.h
|
|
||||||
BDirectory interface declaration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _DIRECTORY_H
|
#ifndef _DIRECTORY_H
|
||||||
#define _DIRECTORY_H
|
#define _DIRECTORY_H
|
||||||
|
|
||||||
|
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <EntryList.h>
|
#include <EntryList.h>
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
#include <StorageDefs.Private.h>
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
namespace OpenBeOS {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class BSymLink;
|
class BSymLink;
|
||||||
|
|
||||||
/*!
|
|
||||||
\class BDirectory
|
|
||||||
\brief A directory in the filesystem
|
|
||||||
|
|
||||||
Provides an interface for manipulating directories and their contents.
|
|
||||||
|
|
||||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
|
||||||
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
|
|
||||||
|
|
||||||
\version 0.0.0
|
|
||||||
*/
|
|
||||||
class BDirectory : public BNode, public BEntryList {
|
class BDirectory : public BNode, public BEntryList {
|
||||||
public:
|
public:
|
||||||
BDirectory();
|
BDirectory();
|
||||||
BDirectory(const BDirectory &dir);
|
BDirectory(const BDirectory &dir);
|
||||||
BDirectory(const entry_ref *ref);
|
BDirectory(const entry_ref *ref);
|
||||||
BDirectory(const node_ref *nref);
|
BDirectory(const node_ref *nref);
|
||||||
BDirectory(const BEntry *entry);
|
BDirectory(const BEntry *entry);
|
||||||
BDirectory(const char *path);
|
BDirectory(const char *path);
|
||||||
BDirectory(const BDirectory *dir, const char *path);
|
BDirectory(const BDirectory *dir, const char *path);
|
||||||
|
|
||||||
virtual ~BDirectory();
|
virtual ~BDirectory();
|
||||||
|
|
||||||
status_t SetTo(const entry_ref *ref);
|
status_t SetTo(const entry_ref *ref);
|
||||||
status_t SetTo(const node_ref *nref);
|
status_t SetTo(const node_ref *nref);
|
||||||
status_t SetTo(const BEntry *entry);
|
status_t SetTo(const BEntry *entry);
|
||||||
status_t SetTo(const char *path);
|
status_t SetTo(const char *path);
|
||||||
status_t SetTo(const BDirectory *dir, const char *path);
|
status_t SetTo(const BDirectory *dir, const char *path);
|
||||||
|
|
||||||
status_t GetEntry(BEntry *entry) const;
|
status_t GetEntry(BEntry *entry) const;
|
||||||
|
|
||||||
bool IsRootDirectory() const;
|
bool IsRootDirectory() const;
|
||||||
|
|
||||||
status_t FindEntry(const char *path, BEntry *entry,
|
status_t FindEntry(const char *path, BEntry *entry,
|
||||||
bool traverse = false) const;
|
bool traverse = false) const;
|
||||||
|
|
||||||
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
|
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
|
||||||
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
|
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
|
||||||
|
|
||||||
status_t GetStatFor(const char *path, struct stat *st) const;
|
status_t GetStatFor(const char *path, struct stat *st) const;
|
||||||
|
|
||||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||||
virtual status_t GetNextRef(entry_ref *ref);
|
virtual status_t GetNextRef(entry_ref *ref);
|
||||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||||
int32 count = INT_MAX);
|
int32 count = INT_MAX);
|
||||||
virtual status_t Rewind();
|
virtual status_t Rewind();
|
||||||
virtual int32 CountEntries();
|
virtual int32 CountEntries();
|
||||||
|
|
||||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||||
status_t CreateFile(const char *path, BFile *file,
|
status_t CreateFile(const char *path, BFile *file,
|
||||||
bool failIfExists = false);
|
bool failIfExists = false);
|
||||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||||
BSymLink *link);
|
BSymLink *link);
|
||||||
|
|
||||||
BDirectory &operator=(const BDirectory &dir);
|
BDirectory &operator=(const BDirectory &dir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BNode;
|
friend class BNode;
|
||||||
|
friend class BEntry;
|
||||||
|
friend class BFile;
|
||||||
|
|
||||||
virtual void _ErectorDirectory1();
|
virtual void _ErectorDirectory1();
|
||||||
virtual void _ErectorDirectory2();
|
virtual void _ErectorDirectory2();
|
||||||
virtual void _ErectorDirectory3();
|
virtual void _ErectorDirectory3();
|
||||||
virtual void _ErectorDirectory4();
|
virtual void _ErectorDirectory4();
|
||||||
virtual void _ErectorDirectory5();
|
virtual void _ErectorDirectory5();
|
||||||
virtual void _ErectorDirectory6();
|
virtual void _ErectorDirectory6();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void close_fd();
|
virtual void close_fd();
|
||||||
int get_fd() const;
|
int get_fd() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 _reservedData[7];
|
uint32 _reservedData[7];
|
||||||
int fDirFd;
|
int fDirFd;
|
||||||
|
|
||||||
friend class BEntry;
|
|
||||||
friend class BFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// C functions
|
|
||||||
|
|
||||||
status_t create_directory(const char *path, mode_t mode);
|
status_t create_directory(const char *path, mode_t mode);
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
}; // namespace OpenBeOS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _DIRECTORY_H
|
#endif // _DIRECTORY_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+42
-68
@@ -1,89 +1,63 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
/*!
|
|
||||||
\file File.h
|
|
||||||
BFile interface declaration.
|
|
||||||
*/
|
|
||||||
#ifndef _FILE_H
|
#ifndef _FILE_H
|
||||||
#define _FILE_H
|
#define _FILE_H
|
||||||
|
|
||||||
|
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <StorageDefs.Private.h>
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
namespace OpenBeOS {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class BFile
|
|
||||||
\brief BFile is a wrapper class for common operations on files providing
|
|
||||||
access to the file's content data and its attributes.
|
|
||||||
|
|
||||||
A BFile represents a file in some file system. It implements the
|
|
||||||
BPositionIO interface and thus the methods to read from and write to the
|
|
||||||
file, and is derived of BNode to provide access to the file's attributes.
|
|
||||||
|
|
||||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
|
||||||
|
|
||||||
\version 0.0.0
|
|
||||||
*/
|
|
||||||
class BFile : public BNode, public BPositionIO {
|
class BFile : public BNode, public BPositionIO {
|
||||||
public:
|
public:
|
||||||
BFile();
|
BFile();
|
||||||
BFile(const BFile &file);
|
BFile(const BFile &file);
|
||||||
BFile(const entry_ref *ref, uint32 openMode);
|
BFile(const entry_ref *ref, uint32 openMode);
|
||||||
BFile(const BEntry *entry, uint32 openMode);
|
BFile(const BEntry *entry, uint32 openMode);
|
||||||
BFile(const char *path, uint32 openMode);
|
BFile(const char *path, uint32 openMode);
|
||||||
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
||||||
virtual ~BFile();
|
virtual ~BFile();
|
||||||
|
|
||||||
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
||||||
status_t SetTo(const BEntry *entry, uint32 openMode);
|
status_t SetTo(const BEntry *entry, uint32 openMode);
|
||||||
status_t SetTo(const char *path, uint32 openMode);
|
status_t SetTo(const char *path, uint32 openMode);
|
||||||
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
||||||
|
|
||||||
bool IsReadable() const;
|
bool IsReadable() const;
|
||||||
bool IsWritable() const;
|
bool IsWritable() const;
|
||||||
|
|
||||||
virtual ssize_t Read(void *buffer, size_t size);
|
virtual ssize_t Read(void *buffer, size_t size);
|
||||||
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
||||||
virtual ssize_t Write(const void *buffer, size_t size);
|
virtual ssize_t Write(const void *buffer, size_t size);
|
||||||
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
||||||
|
|
||||||
virtual off_t Seek(off_t offset, uint32 seekMode);
|
virtual off_t Seek(off_t offset, uint32 seekMode);
|
||||||
virtual off_t Position() const;
|
virtual off_t Position() const;
|
||||||
|
|
||||||
virtual status_t SetSize(off_t size);
|
virtual status_t SetSize(off_t size);
|
||||||
virtual status_t GetSize(off_t* size) const;
|
virtual status_t GetSize(off_t* size) const;
|
||||||
|
|
||||||
BFile &operator=(const BFile &file);
|
BFile &operator=(const BFile &file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void _PhiloFile1();
|
virtual void _PhiloFile1();
|
||||||
virtual void _PhiloFile2();
|
virtual void _PhiloFile2();
|
||||||
virtual void _PhiloFile3();
|
virtual void _PhiloFile3();
|
||||||
virtual void _PhiloFile4();
|
virtual void _PhiloFile4();
|
||||||
virtual void _PhiloFile5();
|
virtual void _PhiloFile5();
|
||||||
virtual void _PhiloFile6();
|
virtual void _PhiloFile6();
|
||||||
|
|
||||||
uint32 _reservedData[8];
|
uint32 _reservedData[8];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int get_fd() const;
|
int get_fd() const;
|
||||||
virtual void close_fd();
|
virtual void close_fd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! The file's open mode.
|
//! The file's open mode.
|
||||||
uint32 fMode;
|
uint32 fMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
}; // namespace OpenBeOS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _FILE_H
|
#endif // _FILE_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,85 +1,62 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
/*!
|
|
||||||
\file Statable.h
|
|
||||||
BStatable interface declaration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STATABLE_H
|
#ifndef _STATABLE_H
|
||||||
#define _STATABLE_H
|
#define _STATABLE_H
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
#include <sys/types.h>
|
||||||
namespace OpenBeOS {
|
#include <sys/stat.h>
|
||||||
#endif // USE_OPENBEOS_NAMESPACE
|
|
||||||
|
struct node_ref;
|
||||||
struct node_ref;
|
class BVolume;
|
||||||
class BVolume;
|
|
||||||
|
|
||||||
|
|
||||||
//! BStatable - A nice C++ wrapper to <code>stat()</code>
|
|
||||||
/*! A purly abstract class which provieds an expenive, but convenet
|
|
||||||
* C++ wrapper to the posix <code>\sa stat()</code> command.
|
|
||||||
*
|
|
||||||
* @see <a href="http://www.opensource.org/licenses/mit-license.html">MIT</a>
|
|
||||||
* @author <a href="mailto:[email protected]"> Michael Lloyd Lee </a>
|
|
||||||
* @author Be Inc
|
|
||||||
* @version 0
|
|
||||||
*/
|
|
||||||
class BStatable {
|
class BStatable {
|
||||||
public:
|
public:
|
||||||
virtual status_t GetStat(struct stat *st) const = 0;
|
virtual status_t GetStat(struct stat *st) const = 0;
|
||||||
|
|
||||||
bool IsFile() const;
|
bool IsFile() const;
|
||||||
bool IsDirectory() const;
|
bool IsDirectory() const;
|
||||||
bool IsSymLink() const;
|
bool IsSymLink() const;
|
||||||
|
|
||||||
status_t GetNodeRef(node_ref *ref) const;
|
status_t GetNodeRef(node_ref *ref) const;
|
||||||
|
|
||||||
status_t GetOwner(uid_t *owner) const;
|
status_t GetOwner(uid_t *owner) const;
|
||||||
status_t SetOwner(uid_t owner);
|
status_t SetOwner(uid_t owner);
|
||||||
|
|
||||||
status_t GetGroup(gid_t *group) const;
|
status_t GetGroup(gid_t *group) const;
|
||||||
status_t SetGroup(gid_t group);
|
status_t SetGroup(gid_t group);
|
||||||
|
|
||||||
status_t GetPermissions(mode_t *perms) const;
|
status_t GetPermissions(mode_t *perms) const;
|
||||||
status_t SetPermissions(mode_t perms);
|
status_t SetPermissions(mode_t perms);
|
||||||
|
|
||||||
status_t GetSize(off_t *size) const;
|
status_t GetSize(off_t *size) const;
|
||||||
|
|
||||||
status_t GetModificationTime(time_t *mtime) const;
|
status_t GetModificationTime(time_t *mtime) const;
|
||||||
status_t SetModificationTime(time_t mtime);
|
status_t SetModificationTime(time_t mtime);
|
||||||
|
|
||||||
status_t GetCreationTime(time_t *ctime) const;
|
status_t GetCreationTime(time_t *ctime) const;
|
||||||
status_t SetCreationTime(time_t ctime);
|
status_t SetCreationTime(time_t ctime);
|
||||||
|
|
||||||
status_t GetAccessTime(time_t *atime) const;
|
status_t GetAccessTime(time_t *atime) const;
|
||||||
status_t SetAccessTime(time_t atime);
|
status_t SetAccessTime(time_t atime);
|
||||||
|
|
||||||
status_t GetVolume(BVolume *vol) const;
|
status_t GetVolume(BVolume *vol) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class BEntry;
|
||||||
|
friend class BNode;
|
||||||
|
|
||||||
friend class BEntry;
|
virtual void _OhSoStatable1();
|
||||||
friend class BNode;
|
virtual void _OhSoStatable2();
|
||||||
|
virtual void _OhSoStatable3();
|
||||||
|
uint32 _reserved[4];
|
||||||
|
|
||||||
virtual void _OhSoStatable1(); //< FBC
|
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||||
virtual void _OhSoStatable2(); //< FBC
|
|
||||||
virtual void _OhSoStatable3(); //< FBC
|
|
||||||
uint32 _ohSoData[4]; //< FBC
|
|
||||||
|
|
||||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif // USE_OPENBEOS_NAMESPACE
|
|
||||||
|
|
||||||
#endif // _STATABLE_H
|
#endif // _STATABLE_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
//----------------------------------------------------------------------
|
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
|
||||||
// by the OpenBeOS license.
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file StorageDefs.Private.h
|
|
||||||
Private Storage Kit declarations needed in public headers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _DEF_STORAGE_PRIVATE_H
|
|
||||||
#define _DEF_STORAGE_PRIVATE_H
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
namespace Storage {
|
|
||||||
typedef int FileDescriptor;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _DEF_STORAGE_PRIVATE_H
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,22 +1,15 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
/*!
|
|
||||||
\file StorageDefs.h
|
|
||||||
Miscellaneous Storage Kit definitions and includes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _DEF_STORAGE_H
|
#ifndef _DEF_STORAGE_H
|
||||||
#define _DEF_STORAGE_H
|
#define _DEF_STORAGE_H
|
||||||
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
namespace OpenBeOS {
|
|
||||||
#endif // USE_OPENBEOS_NAMESPACE
|
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
#define B_DEV_NAME_LENGTH 128
|
#define B_DEV_NAME_LENGTH 128
|
||||||
@@ -24,20 +17,18 @@ namespace OpenBeOS {
|
|||||||
#define B_PATH_NAME_LENGTH MAXPATHLEN
|
#define B_PATH_NAME_LENGTH MAXPATHLEN
|
||||||
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
|
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
|
||||||
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
|
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
|
||||||
#define B_MAX_SYMLINKS SYMLINK_MAX
|
#define B_MAX_SYMLINKS SYMLOOP_MAX
|
||||||
|
|
||||||
|
|
||||||
// Open Modes
|
// Open Modes
|
||||||
#define B_READ_ONLY O_RDONLY // read only
|
#define B_READ_ONLY O_RDONLY // read only
|
||||||
#define B_WRITE_ONLY O_WRONLY // write only
|
#define B_WRITE_ONLY O_WRONLY // write only
|
||||||
#define B_READ_WRITE O_RDWR // read and write
|
#define B_READ_WRITE O_RDWR // read and write
|
||||||
|
|
||||||
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
|
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
|
||||||
#define B_CREATE_FILE O_CREAT // create the file
|
#define B_CREATE_FILE O_CREAT // create the file
|
||||||
#define B_ERASE_FILE O_TRUNC // erase the file's data
|
#define B_ERASE_FILE O_TRUNC // erase the file's data
|
||||||
#define B_OPEN_AT_END O_APPEND // point to the end of the data
|
#define B_OPEN_AT_END O_APPEND // point to the end of the data
|
||||||
|
|
||||||
|
|
||||||
// Node Flavors
|
// Node Flavors
|
||||||
enum node_flavor {
|
enum node_flavor {
|
||||||
B_FILE_NODE = 0x01,
|
B_FILE_NODE = 0x01,
|
||||||
@@ -46,13 +37,4 @@ enum node_flavor {
|
|||||||
B_ANY_NODE = 0x07
|
B_ANY_NODE = 0x07
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
}; // namespace OpenBeOS
|
|
||||||
#endif // USE_OPENBEOS_NAMESPACE
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _DEF_STORAGE_H
|
#endif // _DEF_STORAGE_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@
|
|||||||
#define SSIZE_MAX (2147483647L)
|
#define SSIZE_MAX (2147483647L)
|
||||||
#define TTY_NAME_MAX (256)
|
#define TTY_NAME_MAX (256)
|
||||||
#define TZNAME_MAX (32)
|
#define TZNAME_MAX (32)
|
||||||
#define SYMLINKS_MAX (16)
|
#define SYMLINK_MAX (1024)
|
||||||
|
#define SYMLOOP_MAX (16)
|
||||||
|
|
||||||
#define _POSIX_ARG_MAX (32768)
|
#define _POSIX_ARG_MAX (32768)
|
||||||
#define _POSIX_CHILD_MAX (1024)
|
#define _POSIX_CHILD_MAX (1024)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#define MAXPATHLEN PATH_MAX
|
#define MAXPATHLEN PATH_MAX
|
||||||
#define MAXSYMLINKS SYMLINKS_MAX
|
#define MAXSYMLINKS SYMLOOP_MAX
|
||||||
|
|
||||||
#define NOFILE OPEN_MAX
|
#define NOFILE OPEN_MAX
|
||||||
|
|
||||||
|
|||||||
+21
-19
@@ -1,11 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2006, Haiku Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _SYS_STAT_H_
|
#ifndef _SYS_STAT_H_
|
||||||
#define _SYS_STAT_H_
|
#define _SYS_STAT_H_
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* stat structure
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct stat {
|
struct stat {
|
||||||
dev_t st_dev; /* "device" that this file resides on */
|
dev_t st_dev; /* "device" that this file resides on */
|
||||||
@@ -22,8 +24,10 @@ struct stat {
|
|||||||
time_t st_ctime; /* last change time, not creation time */
|
time_t st_ctime; /* last change time, not creation time */
|
||||||
time_t st_crtime; /* creation time */
|
time_t st_crtime; /* creation time */
|
||||||
|
|
||||||
// OpenBeOS extensions:
|
// Haiku extensions:
|
||||||
// ToDo: we might also define special types for files and TTYs
|
// TODO: we might also define special types for files and TTYs
|
||||||
|
// TODO: we should find another solution for this, as BStatable::GetStat()
|
||||||
|
// can only retrieve the R5 stat structure
|
||||||
unsigned int st_type; /* attribute/index type */
|
unsigned int st_type; /* attribute/index type */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,13 +57,13 @@ struct stat {
|
|||||||
#define S_IFCHR 00000020000 /* character special */
|
#define S_IFCHR 00000020000 /* character special */
|
||||||
#define S_IFIFO 00000010000 /* fifo */
|
#define S_IFIFO 00000010000 /* fifo */
|
||||||
|
|
||||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
|
||||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
|
||||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
|
||||||
#define S_ISINDEX(m) (((m) & S_INDEX_DIR) == S_INDEX_DIR)
|
#define S_ISINDEX(mode) (((mode) & S_INDEX_DIR) == S_INDEX_DIR)
|
||||||
|
|
||||||
#define S_IUMSK 07777 /* user settable bits */
|
#define S_IUMSK 07777 /* user settable bits */
|
||||||
|
|
||||||
@@ -81,12 +85,10 @@ struct stat {
|
|||||||
#define S_IWOTH 00002 /* write permission: other */
|
#define S_IWOTH 00002 /* write permission: other */
|
||||||
#define S_IXOTH 00001 /* execute permission: other */
|
#define S_IXOTH 00001 /* execute permission: other */
|
||||||
|
|
||||||
/** @def ACCESSPERMS 00777 */
|
|
||||||
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO)
|
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO)
|
||||||
/** @def ALLPERMS 07777 */
|
#define ALLPERMS (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO)
|
||||||
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
|
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||||
/** @def DEFFILEMODE 00666 default file mode, everyone can read/write*/
|
/* default file mode, everyone can read/write */
|
||||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -102,7 +104,7 @@ extern int mkfifo(const char *path, mode_t mode);
|
|||||||
extern mode_t umask(mode_t cmask);
|
extern mode_t umask(mode_t cmask);
|
||||||
|
|
||||||
// This achieves backwards compatibility with R5
|
// This achieves backwards compatibility with R5
|
||||||
#if 0
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
#define stat(fd, st) _stat(fd, st, sizeof(struct stat))
|
#define stat(fd, st) _stat(fd, st, sizeof(struct stat))
|
||||||
#define fstat(fd, st) _fstat(fd, st, sizeof(struct stat))
|
#define fstat(fd, st) _fstat(fd, st, sizeof(struct stat))
|
||||||
#define lstat(fd, st) _lstat(fd, st, sizeof(struct stat))
|
#define lstat(fd, st) _lstat(fd, st, sizeof(struct stat))
|
||||||
@@ -117,4 +119,4 @@ extern int lstat(const char *path, struct stat *st);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SYS_STAT_H_ */
|
#endif /* _SYS_STAT_H_ */
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
// R5 compatibility
|
||||||
|
#define R5_STAT_SIZE 60
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
|
||||||
@@ -149,5 +153,3 @@ private:
|
|||||||
using BPrivate::Storage::FDCloser;
|
using BPrivate::Storage::FDCloser;
|
||||||
|
|
||||||
#endif // _STORAGE_SUPPORT_H
|
#endif // _STORAGE_SUPPORT_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+28
-29
@@ -1,18 +1,18 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the Haiku distribution and is covered
|
* Copyright 2002-2006, Haiku Inc.
|
||||||
// by the MIT license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*
|
||||||
|
* Authors:
|
||||||
|
* Tyler Dauwalder
|
||||||
|
* Ingo Weinhold, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file Entry.cpp
|
\file Entry.cpp
|
||||||
BEntry and entry_ref implementations.
|
BEntry and entry_ref implementations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <new>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
@@ -21,21 +21,17 @@
|
|||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
#include <fcntl.h>
|
||||||
using namespace OpenBeOS;
|
#include <new>
|
||||||
#endif
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace std;
|
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
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
// #pragma mark - struct entry_ref
|
||||||
// struct entry_ref
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \struct entry_ref
|
/*! \struct entry_ref
|
||||||
\brief A filesystem entry represented as a name in a concrete directory.
|
\brief A filesystem entry represented as a name in a concrete directory.
|
||||||
@@ -184,9 +180,8 @@ entry_ref::operator=(const entry_ref &ref)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
// #pragma mark - BEntry
|
||||||
// BEntry
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class BEntry
|
\class BEntry
|
||||||
@@ -219,9 +214,10 @@ entry_ref::operator=(const entry_ref &ref)
|
|||||||
- operator=(const BEntry&)
|
- operator=(const BEntry&)
|
||||||
*/
|
*/
|
||||||
BEntry::BEntry()
|
BEntry::BEntry()
|
||||||
: fDirFd(-1),
|
:
|
||||||
fName(NULL),
|
fDirFd(-1),
|
||||||
fCStatus(B_NO_INIT)
|
fName(NULL),
|
||||||
|
fCStatus(B_NO_INIT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,9 +318,10 @@ BEntry::Exists() const
|
|||||||
{
|
{
|
||||||
// just stat the beast
|
// just stat the beast
|
||||||
struct stat st;
|
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
|
/*! \brief Fills in a stat structure for the entry. The information is copied into
|
||||||
the \c stat structure pointed to by \a result.
|
the \c stat structure pointed to by \a result.
|
||||||
|
|
||||||
@@ -341,9 +338,11 @@ BEntry::GetStat(struct stat *result) const
|
|||||||
{
|
{
|
||||||
if (fCStatus != B_OK)
|
if (fCStatus != B_OK)
|
||||||
return B_NO_INIT;
|
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,
|
/*! \brief Reinitializes the BEntry to the path or directory path combination,
|
||||||
resolving symlinks if traverse is true
|
resolving symlinks if traverse is true
|
||||||
|
|
||||||
|
|||||||
+22
-17
@@ -1,34 +1,39 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the Haiku distribution and is covered
|
* Copyright 2002-2006, Haiku Inc.
|
||||||
// by the MIT license.
|
* Distributed under the terms of the MIT License.
|
||||||
//----------------------------------------------------------------------
|
*
|
||||||
|
* Authors:
|
||||||
|
* Tyler Dauwalder
|
||||||
|
* Ingo Weinhold, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file Node.cpp
|
\file Node.cpp
|
||||||
BNode implementation.
|
BNode implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include "storage_support.h"
|
||||||
#include <fcntl.h>
|
|
||||||
#include <fs_attr.h> // for struct attr_info
|
|
||||||
#include <new>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <fs_attr.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
#include <syscalls.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.
|
/*! \brief Creates an uninitialized node_ref object.
|
||||||
*/
|
*/
|
||||||
node_ref::node_ref()
|
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
|
/*! \brief Creates an uninitialized BNode object
|
||||||
@@ -196,7 +201,7 @@ BNode::GetStat(struct stat *st) const
|
|||||||
{
|
{
|
||||||
return fCStatus != B_OK
|
return fCStatus != B_OK
|
||||||
? fCStatus
|
? fCStatus
|
||||||
: _kern_read_stat(fFd, NULL, false, st, sizeof(struct stat));
|
: _kern_read_stat(fFd, NULL, false, st, R5_STAT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
* Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <syscalls.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +19,6 @@
|
|||||||
|
|
||||||
|
|
||||||
// R5 compatibility
|
// R5 compatibility
|
||||||
|
|
||||||
#define R5_STAT_SIZE 60
|
#define R5_STAT_SIZE 60
|
||||||
#undef stat
|
#undef stat
|
||||||
#undef fstat
|
#undef fstat
|
||||||
|
|||||||
Reference in New Issue
Block a user