本文整理汇总了C++中Inode::ID方法的典型用法代码示例。如果您正苦于以下问题:C++ Inode::ID方法的具体用法?C++ Inode::ID怎么用?C++ Inode::ID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inode
的用法示例。
在下文中一共展示了Inode::ID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transaction
static status_t
ext2_unlink(fs_volume* _volume, fs_vnode* _directory, const char* name)
{
TRACE("ext2_unlink()\n");
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
return B_NOT_ALLOWED;
Volume* volume = (Volume*)_volume->private_volume;
Inode* directory = (Inode*)_directory->private_node;
status_t status = directory->CheckPermissions(W_OK);
if (status != B_OK)
return status;
TRACE("ext2_unlink(): Starting transaction\n");
Transaction transaction(volume->GetJournal());
directory->WriteLockInTransaction(transaction);
TRACE("ext2_unlink(): Looking up for directory entry\n");
HTree htree(volume, directory);
DirectoryIterator* directoryIterator;
status = htree.Lookup(name, &directoryIterator);
if (status != B_OK)
return status;
ino_t id;
status = directoryIterator->FindEntry(name, &id);
if (status != B_OK)
return status;
Vnode vnode(volume, id);
Inode* inode;
status = vnode.Get(&inode);
if (status != B_OK)
return status;
inode->WriteLockInTransaction(transaction);
status = inode->Unlink(transaction);
if (status != B_OK)
return status;
status = directoryIterator->RemoveEntry(transaction);
if (status != B_OK)
return status;
entry_cache_remove(volume->ID(), directory->ID(), name);
status = transaction.Done();
if (status != B_OK)
entry_cache_add(volume->ID(), directory->ID(), name, id);
else
notify_entry_removed(volume->ID(), directory->ID(), name, id);
return status;
}
示例2:
static status_t
btrfs_read_stat(fs_volume* _volume, fs_vnode* _node, struct stat* stat)
{
Inode* inode = (Inode*)_node->private_node;
stat->st_dev = inode->GetVolume()->ID();
stat->st_ino = inode->ID();
stat->st_nlink = 1;
stat->st_blksize = BTRFS_IO_SIZE;
stat->st_uid = inode->UserID();
stat->st_gid = inode->GroupID();
stat->st_mode = inode->Mode();
stat->st_type = 0;
inode->GetAccessTime(stat->st_atim);
inode->GetModificationTime(stat->st_mtim);
inode->GetChangeTime(stat->st_ctim);
inode->GetCreationTime(stat->st_crtim);
stat->st_size = inode->Size();
stat->st_blocks = (inode->Size() + 511) / 512;
return B_OK;
}
示例3:
static status_t
ext2_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset,
size_t size, struct file_io_vec* vecs, size_t* _count)
{
TRACE("ext2_get_file_map()\n");
Volume* volume = (Volume*)_volume->private_volume;
Inode* inode = (Inode*)_node->private_node;
size_t index = 0, max = *_count;
while (true) {
fsblock_t block;
uint32 count = 1;
status_t status = inode->FindBlock(offset, block, &count);
if (status != B_OK)
return status;
if (block > volume->NumBlocks()) {
panic("ext2_get_file_map() found block %" B_PRIu64 " for offset %"
B_PRIdOFF "\n", block, offset);
}
off_t blockOffset = block << volume->BlockShift();
uint32 blockLength = volume->BlockSize() * count;
if (index > 0 && (vecs[index - 1].offset
== blockOffset - vecs[index - 1].length
|| (vecs[index - 1].offset == -1 && block == 0))) {
vecs[index - 1].length += blockLength;
} else {
if (index >= max) {
// we're out of file_io_vecs; let's bail out
*_count = index;
return B_BUFFER_OVERFLOW;
}
// 'block' is 0 for sparse blocks
if (block != 0)
vecs[index].offset = blockOffset;
else
vecs[index].offset = -1;
vecs[index].length = blockLength;
index++;
}
offset += blockLength;
if (offset >= inode->Size() || size <= blockLength) {
// We're done!
*_count = index;
TRACE("ext2_get_file_map for inode %" B_PRIdINO "\n", inode->ID());
return B_OK;
}
size -= blockLength;
}
// can never get here
return B_ERROR;
}
示例4: attribute
static status_t
ext2_read_attr_dir(fs_volume* _volume, fs_vnode* _node,
void* _cookie, struct dirent* dirent, size_t bufferSize,
uint32* _num)
{
Inode* inode = (Inode*)_node->private_node;
int32 index = *(int32 *)_cookie;
Attribute attribute(inode);
TRACE("%s()\n", __FUNCTION__);
size_t length = bufferSize;
status_t status = attribute.Find(index);
if (status == B_ENTRY_NOT_FOUND) {
*_num = 0;
return B_OK;
} else if (status != B_OK)
return status;
status = attribute.GetName(dirent->d_name, &length);
if (status != B_OK)
return B_OK;
Volume* volume = (Volume*)_volume->private_volume;
dirent->d_dev = volume->ID();
dirent->d_ino = inode->ID();
dirent->d_reclen = sizeof(struct dirent) + length;
*_num = 1;
*(int32*)_cookie = index + 1;
return B_OK;
}
示例5: lock
static status_t
ext2_write(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
const void* buffer, size_t* _length)
{
TRACE("ext2_write()\n");
Volume* volume = (Volume*)_volume->private_volume;
Inode* inode = (Inode*)_node->private_node;
if (volume->IsReadOnly())
return B_READ_ONLY_DEVICE;
if (inode->IsDirectory()) {
*_length = 0;
return B_IS_A_DIRECTORY;
}
TRACE("ext2_write(): Preparing cookie\n");
file_cookie* cookie = (file_cookie*)_cookie;
if ((cookie->open_mode & O_APPEND) != 0)
pos = inode->Size();
TRACE("ext2_write(): Creating transaction\n");
Transaction transaction;
status_t status = inode->WriteAt(transaction, pos, (const uint8*)buffer,
_length);
if (status == B_OK)
status = transaction.Done();
if (status == B_OK) {
TRACE("ext2_write(): Finalizing\n");
ReadLocker lock(*inode->Lock());
if (cookie->last_size != inode->Size()
&& system_time() > cookie->last_notification
+ INODE_NOTIFICATION_INTERVAL) {
notify_stat_changed(volume->ID(), -1, inode->ID(),
B_STAT_MODIFICATION_TIME | B_STAT_SIZE | B_STAT_INTERIM_UPDATE);
cookie->last_size = inode->Size();
cookie->last_notification = system_time();
}
}
TRACE("ext2_write(): Done\n");
return status;
}
示例6: firstOrphan
status_t
Inode::Unlink(Transaction& transaction)
{
uint32 numLinks = fNode.NumLinks();
TRACE("Inode::Unlink(): Current links: %lu\n", numLinks);
if (numLinks == 0)
return B_BAD_VALUE;
if ((IsDirectory() && numLinks == 2) || (numLinks == 1)) {
fUnlinked = true;
TRACE("Inode::Unlink(): Putting inode in orphan list\n");
ino_t firstOrphanID;
status_t status = fVolume->SaveOrphan(transaction, fID, firstOrphanID);
if (status != B_OK)
return status;
if (firstOrphanID != 0) {
Vnode firstOrphan(fVolume, firstOrphanID);
Inode* nextOrphan;
status = firstOrphan.Get(&nextOrphan);
if (status != B_OK)
return status;
fNode.SetNextOrphan(nextOrphan->ID());
} else {
// Next orphan link is stored in deletion time
fNode.deletion_time = 0;
}
fNode.num_links = 0;
status = remove_vnode(fVolume->FSVolume(), fID);
if (status != B_OK)
return status;
} else
fNode.SetNumLinks(--numLinks);
return WriteBack(transaction);
}
示例7: 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);
//.........这里部分代码省略.........
示例8: locker
static status_t
nfs4_mount(fs_volume* volume, const char* device, uint32 flags,
const char* args, ino_t* _rootVnodeID)
{
TRACE("volume = %p, device = %s, flags = %" B_PRIu32 ", args = %s", volume,
device, flags, args);
status_t result;
/* prepare idmapper server */
MutexLocker locker(gIdMapperLock);
gIdMapper = new(std::nothrow) IdMap;
if (gIdMapper == NULL)
return B_NO_MEMORY;
result = gIdMapper->InitStatus();
if (result != B_OK) {
delete gIdMapper;
gIdMapper = NULL;
return result;
}
locker.Unlock();
AddressResolver* resolver;
MountConfiguration config;
char* path;
result = ParseArguments(args, &resolver, &path, &config);
if (result != B_OK)
return result;
MemoryDeleter pathDeleter(path);
RPC::Server* server;
result = gRPCServerManager->Acquire(&server, resolver, CreateNFS4Server);
delete resolver;
if (result != B_OK)
return result;
FileSystem* fs;
result = FileSystem::Mount(&fs, server, path, volume->id, config);
if (result != B_OK) {
gRPCServerManager->Release(server);
return result;
}
Inode* inode = fs->Root();
if (inode == NULL) {
delete fs;
gRPCServerManager->Release(server);
return B_IO_ERROR;
}
volume->private_volume = fs;
volume->ops = &gNFSv4VolumeOps;
VnodeToInode* vti = new VnodeToInode(inode->ID(), fs);
if (vti == NULL) {
delete fs;
gRPCServerManager->Release(server);
return B_NO_MEMORY;
}
vti->Replace(inode);
result = publish_vnode(volume, inode->ID(), vti, &gNFSv4VnodeOps,
inode->Type(), 0);
if (result != B_OK)
return result;
*_rootVnodeID = inode->ID();
TRACE("*_rootVnodeID = %" B_PRIi64, inode->ID());
return B_OK;
}