本文整理汇总了C++中FileSystem::findNode方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::findNode方法的具体用法?C++ FileSystem::findNode怎么用?C++ FileSystem::findNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::findNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
FileSystem rootfs;
rootfs.addNode("/", new FSDir("dayos", VFS_MODE_RW));
rootfs.addNode("/", new FSDir("drives", VFS_MODE_RW));
rootfs.addNode("/dayos", new FSDir("dev", VFS_MODE_RW));
if (register_service("vfs") != SIGNAL_OK)
{
debug_printf("[ VFS ] Could not register VFS service. Will terminate.\n");
return -1;
}
pid_t vfs_pid = get_service_pid("vfs");
message_t msg;
struct vfs_request* request = (struct vfs_request*)&msg.message;
while (1)
{
while (receive_message(&msg, MESSAGE_ANY) != MESSAGE_RECEIVED)
sleep(10);
switch (msg.signal)
{
case VFS_SIGNAL_CREATE_DEVICE:
if (!rootfs.mkdev(request->path, (VFS_OPEN_MODES)request->mode,
(DEVICE_TYPES)request->param, msg.sender))
msg.signal = SIGNAL_FAIL;
else
msg.signal = SIGNAL_OK;
send_message(&msg, msg.sender);
break;
case VFS_SIGNAL_MOUNT_DEVICE:
{
struct vfs_request req = *request;
if (receive_message_timeout(&msg, msg.sender, 100, 10) !=
MESSAGE_RECEIVED)
break;
if (!rootfs.mount(req.path, request->path,
(VFS_OPEN_MODES)req.mode, request->param))
msg.signal = SIGNAL_FAIL;
else
msg.signal = SIGNAL_OK;
send_message(&msg, msg.sender);
}
break;
case VFS_SIGNAL_MOUNT_RAMDISK:
{
if (!rootfs.mount(request->path, (VFS_OPEN_MODES)request->mode,
msg.sender))
msg.signal = SIGNAL_FAIL;
else
msg.signal = SIGNAL_OK;
send_message(&msg, msg.sender);
}
break;
case VFS_SIGNAL_OPEN:
{
pid_t sender = msg.sender;
FSNode* node = rootfs.findNode(request->path);
struct vfs_file* file = (struct vfs_file*)&msg.message;
if (!node)
{
msg.signal = SIGNAL_FAIL;
send_message(&msg, msg.sender);
break;
}
msg.signal = SIGNAL_OK;
switch (node->getType())
{
case NODE_DEVICE:
{
FSDevice* dev = static_cast<FSDevice*>(node);
file->device = dev->getDriverPID();
file->type = dev->getDeviceType();
file->uid = dev->getUID();
file->guid = dev->getGUID();
strcpy(file->path, request->path);
}
break;
case NODE_MOUNT:
{
FSMount* mount = static_cast<FSMount*>(node);
file->device = mount->getFilesystemDriver();
file->type = VFS_MOUNTPOINT;
// FIXME: Fetch from FS driver!
//.........这里部分代码省略.........