* Style cleanup, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38430 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-29 21:25:12 +00:00
parent 977f0426ee
commit 001d7548ab
@@ -1,11 +1,12 @@
/* /*
* Copyright 2009, Haiku Inc. All rights reserved. * Copyright 2009-2010, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Michael Lotz <[email protected]> * Michael Lotz <[email protected]>
*/ */
#include <new> #include <new>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -24,16 +25,35 @@
//#define TRACE_OVERLAY //#define TRACE_OVERLAY
#ifdef TRACE_OVERLAY #ifdef TRACE_OVERLAY
#define TRACE(x...) dprintf("attribute_overlay: " x) # define TRACE(x...) dprintf("attribute_overlay: " x)
#define TRACE_VOLUME(x...) dprintf("attribute_overlay: " x) # define TRACE_VOLUME(x...) dprintf("attribute_overlay: " x)
#define TRACE_ALWAYS(x...) dprintf("attribute_overlay: " x) # define TRACE_ALWAYS(x...) dprintf("attribute_overlay: " x)
#else #else
#define TRACE(x...) /* nothing */ # define TRACE(x...) /* nothing */
#define TRACE_VOLUME(x...) /* nothing */ # define TRACE_VOLUME(x...) /* nothing */
#define TRACE_ALWAYS(x...) dprintf("attribute_overlay: " x) # define TRACE_ALWAYS(x...) dprintf("attribute_overlay: " x)
#endif #endif
#define ATTRIBUTE_OVERLAY_FILE_MAGIC 'attr'
#define ATTRIBUTE_OVERLAY_ATTRIBUTE_DIR_NAME "_HAIKU"
#define OVERLAY_CALL(op, params...) \
TRACE("relaying op: " #op "\n"); \
OverlayInode *node = (OverlayInode *)vnode->private_node; \
fs_vnode *superVnode = node->SuperVnode(); \
if (superVnode->ops->op != NULL) \
return superVnode->ops->op(volume->super_volume, superVnode, params); \
return B_UNSUPPORTED;
#define OVERLAY_VOLUME_CALL(op, params...) \
TRACE_VOLUME("relaying volume op: " #op "\n"); \
if (volume->super_volume->ops->op != NULL) \
return volume->super_volume->ops->op(volume->super_volume, params);
namespace attribute_overlay { namespace attribute_overlay {
class AttributeFile; class AttributeFile;
@@ -86,8 +106,8 @@ private:
class AttributeFile { class AttributeFile {
public: public:
AttributeFile(fs_volume *overlay, fs_volume *volume, AttributeFile(fs_volume *overlay,
fs_vnode *vnode); fs_volume *volume, fs_vnode *vnode);
~AttributeFile(); ~AttributeFile();
status_t InitCheck() { return fStatus; } status_t InitCheck() { return fStatus; }
@@ -118,11 +138,9 @@ public:
status_t AddAttribute(AttributeEntry *entry); status_t AddAttribute(AttributeEntry *entry);
private: private:
#define ATTRIBUTE_OVERLAY_FILE_MAGIC 'attr'
#define ATTRIBUTE_OVERLAY_ATTRIBUTE_DIR_NAME "_HAIKU"
struct attribute_file { struct attribute_file {
uint32 magic; // 'attr' uint32 magic;
// ATTRIBUTE_OVERLAY_FILE_MAGIC
uint32 entry_count; uint32 entry_count;
uint8 entries[1]; uint8 entries[1];
} _PACKED; } _PACKED;
@@ -167,12 +185,14 @@ public:
status_t FillDirent(struct dirent *dirent, status_t FillDirent(struct dirent *dirent,
size_t bufferSize, uint32 *numEntries); size_t bufferSize, uint32 *numEntries);
status_t Read(off_t position, void *buffer, size_t *length); status_t Read(off_t position, void *buffer,
size_t *length);
status_t Write(off_t position, const void *buffer, status_t Write(off_t position, const void *buffer,
size_t *length); size_t *length);
status_t ReadStat(struct stat *stat); status_t ReadStat(struct stat *stat);
status_t WriteStat(const struct stat *stat, uint32 statMask); status_t WriteStat(const struct stat *stat,
uint32 statMask);
private: private:
struct attribute_entry { struct attribute_entry {
@@ -195,7 +215,8 @@ private:
OverlayVolume::OverlayVolume(fs_volume *volume) OverlayVolume::OverlayVolume(fs_volume *volume)
: fVolume(volume) :
fVolume(volume)
{ {
} }
@@ -210,7 +231,8 @@ OverlayVolume::~OverlayVolume()
OverlayInode::OverlayInode(OverlayVolume *volume, fs_vnode *superVnode, OverlayInode::OverlayInode(OverlayVolume *volume, fs_vnode *superVnode,
ino_t inodeNumber) ino_t inodeNumber)
: fVolume(volume), :
fVolume(volume),
fSuperVnode(*superVnode), fSuperVnode(*superVnode),
fInodeNumber(inodeNumber), fInodeNumber(inodeNumber),
fAttributeFile(NULL) fAttributeFile(NULL)
@@ -297,7 +319,8 @@ OverlayInode::RemoveAttributeFile()
AttributeFile::AttributeFile(fs_volume *overlay, fs_volume *volume, AttributeFile::AttributeFile(fs_volume *overlay, fs_volume *volume,
fs_vnode *vnode) fs_vnode *vnode)
: fStatus(B_NO_INIT), :
fStatus(B_NO_INIT),
fVolumeID(volume->id), fVolumeID(volume->id),
fFileInode(0), fFileInode(0),
fDirectoryInode(0), fDirectoryInode(0),
@@ -604,16 +627,18 @@ AttributeFile::WriteAttributeFile(fs_volume *overlay, fs_volume *volume,
return result; return result;
} }
result = get_vnode(overlay, fAttributeFileInode, (void **)&overlayInode); result = get_vnode(overlay, fAttributeFileInode,
(void **)&overlayInode);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("getting attribute file vnode after create failed: %s\n", TRACE_ALWAYS("getting attribute file vnode after create failed: "
strerror(result)); "%s\n", strerror(result));
return result; return result;
} }
currentVnode = *overlayInode->SuperVnode(); currentVnode = *overlayInode->SuperVnode();
} else { } else {
result = get_vnode(overlay, fAttributeFileInode, (void **)&overlayInode); result = get_vnode(overlay, fAttributeFileInode,
(void **)&overlayInode);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("getting attribute file vnode failed: %s\n", TRACE_ALWAYS("getting attribute file vnode failed: %s\n",
strerror(result)); strerror(result));
@@ -741,7 +766,8 @@ AttributeEntry *
AttributeFile::FindAttribute(const char *name, uint32 *index) AttributeFile::FindAttribute(const char *name, uint32 *index)
{ {
for (uint32 i = 0; i < fFile->entry_count; i++) { for (uint32 i = 0; i < fFile->entry_count; i++) {
if (strncmp(fEntries[i]->Name(), name, fEntries[i]->NameLength()) == 0) { if (strncmp(fEntries[i]->Name(), name, fEntries[i]->NameLength())
== 0) {
if (index) if (index)
*index = i; *index = i;
@@ -759,7 +785,7 @@ AttributeFile::CreateAttribute(const char *name, type_code type, int openMode,
{ {
AttributeEntry *existing = FindAttribute(name); AttributeEntry *existing = FindAttribute(name);
if (existing != NULL) { if (existing != NULL) {
if (openMode & O_TRUNC) if ((openMode & O_TRUNC) != 0)
existing->SetSize(0); existing->SetSize(0);
// attribute already exists, only allow if the attribute type is // attribute already exists, only allow if the attribute type is
@@ -875,7 +901,8 @@ AttributeFile::ReadAttributeDir(struct dirent *dirent, size_t bufferSize,
AttributeEntry::AttributeEntry(AttributeFile *parent, uint8 *buffer) AttributeEntry::AttributeEntry(AttributeFile *parent, uint8 *buffer)
: fParent(parent), :
fParent(parent),
fEntry(NULL), fEntry(NULL),
fData(NULL), fData(NULL),
fStatus(B_NO_INIT), fStatus(B_NO_INIT),
@@ -893,7 +920,8 @@ AttributeEntry::AttributeEntry(AttributeFile *parent, uint8 *buffer)
AttributeEntry::AttributeEntry(AttributeFile *parent, const char *name, AttributeEntry::AttributeEntry(AttributeFile *parent, const char *name,
type_code type) type_code type)
: fParent(parent), :
fParent(parent),
fEntry(NULL), fEntry(NULL),
fData(NULL), fData(NULL),
fStatus(B_NO_INIT), fStatus(B_NO_INIT),
@@ -1075,15 +1103,6 @@ AttributeEntry::WriteStat(const struct stat *stat, uint32 statMask)
// #pragma mark - vnode ops // #pragma mark - vnode ops
#define OVERLAY_CALL(op, params...) \
TRACE("relaying op: " #op "\n"); \
OverlayInode *node = (OverlayInode *)vnode->private_node; \
fs_vnode *superVnode = node->SuperVnode(); \
if (superVnode->ops->op != NULL) \
return superVnode->ops->op(volume->super_volume, superVnode, params); \
return B_UNSUPPORTED;
static status_t static status_t
overlay_put_vnode(fs_volume *volume, fs_vnode *vnode, bool reenter) overlay_put_vnode(fs_volume *volume, fs_vnode *vnode, bool reenter)
{ {
@@ -1624,7 +1643,8 @@ overlay_create_special_node(fs_volume *volume, fs_vnode *vnode,
const char *name, fs_vnode *subVnode, mode_t mode, uint32 flags, const char *name, fs_vnode *subVnode, mode_t mode, uint32 flags,
fs_vnode *_superVnode, ino_t *nodeID) fs_vnode *_superVnode, ino_t *nodeID)
{ {
OVERLAY_CALL(create_special_node, name, subVnode, mode, flags, _superVnode, nodeID) OVERLAY_CALL(create_special_node, name, subVnode, mode, flags, _superVnode,
nodeID)
} }
@@ -1707,12 +1727,6 @@ static fs_vnode_ops sOverlayVnodeOps = {
// #pragma mark - volume ops // #pragma mark - volume ops
#define OVERLAY_VOLUME_CALL(op, params...) \
TRACE_VOLUME("relaying volume op: " #op "\n"); \
if (volume->super_volume->ops->op != NULL) \
return volume->super_volume->ops->op(volume->super_volume, params);
static status_t static status_t
overlay_unmount(fs_volume *volume) overlay_unmount(fs_volume *volume)
{ {
@@ -2004,7 +2018,7 @@ overlay_std_ops(int32 op, ...)
static file_system_module_info sOverlayFileSystem = { static file_system_module_info sOverlayFileSystem = {
{ {
"file_systems/attribute_overlay"B_CURRENT_FS_API_VERSION, "file_systems/attribute_overlay" B_CURRENT_FS_API_VERSION,
0, 0,
overlay_std_ops, overlay_std_ops,
}, },