Cdrom File System For Vxworks 5.5.1
Cdrom File System For Vxworks 5.5.1
Programmer’s Supplement
Copyright 2003 Wind River Systems, Inc.
ALL RIGHTS RESERVED. No part of this publication may be copied in any form, by
photocopy, microfilm, retrieval system, or by any other means now known or hereafter
invented without the prior written permission of Wind River Systems, Inc.
Wind River, the Wind River logo, Tornado, and VxWorks are registered trademarks of
Wind River Systems, Inc. Any third-party trademarks referenced are the property of their
respective owners. For further information regarding Wind River trademarks, please see:
http://www.windriver.com/company/terms/trademark.html
Corporate Headquarters
Wind River Systems, Inc.
500 Wind River Way
Alameda, CA 94501-1153
U.S.A.
For additional contact information, please visit the Wind River URL:
http://www.windriver.com
For information on how to contact Customer Support, please visit the following URL:
http://www.windriver.com/support
21 Apr 03
Part #: DOC-15053-ND-00
Contents
1 Introduction .............................................................................................................. 1
2 cdromFsLib ............................................................................................................... 1
iii
CD-ROM File System for VxWorks 5.5.1
Programmer’s Supplement
iv
CD-ROM File System
for VxWorks 5.5.1 ®
Programmer’s Supplement
1. Introduction
VxWorks uses a standard I/O interface between the file system and the device
driver. This allows multiple file systems, of the same or different types, to operate
within a single VxWorks system. By following these standard interfaces, you can
write your own file system for VxWorks, and freely mix file systems and device
drivers.
This document discusses the VxWorks CD-ROM file system, cdromFs. cdromFs
allows applications to read data from CDs formatted according to the ISO 9660
standard file system with or without the Joliet extensions. This document describes
how cdromFs is organized, configured, and used.
2. cdromFsLib
The cdromFs library, cdromFsLib, lets applications read any CD-ROMs, CD-Rs, or
CD-RWs (collectively called CDs) that are formatted in accordance with the ISO
9660 file system standard, with or without the Joliet extensions. ISO 9660
interchange level 3, implementation level 2, is supported. Note that multi-extent
files, interleaved files, and files with extended attribute records are supported.
1
CD-ROM File System for VxWorks 5.5.1
Programmer’s Supplement
The following CD features and ISO 9660 features are not supported:
■ Multi-volume sets
■ Record format files
■ CDs with a sector size that is not a power of two1
■ Multi-session CD-R or CD-RW2
To configure VxWorks with cdromFs, add the INCLUDE_CDROMFS component to
the kernel.
After initializing cdromFs and mounting it on a CD-ROM block device, you can
access data on that device using the standard POSIX I/O calls: open( ), close( ),
read( ), ioctl( ), readdir( ), and stat( ). The write( ) call always returns an error.
The cdromFs utility supports multiple drives, multiple open files, and concurrent
file access. When you specify a pathname, cdromFS accepts both “/” and “\”.
However, the backslash is not recommended because it might not be supported in
future releases.
cdromFs provides access to CD file systems using any standard BLK_DEV
structure. The basic initialization sequence is similar to installing a dosFs file
system on a SCSI or ATA device, with a few significant differences: Create the CD
file system device directly on the BLK_DEV. CBIO drivers are not used. After you
have created the CD file system device, use ioctl( ) to set file system options. The
files system options are described below:
■ CDROMFS_DIR_MODE_SET/GET. These options set and get the directory
mode. The directory mode controls whether a file is opened with the Joliet
extensions, or without them. The directory mode can be set to any of the
following:
■ MODE_ISO9660. Do not use the Joliet extensions.
■ MODE_JOLIET. Use the Joliet extensions.
■ MODE_AUTO. Try opening the directory first without Joliet, and then with
Joliet.
1. Therefore, mode 2/form 2 sectors are not supported, as they have 2324 bytes of user data
per sector. Both mode 1/form 1 and mode 2/form 1 sectors are supported, as they have 2048
bytes of user data per sector.
2. The first session (that is, the earliest session) is always read. The most commonly desired
behavior is to read the last session (that is, the latest session).
2
3
Creating and Using a CD Block Device
! WARNING: Changing the directory mode unmounts the file system. Therefore,
any open file descriptors are marked as obsolete.
■
CDROMFS_STRIP_SEMICOLON. This option sets the readdir( ) strip semicolon
setting to FALSE if arg is 0, and to TRUE otherwise. If TRUE, readdir( ) removes
the semicolon and following version number from the directory entries
retrieved.
■ CDROMFS_GET_VOL_DESC. This option returns, in arg, the primary or
supplementary volume descriptor by which the volume is mounted. arg must
be of type T_ISO_PVD_SVD_ID, as defined in cdromFsLib.h. The result is the
volume descriptor, adjusted for the endianness of the processor (not the raw
volume descriptor from the CD). This result can be used directly by the
processor. The result also includes some information not in the volume
descriptor, such as which volume descriptor is in use.
For information on using cdromFs( ), see the VxWorks API Reference entry for
cdromFsLib.
3
CD-ROM File System for VxWorks 5.5.1
Programmer’s Supplement
-> devs
drv name
0 /null
1 /tyCo/0
1 /tyCo/1
5 ala-petrient:
6 /vio
7 /cd
value = 25 = 0x19
-> cd "/cd"
value = 0 = 0x0
The cd command changes the current working directory, without performing I/O,
and, therefore, can be called before the media is mounted.
4
3
Creating and Using a CD Block Device
numbers will be returned. If you do not want version numbers, enter the
following:
-> ioctl (fd, 0x740002, 1)
Mount the device in order to access it. Because cdromFs is mounted during the first
open( ) operation, a call to open( ) or any function that uses open( ) will mount the
device. The ls command below both mounts the device and lists its contents.
5
CD-ROM File System for VxWorks 5.5.1
Programmer’s Supplement
-> ls "/cd"
/cd/.
/cd/..
/cd/INDEX.HTML;1
/cd/INSTRUCT.HTML;1
/cd/MPF
/cd/README.TXT;1
value = 0 = 0x0
6
4
Changing Disks
4. Changing Disks
The cdromFs file system must be notified when removable disks are changed (for
example, when CDs are swapped). Two different notification methods are
provided:
■ ioctl( ) FIOUNMOUNT
■ the ready-change mechanism
Unmounting Volumes
The first method of announcing a disk change is to call the ioctl( ) function
FIOUNMOUNT. This call marks any open file descriptors as obsolete. The next I/O
operation remounts the disk. Any open file descriptor to the device can be used in
the ioctl( ) call.
Attempts to use obsolete file descriptors for further I/O operations produce an
S_cdromFsLib_VOL_UNMOUNTED error. To free an obsolete descriptor, use close( )
as usual. This call frees the descriptor, although it produces the same error.
ISRs should not call ioctl( ) FIOUNMOUNT directly because the call can pend while
the device becomes available. The ISR can instead give a semaphore that prompts
a task to unmount the volume. Note that ioctl( ) FIODISKCHANGE can be called
directly from an ISR; see Announcing Disk Changes with the Ready-Change
Mechanism, p.7.
The second method of announcing that a disk change is taking place is with the
ready-change mechanism. cdromFsLib interprets a change in the disk’s ready
status to indicate that the disk must be remounted during the next I/O call.
There are two ways to announce a ready-change action:
■ By calling ioctl( ) with FIODISKCHANGE.
■ By having the device driver set the bd_readyChanged field in the BLK_DEV
structure to TRUE. This has the same effect as notifying cdromFsLib directly.
The ready-change announcement does not unmount the disk; therefore, it does not
mark file descriptors as obsolete. It merely marks the volume as needing to be
remounted.
7
CD-ROM File System for VxWorks 5.5.1
Programmer’s Supplement
A ready-change can be called from an ISR, as it does not perform actions that could
cause delay.
The block device driver status-checking routine (identified by the bd_statusChk
field in the BLK_DEV structure) is useful for asserting ready-change for devices
that only detect a disk change after the new disk is inserted. This routine is called
at the beginning of each open( ) or creat( ) call, before the file system checks for a
ready-change.
If it is not possible to announce a ready-change each time the disk is changed, close
all file descriptors for the volume before changing the disk.
FIONREAD64 6401 Gets the number of unread bytes in a file (64-bit version).
8
6
Version Numbers
FIOSEEK64 6407 Sets the current byte offset in a file (64-bit version).
FIOWHERE64 6408 Returns the current byte position in a file (64-bit version).
6. Version Numbers
cdromFsLib has a 4-byte version number. The version number is composed of four
parts, from most significant byte to least significant byte:
■ major number
■ minor number
■ patch level
■ build
The version number is returned by cdromFsVersionNumGet( ) and displayed by
cdromFsVersionNumDisplay( ).3
3. This function name uses Display rather Show in order not to clutter the output of lkup
"Show". Other VxWorks modules will include similar version number support in the future.