- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我试图通过/proc/{pid}/as 为 qnx 6.6 创建我自己的进程管理器。
但我只需要更改一个操作 (io_open),所有其他操作应该继续使用旧文件 (/proc/{pid}/as)。
我能否只获取指向 resmgr_context_t 的指针(从路径或 fd,在 resmgr_attach 之前)并为所有其他操作调用默认函数?
这是我想要的愚蠢的例子:
resmgr_context_t* old_context;
int my_lseek(resmgr_context_t *ctp, io_lseek_t *msg, RESMGR_OCB_T *ocb){
return iofunc_lseek_default(old_context, msg, ocb);
}
最佳答案
您需要制作一个只为 io_open 注册一个函数的常规资源管理器,所有其他资源管理器操作将向下过滤到堆栈中较低的资源管理器。
如果您希望消息从 resmgr 堆栈向下移动到其他已注册的 io_open 回调,则从 io_open 回调返回 ENOENT,否则返回 EOK。
为简洁起见省略了错误检查。
#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
static resmgr_connect_funcs_t connect_funcs;
static resmgr_io_funcs_t io_funcs;
static iofunc_attr_t attr;
int io_open (resmgr_context_t *ctp, io_open_t *msg, RESMGR_HANDLE_T *handle, void *extra);
int main(int argc, char **argv)
{
resmgr_attr_t resmgr_attr;
dispatch_t *dpp;
dispatch_context_t *ctp;
int id;
// initialize dispatch interface
dpp = dispatch_create();
// initialize resource manager attributes
memset(&resmgr_attr, 0, sizeof resmgr_attr);
resmgr_attr.nparts_max = 1;
resmgr_attr.msg_max_size = 2048;
// initialize functions for handling messages
iofunc_func_init(_RESMGR_CONNECT_NFUNCS, &connect_funcs,
_RESMGR_IO_NFUNCS, &io_funcs);
connect_funcs.open = io_open;
// initialize attribute structure used by the device
iofunc_attr_init(&attr, S_IFNAM | 0666, 0, 0);
// attach to /proc/{pid}/as path, replace '1' with correct pid
resmgr_attach(dpp, &resmgr_attr,"/proc/1/as",
_FTYPE_ANY, _RESMGR_FLAG_BEFORE|_RESMGR_FLAG_DIR,
&connect_funcs, &io_funcs, &attr);
ctp = dispatch_context_alloc(dpp);
/* start the resource manager message loop */
while(1) {
if((ctp = dispatch_block(ctp)) == NULL) {
perror("dispatch_block");
return EXIT_FAILURE;
}
dispatch_handler(ctp);
}
}
int io_open (resmgr_context_t *ctp, io_open_t *msg, RESMGR_HANDLE_T *handle, void *extra)
{
time_t tod;
tod = time(NULL);
printf ("%10d %-32s is being opened\n", tod, msg->connect.path);
return(ENOENT);
}
关于linux - qnx 获取旧资源管理器的 resmgr_context_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46346247/
我有一个 12 节点集群,我运行的是 yarn 架构。似乎我的节点大部分时间都很忙,而且很多时候作业都失败了。如何随时查看资源的使用情况?还有什么方法可以为用户设置有限的资源,例如:如果用户提交作业,
我有一个关于 Xtend 的非常具体的问题。 在我读到的有关 xText/xTend 的每个示例中,我都会看到类似这样的内容: override void doGenerate(Resource re
代码参考 代码文件参考下述详解的类图,工程参考第零章工程说明 。 概述 在游戏项目中有很多资产如:预制体,图片,音频,Lua脚本,Shader等等。他们随打包放在用户的硬盘里。在游戏的运
我有一个包含10个节点的Hadoop集群。在10个节点中,有3个部署了HBase。有两个共享集群的应用程序。 应用程序1从hadoop HDF写入和读取数据。应用程序2将数据存储到HBase中。有没有
例子: var image = UIImage.FromFile("/path/to/image.png"); var imageView = new UIImageView(); imageView
我需要存储 ThirdPartyElm 类型的元素序列,我使用的是 std::vector(或 std::array 如果我需要一个固定大小的序列)。 我想知道我应该如何初始化序列。第一个版本创建一个
我有一个具有UITabBarController的MonoTouch应用程序,每个选项卡都是一个UINavigationController。其中一些包装了一个UIViewController,后者添
所以我一直在研究使用资源管理 API 对 azure 进行只读 api 访问。现在我主要关注虚拟机。我一直在使用这个预发布包和 TokenCredentials: https://www.nuget.
我想获取 Azure 中包含给定标签的资源列表。基本请求形式如下:https://management.azure.com/subscriptions/{subscriptionId}/resourc
我一直在尝试访问 Azure 公开的 REST API,例如“https://management.azure.com/subscriptions?api-version=2016-06-01”,但无
如何使用 Azure 资源管理 API 获取资源组的资源列表 我已经安装了 Microsoft.Azure.Management.ResourceManager.Fluent Nuget 包下面的脚本
如何使用 Azure 资源管理 API 获取资源组的资源列表 我已经安装了 Microsoft.Azure.Management.ResourceManager.Fluent Nuget 包下面的脚本
我正在尝试在 Jersey 中编写 RESTful Web 应用程序时管理竞争资源(如:数据库 session )。通常我会写这样的代码: Session session = getSession()
我是这个论坛的新手。 我正在查看有关 Azure 资源运行状况 Rest Api 的 Microsoft 文档,链接如下: https://azure.microsoft.com/en-us/blog
我想使用这些 API 获取特定 Azure 帐户或订阅的运行状况和其他资源详细信息 https://learn.microsoft.com/en-us/rest/api/resourcehealth/
我正在尝试在 Azure 资源管理的上下文中找到应用程序权限的安全最佳实践。 目前,management.azure.com 仅列出了一项权限,它是management.azure.com/user_
我想使用这些 API 获取特定 Azure 帐户或订阅的运行状况和其他资源详细信息 https://learn.microsoft.com/en-us/rest/api/resourcehealth/
我正在尝试在 Azure 资源管理的上下文中找到应用程序权限的安全最佳实践。 目前,management.azure.com 仅列出了一项权限,它是management.azure.com/user_
我正在寻找一种以编程方式列出组织内的 Google Cloud 项目的方法。我正在尝试使用服务帐户导出的 json 凭据以这种方式实现此目的: // More info on the endp
我正在编写一些用于自动部署Azure网站的代码(包括在Azure中创建网站)。我正在使用 Nuget 中提供的 Azure 管理库和 Azure 资源管理库。大部分内容都已到位,但是我无法找到通过我见
我是一名优秀的程序员,十分优秀!