1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include "Node.h" 8 9#include <stdlib.h> 10#include <string.h> 11 12#include "DebugSupport.h" 13#include "EmptyAttributeDirectoryCookie.h" 14 15 16Node::Node(ino_t id) 17 : 18 fID(id), 19 fParent(NULL), 20 fName(NULL), 21 fFlags(0) 22{ 23 rw_lock_init(&fLock, "packagefs node"); 24} 25 26 27Node::~Node() 28{ 29 if ((fFlags & NODE_FLAG_OWNS_NAME) != 0) 30 free(fName); 31 32 rw_lock_destroy(&fLock); 33} 34 35 36status_t 37Node::Init(Directory* parent, const char* name, uint32 flags) 38{ 39 fParent = parent; 40 fFlags = flags; 41 42 if ((flags & NODE_FLAG_CONST_NAME) != 0 43 || (flags & NODE_FLAG_KEEP_NAME) != 0) { 44 fName = const_cast<char*>(name); 45 } else { 46 fName = strdup(name); 47 if (fName == NULL) 48 RETURN_ERROR(B_NO_MEMORY); 49 fFlags |= NODE_FLAG_OWNS_NAME; 50 } 51 52 return B_OK; 53} 54 55 56status_t 57Node::VFSInit(dev_t deviceID) 58{ 59 fFlags |= NODE_FLAG_KNOWN_TO_VFS; 60 return B_OK; 61} 62 63 64void 65Node::VFSUninit() 66{ 67 fFlags &= ~(uint32)NODE_FLAG_KNOWN_TO_VFS; 68} 69 70 71void 72Node::SetID(ino_t id) 73{ 74 fID = id; 75} 76 77 78void 79Node::SetParent(Directory* parent) 80{ 81 fParent = parent; 82} 83 84 85uid_t 86Node::UserID() const 87{ 88 return 0; 89} 90 91 92gid_t 93Node::GroupID() const 94{ 95 return 0; 96} 97 98 99status_t 100Node::OpenAttributeDirectory(AttributeDirectoryCookie*& _cookie) 101{ 102 AttributeDirectoryCookie* cookie 103 = new(std::nothrow) EmptyAttributeDirectoryCookie; 104 if (cookie == NULL) 105 return B_NO_MEMORY; 106 107 _cookie = cookie; 108 return B_OK; 109} 110 111 112status_t 113Node::OpenAttribute(const char* name, int openMode, AttributeCookie*& _cookie) 114{ 115 return B_ENTRY_NOT_FOUND; 116} 117 118 119status_t 120Node::IndexAttribute(AttributeIndexer* indexer) 121{ 122 return B_NOT_SUPPORTED; 123} 124 125 126void* 127Node::IndexCookieForAttribute(const char* name) const 128{ 129 return NULL; 130} 131