本文整理汇总了C++中Volume::AllocateInode方法的典型用法代码示例。如果您正苦于以下问题:C++ Volume::AllocateInode方法的具体用法?C++ Volume::AllocateInode怎么用?C++ Volume::AllocateInode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Volume
的用法示例。
在下文中一共展示了Volume::AllocateInode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: htree
/*static*/ status_t
Inode::Create(Transaction& transaction, Inode* parent, const char* name,
int32 mode, int openMode, uint8 type, bool* _created, ino_t* _id,
Inode** _inode, fs_vnode_ops* vnodeOps, uint32 publishFlags)
{
TRACE("Inode::Create()\n");
Volume* volume = transaction.GetVolume();
DirectoryIterator* entries = NULL;
ObjectDeleter<DirectoryIterator> entriesDeleter;
if (parent != NULL) {
parent->WriteLockInTransaction(transaction);
TRACE("Inode::Create(): Looking up entry destination\n");
HTree htree(volume, parent);
status_t status = htree.Lookup(name, &entries);
if (status == B_ENTRY_NOT_FOUND) {
panic("We need to add the first node.\n");
return B_ERROR;
}
if (status != B_OK)
return status;
entriesDeleter.SetTo(entries);
TRACE("Inode::Create(): Looking up to see if file already exists\n");
ino_t entryID;
status = entries->FindEntry(name, &entryID);
if (status == B_OK) {
// File already exists
TRACE("Inode::Create(): File already exists\n");
if (S_ISDIR(mode) || S_ISLNK(mode) || (openMode & O_EXCL) != 0)
return B_FILE_EXISTS;
Vnode vnode(volume, entryID);
Inode* inode;
status = vnode.Get(&inode);
if (status != B_OK) {
TRACE("Inode::Create() Failed to get the inode from the "
"vnode\n");
return B_ENTRY_NOT_FOUND;
}
if (inode->IsDirectory() && (openMode & O_RWMASK) != O_RDONLY)
return B_IS_A_DIRECTORY;
if ((openMode & O_DIRECTORY) != 0 && !inode->IsDirectory())
return B_NOT_A_DIRECTORY;
if (inode->CheckPermissions(open_mode_to_access(openMode)
| ((openMode & O_TRUNC) != 0 ? W_OK : 0)) != B_OK)
return B_NOT_ALLOWED;
if ((openMode & O_TRUNC) != 0) {
// Truncate requested
TRACE("Inode::Create(): Truncating file\n");
inode->WriteLockInTransaction(transaction);
status = inode->Resize(transaction, 0);
if (status != B_OK)
return status;
}
if (_created != NULL)
*_created = false;
if (_id != NULL)
*_id = inode->ID();
if (_inode != NULL)
*_inode = inode;
if (_id != NULL || _inode != NULL)
vnode.Keep();
TRACE("Inode::Create(): Done opening file\n");
return B_OK;
/*} else if ((mode & S_ATTR_DIR) == 0) {
TRACE("Inode::Create(): (mode & S_ATTR_DIR) == 0\n");
return B_BAD_VALUE;*/
} else if ((openMode & O_DIRECTORY) != 0) {
TRACE("Inode::Create(): (openMode & O_DIRECTORY) != 0\n");
return B_ENTRY_NOT_FOUND;
}
// Return to initial position
TRACE("Inode::Create(): Restarting iterator\n");
entries->Restart();
}
status_t status;
if (parent != NULL) {
status = parent->CheckPermissions(W_OK);
if (status != B_OK)
return status;
}
TRACE("Inode::Create(): Allocating inode\n");
ino_t id;
status = volume->AllocateInode(transaction, parent, mode, id);
//.........这里部分代码省略.........