* 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:
parent
dbd51bbab9
commit
7b3d36e5aa
headers
os/storage
posix
private/storage
src
@ -1,114 +1,84 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Directory.h
|
||||
BDirectory interface declaration.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DIRECTORY_H
|
||||
#define _DIRECTORY_H
|
||||
|
||||
|
||||
#include <Node.h>
|
||||
#include <EntryList.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
class BSymLink;
|
||||
|
||||
/*!
|
||||
\class BDirectory
|
||||
\brief A directory in the filesystem
|
||||
|
||||
Provides an interface for manipulating directories and their contents.
|
||||
|
||||
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
|
||||
\author <a href="mailto:tylerdauwalder@users.sf.net">Tyler Dauwalder</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BDirectory : public BNode, public BEntryList {
|
||||
public:
|
||||
BDirectory();
|
||||
BDirectory(const BDirectory &dir);
|
||||
BDirectory(const entry_ref *ref);
|
||||
BDirectory(const node_ref *nref);
|
||||
BDirectory(const BEntry *entry);
|
||||
BDirectory(const char *path);
|
||||
BDirectory(const BDirectory *dir, const char *path);
|
||||
public:
|
||||
BDirectory();
|
||||
BDirectory(const BDirectory &dir);
|
||||
BDirectory(const entry_ref *ref);
|
||||
BDirectory(const node_ref *nref);
|
||||
BDirectory(const BEntry *entry);
|
||||
BDirectory(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 node_ref *nref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const node_ref *nref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(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,
|
||||
bool traverse = false) const;
|
||||
status_t FindEntry(const char *path, BEntry *entry,
|
||||
bool traverse = false) 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 char *path, 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 GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||
virtual status_t GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||
status_t CreateFile(const char *path, BFile *file,
|
||||
bool failIfExists = false);
|
||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||
BSymLink *link);
|
||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||
status_t CreateFile(const char *path, BFile *file,
|
||||
bool failIfExists = false);
|
||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||
BSymLink *link);
|
||||
|
||||
BDirectory &operator=(const BDirectory &dir);
|
||||
BDirectory &operator=(const BDirectory &dir);
|
||||
|
||||
private:
|
||||
friend class BNode;
|
||||
private:
|
||||
friend class BNode;
|
||||
friend class BEntry;
|
||||
friend class BFile;
|
||||
|
||||
virtual void _ErectorDirectory1();
|
||||
virtual void _ErectorDirectory2();
|
||||
virtual void _ErectorDirectory3();
|
||||
virtual void _ErectorDirectory4();
|
||||
virtual void _ErectorDirectory5();
|
||||
virtual void _ErectorDirectory6();
|
||||
virtual void _ErectorDirectory1();
|
||||
virtual void _ErectorDirectory2();
|
||||
virtual void _ErectorDirectory3();
|
||||
virtual void _ErectorDirectory4();
|
||||
virtual void _ErectorDirectory5();
|
||||
virtual void _ErectorDirectory6();
|
||||
|
||||
private:
|
||||
virtual void close_fd();
|
||||
int get_fd() const;
|
||||
private:
|
||||
virtual void close_fd();
|
||||
int get_fd() const;
|
||||
|
||||
private:
|
||||
uint32 _reservedData[7];
|
||||
int fDirFd;
|
||||
|
||||
friend class BEntry;
|
||||
friend class BFile;
|
||||
private:
|
||||
uint32 _reservedData[7];
|
||||
int fDirFd;
|
||||
};
|
||||
|
||||
|
||||
// C functions
|
||||
|
||||
status_t create_directory(const char *path, mode_t mode);
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // _DIRECTORY_H
|
||||
|
||||
|
||||
|
@ -1,89 +1,63 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file File.h
|
||||
BFile interface declaration.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FILE_H
|
||||
#define _FILE_H
|
||||
|
||||
|
||||
#include <DataIO.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:bonefish@users.sf.net'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BFile : public BNode, public BPositionIO {
|
||||
public:
|
||||
BFile();
|
||||
BFile(const BFile &file);
|
||||
BFile(const entry_ref *ref, uint32 openMode);
|
||||
BFile(const BEntry *entry, uint32 openMode);
|
||||
BFile(const char *path, uint32 openMode);
|
||||
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
virtual ~BFile();
|
||||
public:
|
||||
BFile();
|
||||
BFile(const BFile &file);
|
||||
BFile(const entry_ref *ref, uint32 openMode);
|
||||
BFile(const BEntry *entry, uint32 openMode);
|
||||
BFile(const char *path, uint32 openMode);
|
||||
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
virtual ~BFile();
|
||||
|
||||
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
||||
status_t SetTo(const BEntry *entry, 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 entry_ref *ref, uint32 openMode);
|
||||
status_t SetTo(const BEntry *entry, uint32 openMode);
|
||||
status_t SetTo(const char *path, uint32 openMode);
|
||||
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
|
||||
bool IsReadable() const;
|
||||
bool IsWritable() const;
|
||||
bool IsReadable() const;
|
||||
bool IsWritable() const;
|
||||
|
||||
virtual ssize_t Read(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 WriteAt(off_t location, const 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 Write(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 Position() const;
|
||||
virtual off_t Seek(off_t offset, uint32 seekMode);
|
||||
virtual off_t Position() const;
|
||||
|
||||
virtual status_t SetSize(off_t size);
|
||||
virtual status_t GetSize(off_t* size) const;
|
||||
virtual status_t SetSize(off_t size);
|
||||
virtual status_t GetSize(off_t* size) const;
|
||||
|
||||
BFile &operator=(const BFile &file);
|
||||
BFile &operator=(const BFile &file);
|
||||
|
||||
private:
|
||||
virtual void _PhiloFile1();
|
||||
virtual void _PhiloFile2();
|
||||
virtual void _PhiloFile3();
|
||||
virtual void _PhiloFile4();
|
||||
virtual void _PhiloFile5();
|
||||
virtual void _PhiloFile6();
|
||||
private:
|
||||
virtual void _PhiloFile1();
|
||||
virtual void _PhiloFile2();
|
||||
virtual void _PhiloFile3();
|
||||
virtual void _PhiloFile4();
|
||||
virtual void _PhiloFile5();
|
||||
virtual void _PhiloFile6();
|
||||
|
||||
uint32 _reservedData[8];
|
||||
uint32 _reservedData[8];
|
||||
|
||||
private:
|
||||
int get_fd() const;
|
||||
virtual void close_fd();
|
||||
private:
|
||||
int get_fd() const;
|
||||
virtual void close_fd();
|
||||
|
||||
private:
|
||||
//! The file's open mode.
|
||||
uint32 fMode;
|
||||
private:
|
||||
//! The file's open mode.
|
||||
uint32 fMode;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // _FILE_H
|
||||
|
||||
|
||||
|
@ -1,85 +1,62 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Statable.h
|
||||
BStatable interface declaration.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _STATABLE_H
|
||||
#define _STATABLE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
struct node_ref;
|
||||
class BVolume;
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
struct node_ref;
|
||||
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:mrmlk@users.sf.net"> Michael Lloyd Lee </a>
|
||||
* @author Be Inc
|
||||
* @version 0
|
||||
*/
|
||||
class BStatable {
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) const = 0;
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) const = 0;
|
||||
|
||||
bool IsFile() const;
|
||||
bool IsDirectory() const;
|
||||
bool IsSymLink() const;
|
||||
bool IsFile() const;
|
||||
bool IsDirectory() 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 SetOwner(uid_t owner);
|
||||
status_t GetOwner(uid_t *owner) const;
|
||||
status_t SetOwner(uid_t owner);
|
||||
|
||||
status_t GetGroup(gid_t *group) const;
|
||||
status_t SetGroup(gid_t group);
|
||||
status_t GetGroup(gid_t *group) const;
|
||||
status_t SetGroup(gid_t group);
|
||||
|
||||
status_t GetPermissions(mode_t *perms) const;
|
||||
status_t SetPermissions(mode_t perms);
|
||||
status_t GetPermissions(mode_t *perms) const;
|
||||
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 SetModificationTime(time_t mtime);
|
||||
status_t GetModificationTime(time_t *mtime) const;
|
||||
status_t SetModificationTime(time_t mtime);
|
||||
|
||||
status_t GetCreationTime(time_t *ctime) const;
|
||||
status_t SetCreationTime(time_t ctime);
|
||||
status_t GetCreationTime(time_t *ctime) const;
|
||||
status_t SetCreationTime(time_t ctime);
|
||||
|
||||
status_t GetAccessTime(time_t *atime) const;
|
||||
status_t SetAccessTime(time_t atime);
|
||||
status_t GetAccessTime(time_t *atime) const;
|
||||
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;
|
||||
friend class BNode;
|
||||
virtual void _OhSoStatable1();
|
||||
virtual void _OhSoStatable2();
|
||||
virtual void _OhSoStatable3();
|
||||
uint32 _reserved[4];
|
||||
|
||||
virtual void _OhSoStatable1(); //< FBC
|
||||
virtual void _OhSoStatable2(); //< FBC
|
||||
virtual void _OhSoStatable3(); //< FBC
|
||||
uint32 _ohSoData[4]; //< FBC
|
||||
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
#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
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file StorageDefs.h
|
||||
Miscellaneous Storage Kit definitions and includes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DEF_STORAGE_H
|
||||
#define _DEF_STORAGE_H
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
// Limits
|
||||
#define B_DEV_NAME_LENGTH 128
|
||||
@ -24,20 +17,18 @@ namespace OpenBeOS {
|
||||
#define B_PATH_NAME_LENGTH MAXPATHLEN
|
||||
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
|
||||
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
|
||||
#define B_MAX_SYMLINKS SYMLINK_MAX
|
||||
|
||||
#define B_MAX_SYMLINKS SYMLOOP_MAX
|
||||
|
||||
// Open Modes
|
||||
#define B_READ_ONLY O_RDONLY // read only
|
||||
#define B_WRITE_ONLY O_WRONLY // write only
|
||||
#define B_READ_WRITE O_RDWR // read and write
|
||||
#define B_READ_ONLY O_RDONLY // read only
|
||||
#define B_WRITE_ONLY O_WRONLY // write only
|
||||
#define B_READ_WRITE O_RDWR // read and write
|
||||
|
||||
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
|
||||
#define B_CREATE_FILE O_CREAT // create the file
|
||||
#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
|
||||
|
||||
|
||||
// Node Flavors
|
||||
enum node_flavor {
|
||||
B_FILE_NODE = 0x01,
|
||||
@ -46,13 +37,4 @@ enum node_flavor {
|
||||
B_ANY_NODE = 0x07
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
|
||||
#endif // _DEF_STORAGE_H
|
||||
|
||||
|
||||
|
@ -41,7 +41,8 @@
|
||||
#define SSIZE_MAX (2147483647L)
|
||||
#define TTY_NAME_MAX (256)
|
||||
#define TZNAME_MAX (32)
|
||||
#define SYMLINKS_MAX (16)
|
||||
#define SYMLINK_MAX (1024)
|
||||
#define SYMLOOP_MAX (16)
|
||||
|
||||
#define _POSIX_ARG_MAX (32768)
|
||||
#define _POSIX_CHILD_MAX (1024)
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define MAXSYMLINKS SYMLINKS_MAX
|
||||
#define MAXSYMLINKS SYMLOOP_MAX
|
||||
|
||||
#define NOFILE OPEN_MAX
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SYS_STAT_H_
|
||||
#define _SYS_STAT_H_
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* stat structure
|
||||
*/
|
||||
|
||||
struct stat {
|
||||
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_crtime; /* creation time */
|
||||
|
||||
// OpenBeOS extensions:
|
||||
// ToDo: we might also define special types for files and TTYs
|
||||
// Haiku extensions:
|
||||
// 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 */
|
||||
};
|
||||
|
||||
@ -53,13 +57,13 @@ struct stat {
|
||||
#define S_IFCHR 00000020000 /* character special */
|
||||
#define S_IFIFO 00000010000 /* fifo */
|
||||
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISINDEX(m) (((m) & S_INDEX_DIR) == S_INDEX_DIR)
|
||||
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISINDEX(mode) (((mode) & S_INDEX_DIR) == S_INDEX_DIR)
|
||||
|
||||
#define S_IUMSK 07777 /* user settable bits */
|
||||
|
||||
@ -81,12 +85,10 @@ struct stat {
|
||||
#define S_IWOTH 00002 /* write permission: other */
|
||||
#define S_IXOTH 00001 /* execute permission: other */
|
||||
|
||||
/** @def ACCESSPERMS 00777 */
|
||||
#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)
|
||||
/** @def DEFFILEMODE 00666 default file mode, everyone can read/write*/
|
||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
||||
#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)
|
||||
/* default file mode, everyone can read/write */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -102,7 +104,7 @@ extern int mkfifo(const char *path, mode_t mode);
|
||||
extern mode_t umask(mode_t cmask);
|
||||
|
||||
// This achieves backwards compatibility with R5
|
||||
#if 0
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
#define stat(fd, st) _stat(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))
|
||||
@ -117,4 +119,4 @@ extern int lstat(const char *path, struct stat *st);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_STAT_H_ */
|
||||
#endif /* _SYS_STAT_H_ */
|
||||
|
@ -21,6 +21,10 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
// R5 compatibility
|
||||
#define R5_STAT_SIZE 60
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
|
||||
@ -149,5 +153,3 @@ private:
|
||||
using BPrivate::Storage::FDCloser;
|
||||
|
||||
#endif // _STORAGE_SUPPORT_H
|
||||
|
||||
|
||||
|
@ -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, bonefish@users.sf.net
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user