📄 usrfdiskpartlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/usrFdiskPartLib.html - generated by refgen from usrFdiskPartLib.c --> <title> usrFdiskPartLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>usrFdiskPartLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>usrFdiskPartLib</strong> - FDISK-style partition handler </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./usrFdiskPartLib.html#usrFdiskPartRead">usrFdiskPartRead</a>( )</b> - read an FDISK-style partition table<br><b><a href="./usrFdiskPartLib.html#usrFdiskPartCreate">usrFdiskPartCreate</a>( )</b> - create an FDISK-like partition table on a disk<br><b><a href="./usrFdiskPartLib.html#usrFdiskPartShow">usrFdiskPartShow</a>( )</b> - parse and display partition data<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p><p>This module is provided is source code to accommodate variouscustomizations of partition table handling, resulting fromvariations in the partition table format in a particular configuration.It is intended for use with dpartCbio partition manager.<p>This code supports both mounting MSDOS file systems anddisplaying partition tables written by MSDOS FDISK.exe orby any other MSDOS FDISK.exe compatible partitioning software. <p>The first partition table is contained within a hard drivesMaster Boot Record (MBR) sector, which is defined as sectorone, cylinder zero, head zero or logical block address zero.<p>The mounting and displaying routines within this code will first parse the MBR partition tables entries (defined below)and also recursively parse any "extended" partition tables,which may reside within another sector further into the hard disk. MSDOS file systems within extended partitions are knownto those familiar with the MSDOS FDISK.exe utility as "Logical drives within the extended partition".<p>Here is a picture showing the layout of a single disk containingmultiple MSDOS file systems:<p><pre> +---------------------------------------------------------+ |<---------------------The entire disk------------------->| |M | |B<---C:---> | |R /---- First extended partition--------------\| | E<---D:---><-Rest of the ext part------------>| |P x | |A t E<---E:--->E<Rest of the ext part->| |R x x | |T t t<---------F:---------->| +---------------------------------------------------------+ (Ext == extended partition sector) C: is a primary partiion D:, E:, and F: are logical drives within the extended partition.</pre>A MS-DOS partition table resides within one sector on a harddisk. There is always one in the first sector of a hard diskpartitioned with FDISK.exe. There first partition table maycontain references to "extended" partition tables residing onother sectors if there are multiple partitions. The first sector of the disk is the starting point. Partition tablesare of the format:<p><pre>Offset from the beginning of the sector Description------------- ------------------------- 0x1be Partition 1 table entry (16 bytes) 0x1ce Partition 2 table entry (16 bytes) 0x1de Partition 3 table entry (16 bytes) 0x1ee Partition 4 table entry (16 bytes) 0x1fe Signature (0x55aa, 2 bytes)</pre>Individual MSDOS partition table entries are of the format:<pre>Offset Size Description------ ---- ------------------------------ 0x0 8 bits boot type 0x1 8 bits beginning sector head value 0x2 8 bits beginning sector (2 high bits of cylinder#) 0x3 8 bits beginning cylinder# (low order bits of cylinder#) 0x4 8 bits system indicator 0x5 8 bits ending sector head value 0x6 8 bits ending sector (2 high bits of cylinder#) 0x7 8 bits ending cylinder# (low order bits of cylinder#) 0x8 32 bits number of sectors preceding the partition 0xc 32 bits number of sectors in the partition</pre>The Cylinder, Head and Sector values herein are not used,instead the 32-bit partition offset and size (also known as LBAaddresses) are used exclusively to determine partition geometry.<p>If a non-partitioned disk is detected, in which case the 0'th blockis a DosFs boot block rather then an MBR, the entire disk will beconfigured as partition 0, so that disks formatted with VxWorks anddisks formatted on MS-DOS or Windows can be accepted interchangeably.<p>The <b><a href="./usrFdiskPartLib.html#usrFdiskPartCreate">usrFdiskPartCreate</a>( )</b> will create a partition table with up to fourpartitions, which can be later used with <b><a href="./usrFdiskPartLib.html#usrFdiskPartRead">usrFdiskPartRead</a>( )</b> anddpartCbio to manage a partitioned disk on VxWorks.<p>However, it can not be guaranteed that this partition table can be usedon another system due to several BIOS specific paramaters in the bootarea. If interchangeability via removable disks is a requirement, partition tables should be created and volumes should be formatted on the other system with which the data is to be interchanged/<p></blockquote><h4>CAUTION</h4><blockquote><p>The partition decode function is recursive, up to the maximumnumber of partitions expected, which is no more then 24.<p>Sufficient stack space needs to be provided via <b><a href="./taskLib.html#taskSpawn">taskSpawn</a>( )</b> to accommodate the recursion level.<p></blockquote><h4>SEE ALSO</h4><blockquote><p>dpartCbio<hr><a name="usrFdiskPartRead"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>usrFdiskPartRead( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>usrFdiskPartRead( )</strong> - read an FDISK-style partition table</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS usrFdiskPartRead ( CBIO_DEV_ID cDev, /* device from which to read blocks */ PART_TABLE_ENTRY * pPartTab, /* table where to fill results */ int nPart /* # of entries in <i>pPartTable</i> */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This function will read and decode a PC formatted partition tableon a disk, and fill the appropriate partition table array withthe resulting geometry, which should be used by the dpartCbiopartition manager to access a partitioned disk with a shared diskcache.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><p>The following example shows how a hard disk which is expected to haveup to two partitions might be configured, assuming the physicallevel initialization resulted in the <i>blkIoDevId</i> handle:<p><pre>devCbio = dcacheDevCreate( blkIoDevId, 0, 0x20000, "Hard Disk");mainDevId = dpartDevCreate( devCbio, 2, usrFdiskPartRead )dosFsDevCreate( "/disk0a", dpartPartGet (mainDevId, 0), 0,0,0);dosFsDevCreate( "/disk0b", dpartPartGet (mainDevId, 1), 0,0,0);</pre></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR if partition table is corrupt</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./usrFdiskPartLib.html#top">usrFdiskPartLib</a></b><hr><a name="usrFdiskPartCreate"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>usrFdiskPartCreate( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>usrFdiskPartCreate( )</strong> - create an FDISK-like partition table on a disk</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS usrFdiskPartCreate ( CBIO_DEV_ID cDev, /* device representing the entire disk */ int nPart, /* how many partitions needed, default=1, max=4 */ int size1, /* space percentage for second partition */ int size2, /* space percentage for third partition */ int size3 /* space percentage for fourth partition */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This function may be used to create a basic PC partition table.Such partition table however is not intended to be compatible withother operating systems, it is intended for disks connected to aVxWorks target, but without the access to a PC which may be used tocreate the partition table.<p>This function is capable of creating only one partition table - theMBR, and will not create any Bootable or Extended partitions.Therefore, 4 partitions are supported.<p><i>dev</i> is a CBIO device handle for an entire disk, e.g. a handlereturned by <b><a href="./dcacheCbio.html#dcacheDevCreate">dcacheDevCreate</a>( )</b>, or if dpartCbio is used, it can be eitherthe Master partition manager handle, or the one of the 0th partitionif the disk does not contain a partition table at all.<p>The <i>nPart</i> argument contains the number of partitions to create. If<i>nPart</i> is 0 or 1, then a single partition covering the entire disk iscreated.If <i>nPart</i> is between 2 and 4, then the arguments <i>size1</i>, <i>size2</i>and <i>size3</i> contain the <i>percentage </i>of disk space to be assigned to the 2nd, 3rd, and 4th partitionsrespectively. The first partition (partition 0) will be assigned theremainder of space left (space hog).<p>Partition sizes will be round down to be multiple of whole tracksso that partition Cylinder/Head/Track fields will be initialized as well as the LBA fields. Although the CHS fields are written theyare not used in VxWorks, and can not be guaranteed to work correctlyon other systems.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR writing a partition table to disk</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./usrFdiskPartLib.html#top">usrFdiskPartLib</a></b><hr><a name="usrFdiskPartShow"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>usrFdiskPartShow( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>usrFdiskPartShow( )</strong> - parse and display partition data</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS usrFdiskPartShow ( CBIO_DEV_ID cbio, /* device CBIO handle */ block_t extPartOffset, /* user should pass zero */ block_t currentOffset, /* user should pass zero */ int extPartLevel /* user should pass zero */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine is intended to be user callable.<p>A device dependent partition table show routine. This routine outputs formatted data for all partition table fields for every partition table found on a given disk,starting with the MBR sectors partition table. This code can be removed to reduce code size by undefining: <b>INCLUDE_PART_SHOW</b>and rebuilding this library and linking to the new library.<p>This routine takes three arguments. First, a CBIO pointer (assigned for the entire physical disk) usually obtained from <b><a href="./dcacheCbio.html#dcacheDevCreate">dcacheDevCreate</a>( )</b>. It also takes two <b>block_t</b> type arguments and one signed int, the user shall pass zero in these paramaters.<p>For example:<pre>sp usrFdiskPartShow (pCbio,0,0,0)</pre>Developers may use size<i>arch</i> to view code size.<p></blockquote><h4>NOTE</h4><blockquote><p><p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./usrFdiskPartLib.html#top">usrFdiskPartLib</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -