本文整理汇总了C++中VNode::GetStatData方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::GetStatData方法的具体用法?C++ VNode::GetStatData怎么用?C++ VNode::GetStatData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::GetStatData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// reiserfs_access
static status_t
reiserfs_access(fs_volume *fs, fs_vnode *_node, int mode)
{
TOUCH(fs);
// FUNCTION_START();
// Volume *volume = (Volume*)fs->private_volume;
VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
node->GetObjectID()));
// write access requested?
if (mode & W_OK)
return B_READ_ONLY_DEVICE;
// get node permissions
StatData *statData = node->GetStatData();
int userPermissions = (statData->GetMode() & S_IRWXU) >> 6;
int groupPermissions = (statData->GetMode() & S_IRWXG) >> 3;
int otherPermissions = statData->GetMode() & S_IRWXO;
// get the permissions for this uid/gid
int permissions = 0;
uid_t uid = geteuid();
// user is root
if (uid == 0) {
// root has always read/write permission, but at least one of the
// X bits must be set for execute permission
permissions = userPermissions | groupPermissions | otherPermissions
| S_IROTH | S_IWOTH;
// user is node owner
} else if (uid == statData->GetUID())
permissions = userPermissions;
// user is in owning group
else if (is_user_in_group(statData->GetGID()))
permissions = groupPermissions;
// user is one of the others
else
permissions = otherPermissions;
// do the check
if (mode & ~permissions)
return B_NOT_ALLOWED;
return B_OK;
}
示例2:
// reiserfs_read_stat
static status_t
reiserfs_read_stat(fs_volume *fs, fs_vnode *_node, struct stat *st)
{
// FUNCTION_START();
Volume *volume = (Volume*)fs->private_volume;
VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
node->GetObjectID()));
status_t error = B_OK;
StatData *statData = node->GetStatData();
st->st_dev = volume->GetID();
st->st_ino = node->GetID();
st->st_mode = statData->GetMode();
st->st_nlink = statData->GetNLink();
st->st_uid = statData->GetUID();
st->st_gid = statData->GetGID();
st->st_size = statData->GetSize();
st->st_blksize = kOptimalIOSize;
st->st_atime = statData->GetATime();
st->st_mtime = st->st_ctime = statData->GetMTime();
st->st_crtime = statData->GetCTime();
RETURN_ERROR(error);
}
示例3: new
// reiserfs_read_vnode
static status_t
reiserfs_read_vnode(fs_volume *fs, ino_t vnid, fs_vnode *node, int *_type,
uint32 *_flags, bool reenter)
{
TOUCH(reenter);
// FUNCTION_START();
FUNCTION(("(%Ld: %lu, %ld)\n", vnid, VNode::GetDirIDFor(vnid),
VNode::GetObjectIDFor(vnid)));
Volume *volume = (Volume*)fs->private_volume;
status_t error = B_OK;
VNode *foundNode = new(nothrow) VNode;
if (foundNode) {
error = volume->FindVNode(vnid, foundNode);
if (error == B_OK) {
node->private_node = foundNode;
node->ops = &gReiserFSVnodeOps;
*_type = foundNode->GetStatData()->GetMode() & S_IFMT;
*_flags = 0;
} else
delete foundNode;
} else
error = B_NO_MEMORY;
RETURN_ERROR(error);
}