Hi,
I want to make a character device.
The following code is example in QNX 6 Programmer’s Guide.
I expected the code makes a character device, but doesn’t so.
When I do ‘ls -l /dev/sample’, the result is
nrw-rw-rw- 1 root root 0 Dec 04 22:25 /dev/sample
,instead of
crw-rw-rw- 1 root root 0 Dec 04 22:25 /dev/sample
I know ‘c’ means character device, however what does mean ‘n’ ? network ?
And how do I modify the code for making a character device ?
Thanks in advance,
Hoon
#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.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;
main(int argc, char *argv)
{
/ declare variables we’ll be using */
resmgr_attr_t resmgr_attr;
dispatch_t *dpp;
dispatch_context_t *ctp;
int id;
/* initialize dispatch interface */
if((dpp = dispatch_create()) == NULL) {
fprintf(stderr, “%s: Unable to allocate dispatch handle.\n”,
argv[0]);
return EXIT_FAILURE;
}
/* 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);
/* initialize attribute structure used by the device */
iofunc_attr_init(&attr, S_IFNAM | 0666, 0, 0);
/* attach our device name /
id = resmgr_attach(dpp, / dispatch handle /
&resmgr_attr, / resource manager attrs /
“/dev/sample”, / device name /
_FTYPE_ANY, / open type /
0, / flags /
&connect_funcs, / connect routines /
&io_funcs, / I/O routines /
&attr); / handle */
if(id == -1) {
fprintf(stderr, “%s: Unable to attach name.\n”, argv[0]);
return EXIT_FAILURE;
}
/* allocate a context structure */
ctp = dispatch_context_alloc(dpp);
/* start the resource manager message loop */
while(1) {
if((ctp = dispatch_block(ctp)) == NULL) {
fprintf(stderr, “block error\n”);
return EXIT_FAILURE;
}
dispatch_handler(ctp);
}
}