Linux qnx获取旧资源管理器的resmgr\u上下文
我试图在/proc/{pid}/as上为qnx 6.6创建自己的流程管理器 但我只需要更改一个操作(io_open),所有其他操作都应该继续使用旧文件(/proc/{pid}/as) 我可以只获取指向resmgr\u context\t的指针(从path或fd,在resmgr\u attach之前)并且对于所有其他操作只调用default函数吗 这是我想要的愚蠢的例子:Linux qnx获取旧资源管理器的resmgr\u上下文,linux,qnx,resourcemanager,Linux,Qnx,Resourcemanager,我试图在/proc/{pid}/as上为qnx 6.6创建自己的流程管理器 但我只需要更改一个操作(io_open),所有其他操作都应该继续使用旧文件(/proc/{pid}/as) 我可以只获取指向resmgr\u context\t的指针(从path或fd,在resmgr\u attach之前)并且对于所有其他操作只调用default函数吗 这是我想要的愚蠢的例子: resmgr_context_t* old_context; int my_lseek(resmgr_context_t *c
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_函数的常规资源管理器,所有其他资源管理器操作将向下过滤到堆栈中较低的资源管理器 如果希望消息从resmgr堆栈向下移动到其他已注册的io_open回调,请从io_open回调返回enoint,否则返回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);
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
静态resmgr\u connect\u funcs\u t connect\u funcs;
静态resmgr_io_函数_t io_函数;
静态iofunc\u attr\u t attr;
int io_open(resmgr_context_t*ctp、io_open_t*msg、resmgr_HANDLE_t*HANDLE、void*extra);
int main(int argc,字符**argv)
{
resmgr\u attr\t resmgr\u attr;
派遣*民进党;
调度上下文ctp;
int-id;
//初始化调度接口
dpp=调度_创建();
//初始化资源管理器属性
memset(&resmgr\u attr,0,resmgr\u attr的大小);
resmgr_attr.npart_max=1;
resmgr_attr.msg_max_size=2048;
//初始化处理消息的函数
iofunc_func_init(_RESMGR_CONNECT_NFUNCS,&CONNECT_func,
_高级管理人员(信息、信息和功能);
connect_funcs.open=io_open;
//初始化设备使用的属性结构
iofunc_attr_init(&attr,S|u IFNAM | 0666,0,0);
//附加到/proc/{pid}/as路径,用正确的pid替换“1”
resmgr_attach(dpp和resmgr_attr,“/proc/1/as”,
_F在| |前键入_ANY,_RESMGR_FLAG_DIR,
&连接函数和io函数以及属性);
ctp=dispatch\u context\u alloc(dpp);
/*启动资源管理器消息循环*/
而(1){
如果((ctp=dispatch_block(ctp))==NULL){
perror(“调度区”);
返回退出失败;
}
调度处理程序(ctp);
}
}
int io_open(resmgr_context_t*ctp、io_open_t*msg、resmgr_HANDLE_t*HANDLE、void*extra)
{
时间;
tod=时间(空);
printf(“%10d%-32s正在打开”\n“,tod,msg->connect.path);
返回(eNONT);
}
“所有其他资源管理器操作将向下过滤到堆栈中较低的资源管理器。”这是否意味着,如果我将mmap回调,它将永远不会触发,因为io_open中返回ENONT后的所有消息将向下过滤到较低的RM?