26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG. Writing a resource manager<br />

We’ll look at:<br />

• The resmgr_attach() function and its parameters<br />

• Putting in your own functions<br />

• The general flow of a resource manager<br />

• Messages that should be connect messages but aren’t<br />

• Combine messages<br />

The resmgr_attach() function and its parameters<br />

As you saw in the /dev/null example above, the first thing you’ll want to do is<br />

register your chosen “mountpoint” <strong>with</strong> the process manager. This is done via<br />

resmgr_attach(), which has the following prototype:<br />

int<br />

resmgr_attach (void *dpp,<br />

resmgr_attr_t *resmgr_attr,<br />

const char *path,<br />

enum _file_type file_type,<br />

unsigned flags,<br />

const resmgr_connect_funcs_t *connect_funcs,<br />

const resmgr_io_funcs_t *io_funcs,<br />

RESMGR_HANDLE_T *handle);<br />

Let’s examine these arguments, in order, and see what they’re used for.<br />

dpp<br />

resmgr_attr<br />

path<br />

file_type<br />

flags<br />

The dispatch handle. This lets the dispatch interface manage the<br />

message receive for your resource manager.<br />

Controls the resource manager characteristics, as discussed above.<br />

The mountpoint that you’re registering. If you’re registering a<br />

discrete mountpoint (such as would be the case, for example, <strong>with</strong><br />

/dev/null,or/dev/ser1), then this mountpoint must be matched<br />

exactly by the client, <strong>with</strong> no further pathname components past the<br />

mountpoint. If you’re registering a directory mountpoint (such as<br />

would be the case, for example, <strong>with</strong> a network filesystem mounted<br />

as /nfs), then the match must be exact as well, <strong>with</strong> the added<br />

feature that pathnames past the mountpoint are allowed; they get<br />

passed to the connect functions stripped of the mountpoint (for<br />

example, the pathname /nfs/etc/passwd would match the<br />

network filesystem resource manager, and it would get etc/passwd<br />

as the rest of the pathname).<br />

The class of resource manager. See below.<br />

Additional flags to control the behavior of your resource manager.<br />

These flags are defined below.<br />

April 30, 2009 Chapter 5 • Resource Managers 211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!