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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

ioflag<br />

The open mode; how this resource was opened (e.g. read only). The open<br />

modes (as passed to open() on the client side) correspond to the ioflag<br />

values as follows:<br />

Open mode ioflag value<br />

O_RDONLY _IO_FLAG_RD<br />

O_RDWR _IO_FLAG_RD | _IO_FLAG_WR<br />

O_WRONLY _IO_FLAG_WR<br />

offset<br />

sflag<br />

flags<br />

The current lseek() offset into this resource.<br />

The sharing flag (see ) used <strong>with</strong> the client’s sopen() function<br />

call. These are the flags SH_COMPAT, SH_DENYRW, SH_DENYWR,<br />

SH_DENYRD, and SH_DENYNO.<br />

System flags. The two flags currently supported are<br />

IOFUNC_OCB_PRIVILEGED, which indicates whether a privileged process<br />

issued the connect message that resulted in this OCB, and<br />

IOFUNC_OCB_MMAP, which indicates whether this OCB is in use by a<br />

mmap() call on the client side. No other flags are defined at this time. You<br />

can use the bits defined by IOFUNC_OCB_FLAGS_PRIVATE for your own<br />

private flags.<br />

If you wish to store additional data along <strong>with</strong> the “normal” OCB, rest assured that<br />

you can “extend” the OCB. We’ll discuss this in the “Advanced topics” section.<br />

The strange case of the offset member<br />

The offset field is, to say the least, interesting. Have a look at to<br />

see how it’s implemented. Depending on what preprocessor flags you’ve set, you may<br />

get one of six (!) possible layouts for the offset area. But don’t worry too much about<br />

the implementation — there are really only two cases to consider, depending on<br />

whether you want to support 64-bit offsets:<br />

• yes — the offset member is 64 bits<br />

• no (32-bit integers) — the offset member is the lower 32 bits; another member,<br />

offset_hi, contains the upper 32 bits.<br />

For our purposes here, unless we’re specifically going to talk about 32 versus 64 bits,<br />

we’ll just assume that all offsets are 64 bits, of type off_t, and that the platform<br />

knows how to deal <strong>with</strong> 64-bit quantities.<br />

April 30, 2009 Chapter 5 • Resource Managers 221

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

Saved successfully!

Ooh no, something went wrong!