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 />

The dev member contains the device number and is described below in “Of device<br />

numbers, inodes, and our friend rdev.”<br />

The blocksize describes the native blocksize of the device in bytes. For example, on a<br />

typical rotating-medium storage system, this would be the value 512.<br />

Finally, the funcs pointer points to a structure (from ):<br />

typedef struct _iofunc_funcs {<br />

unsigned nfuncs;<br />

IOFUNC_OCB_T *(*ocb_calloc)<br />

(resmgr_context_t *ctp,<br />

IOFUNC_ATTR_T *attr);<br />

void<br />

(*ocb_free)<br />

(IOFUNC_OCB_T *ocb);<br />

} iofunc_funcs_t;<br />

As <strong>with</strong> the connect and I/O functions tables, the nfuncs member should be stuffed<br />

<strong>with</strong> the current size of the table. Use the constant _IOFUNC_NFUNCS for this.<br />

The ocb_calloc and ocb_free function pointers can be filled <strong>with</strong> addresses of<br />

functions to call whenever an OCB is to be allocated or deallocated. We’ll discuss why<br />

you’d want to use these functions later when we talk about extending OCBs.<br />

Of device numbers, inodes, and our friend rdev<br />

The mount structure contains a member called dev. The attributes structure contains<br />

two members: inode and rdev. Let’s look at their relationships by examining a<br />

traditional disk-based filesystem. The filesystem is mounted on a block device (which<br />

is the entire disk). This block device might be known as /dev/hd0 (the first hard disk<br />

in the system). On this disk, there might be a number of partitions, such as<br />

/dev/hd0t77 (the first <strong>QNX</strong> filesystem partition on that particular device). Finally,<br />

<strong>with</strong>in that partition, there might be an arbitrary number of files, one of which might<br />

be /hd/spud.txt.<br />

The dev (or “device number”) member, contains a number that’s unique to the node<br />

that this resource manager is registered <strong>with</strong>. The rdev member is the dev number of<br />

the root device. Finally, the inode is the file serial number.<br />

(Note that you can obtain major and minor device numbers by calling<br />

rsrcdbmgr_devno_attach(); see the <strong>Neutrino</strong> Library Reference for more details. You<br />

are limited to 64 major devices and 1024 minor devices per major device.)<br />

Let’s relate that to our disk example. The following table shows some example<br />

numbers; after the table we’ll take a look at where these numbers came from and how<br />

they’re related.<br />

April 30, 2009 Chapter 5 • Resource Managers 225

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

Saved successfully!

Ooh no, something went wrong!