status_t Inode::OpenAttr(const char* _name, int mode, OpenAttrCookie* cookie, bool create, int32 type) { ASSERT(_name != NULL); ASSERT(cookie != NULL); (void)type; status_t result = LoadAttrDirHandle(); if (result != B_OK) return result; char* name = AttrToFileName(_name); if (name == NULL) return B_NO_MEMORY; MemoryDeleter nameDeleter(name); OpenDelegationData data; data.fType = OPEN_DELEGATE_NONE; OpenState* state = new OpenState; if (state == NULL) return B_NO_MEMORY; state->fFileSystem = fFileSystem; result = NFS4Inode::OpenAttr(state, name, mode, &data, create); if (result != B_OK) { delete state; return result; } fFileSystem->AddOpenFile(state); cookie->fOpenState = state; cookie->fFileSystem = fFileSystem; cookie->fMode = mode; if (data.fType != OPEN_DELEGATE_NONE) { Delegation* delegation = new(std::nothrow) Delegation(data, this, state->fClientID, true); if (delegation != NULL) { delegation->fInfo = state->fInfo; delegation->fFileSystem = fFileSystem; state->fDelegation = delegation; fFileSystem->AddDelegation(delegation); } } if (create || (mode & O_TRUNC) == O_TRUNC) { struct stat st; st.st_size = 0; WriteStat(&st, B_STAT_SIZE, cookie); } return B_OK; }
status_t Inode::OpenAttrDir(OpenDirCookie* cookie) { ASSERT(cookie != NULL); cookie->fSpecial = 0; cookie->fSnapshot = NULL; cookie->fCurrent = NULL; cookie->fEOF = false; cookie->fAttrDir = true; return LoadAttrDirHandle(); }