VxWorks API Reference : OS Libraries

dpartCbio

NAME

dpartCbio - generic disk partition manager

ROUTINES

dpartDevCreate( ) - Initialize a partitioned disk
dpartPartGet( ) - retrieve handle for a partition

DESCRIPTION

This module implements a generic partition manager using the CBIO API (see cbioLib) It supports creating a separate file system device for each of its partitions.

This partition manager depends upon an external library to decode a particular disk partition table format, and report the resulting partition layout information back to this module. This module is responsible for maintaining the partition logic during operation.

When using this module with the dcacheCbio module, it is recommened this module be the master CBIO device. This module should be above the cache CBIO module layer. This is because the cache layer is optimized to fuction efficently atop a single physical disk drive. One should call dcacheDevCreate before dpartDevCreate.

An implementation of the de-facto standard partition table format which is created by the MSDOS FDISK program is provided with the usrFdiskPartLib module, which should be used to handle PC-style partitioned hard or removable drives.

EXAMPLE

The following code will initialize a disk which is expected to have up to 4 partitions:

  usrPartDiskFsInit( BLK_DEV * blkDevId )
    {
    const char * devNames[] = { "/sd0a", "/sd0b", "/sd0c", "/sd0d" };
    CBIO_DEV_ID cbioCache;
    CBIO_DEV_ID cbioParts;

    /* create a disk cache atop the entire BLK_DEV */

    cbioCache = dcacheDevCreate ( blkDevId, NULL, 0, "/sd0" );

    if (NULL == cbioCache)
        {
        return (ERROR);
        }

    /* create a partition manager with a FDISK style decoder */

    cbioParts = dpartDevCreate( cbioCache, 4, usrFdiskPartRead );

    if (NULL == cbioParts)
        {
        return (ERROR);
        }

    /* create file systems atop each partition */

    dosFsDevCreate( devNames[0], dpartPartGet(cbioParts,0), 0x10, NONE);
    dosFsDevCreate( devNames[1], dpartPartGet(cbioParts,1), 0x10, NONE);
    dosFsDevCreate( devNames[2], dpartPartGet(cbioParts,2), 0x10, NONE);
    dosFsDevCreate( devNames[3], dpartPartGet(cbioParts,3), 0x10, NONE);
    }
Because this module complies with the CBIO programming interface on both its upper and lower layers, it is both an optional and a stackable module.

SEE ALSO

dcacheLib, dosFsLib, usrFdiskPartLib


OS Libraries : Routines

dpartDevCreate( )

NAME

dpartDevCreate( ) - Initialize a partitioned disk

SYNOPSIS

CBIO_DEV_ID dpartDevCreate
    (
    CBIO_DEV_ID subDev,         /* lower level CBIO device */
    int         nPart,          /* # of partitions */
    FUNCPTR     pPartDecodeFunc /* function to decode partition table */
    )

DESCRIPTION

To handle a partitioned disk, this function should be called, with subDev as the handle returned from dcacheDevCreate( ), It is recommended that for efficient operation a single disk cache be allocated for the entire disk and shared by its partitions.

nPart is the maximum number of partitions which are expected for the particular disk drive. Up to 24 (C-Z) partitions per disk are supported.

PARTITION DECODE FUNCTION

An external partition table decode function is provided via the pPartDecodeFunc argument, which implements a particular style and format of partition tables, and fill in the results into a table defined as Pn array of PART_TABLE_ENTRY types. See dpartCbio.h for definition of PART_TABLE_ENTRY. The prototype for this function is as follows:

    STATUS parDecodeFunc
      (
      CBIO_DEV_ID dev,        /* device from which to read blocks */
      PART_TABLE_ENTRY *pPartTab, /* table where to fill results */
      int nPart               /* # of entries in <pPartTable> */
      )

RETURNS

CBIO_DEV_ID or NULL if error creating CBIO device.

SEE ALSO

dpartCbio, dosFsDevCreate( ). INTERNAL during create, readyChanged bit is TRUE, so no accesses are allowed until after a CBIO_RESET, at which time the actual partition table will be brought in and applied.


OS Libraries : Routines

dpartPartGet( )

NAME

dpartPartGet( ) - retrieve handle for a partition

SYNOPSIS

CBIO_DEV_ID dpartPartGet
    (
    CBIO_DEV_ID masterHandle, /* CBIO handle of the master partition */
    int         partNum       /* partition number from 0 to nPart */
    )

DESCRIPTION

This function retrieves a CBIO handle into a particular partition of a partitioned device. This handle is intended to be used with dosFsDevCreate( ).

RETURNS

CBIO_DEV_ID or NULL if partition is out of range, or masterHandle is invalid.

SEE ALSO

dpartCbio, dosFsDevCreate( )