2017-09-21 3 views
2

/proc/{pid}/as를 통해 qnx 6.6에 대한 프로세스 관리자를 직접 만들려고합니다.qnx 이전 자원 관리자의 resmgr_context_t를 얻으십시오

하지만 하나의 작업 (io_open) 만 변경해야하며 다른 모든 작업은 이전 파일 (/ proc/{pid}/as)에서 계속 작동해야합니다.

resmgr_context_t (path 또는 fd, resmgr_attach 이전)에 대한 포인터를 얻을 수 있고 다른 모든 작업에 대해서만 기본 함수를 호출 할 수 있습니까? 당신은 다른 모든 자원 관리자 작업에서 낮은 자원 관리자까지 필터링에만 io_open하는 기능을 등록하는 일반 자원 관리자를 만들 필요가

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); 
} 

답변

0

:

이 내가 원하는 것을 stupied 예입니다 스택

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); 
} 
+0

"다른 모든 리소스 관리자 작업은 스택의 하위 리소스 관리자로 필터링됩니다." 즉, 콜백을 mmap하면, 트리거되지 않습니다. io_open의 ENOENT가 반환 된 후 모든 msg가 낮은 RM으로 필터링됩니다. –