📄 usrdosfsold.c
字号:
/* usrDosFsOld.c - old DosFs compatibility library *//* Copyright 1998-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01j,15may02,jkf SPR#77063, adding dosFsVolFormat option to dosFsDevInit01i,14nov01,jkf general clean up, removed void * use.01h,20sep01,jkf SPR#69031, common code for both AE & 5.x.01g,26dec99,jkf T3 changes01f,31jul99,jkf T2 merge, tidiness & spelling.01e,23nov98,??? clean warning01d,14jul98,lrn usrFsLib now linked in by usrLib01c,09jul98,lrn moved definitions to dosFsLib.h, added dosFsCacheSizeDefault01b,30jun98,lrn added dosFsInit() installing all sub-modules, added PCMCIA comment, dosFsDateTimeInstall01a,24jun98,mjc written.*//*DESCRIPTIONThis library provides backward compatibility with old DosFs implementation.Many of the routines here are just stubs and the other are simply envelopes to new DosFs user interface.This backwards compatibility module is intended to allow easy upgrade ofthe MS-DOS file system without modification of any of the VxWorksconfiguration and initialization files.In some cases however this backwards compatibility interface isinsufficient, and will require the user to modify the VxWorksconfiguration code to use the new interface. One such configuration isthe PCMCIA support for x86 targets.This is strongly recommended do not use the routines from this library in thenew application design. Instead, they may be used as examples which demonstrate use of routines to initialize and configure devices in the new DosFs.LIMITATIONSSEE ALSO: dosFsLib, dcacheLib, dpartLib*//* INCLUDES */#include "vxWorks.h"#include "private/dosFsVerP.h"#include "errnoLib.h"#include "string.h"#include "stdlib.h"#include "dosFsLib.h"#include "dcacheCbio.h"#include "time.h"#include "timers.h"#include "usrLib.h"/* DEFINES */#define DEFAULT_OPTIONS 0 /* default volume options *//* locals */LOCAL UINT dosFsMkfsOptions = DEFAULT_OPTIONS; /* options to use during mkfs */LOCAL FUNCPTR pDosFsDateTimeFunc = NULL ;LOCAL BOOL dosFsInitCalled = FALSE ;/* globals */int dosFsCacheSizeDefault = 128 * 1024 ;/* forward */LOCAL void dosFsDateTimeSet (void );/********************************************************************************* dosFsInit - initialize the MS-DOS file system and related libraries** This function is part of the backward compatibility library delivered* with the new MS-DOS file system. It is intended to provide the same* interface as the old version of the MS-DOS file system, and configure* all sub-modules of the new file system implementation.** In order to avoid modifying the VxWorks configuration files, this* backward compatibility function will install all available MS-DOS file* system sub-modules. This code is provided in source so that the user may* eliminate the options which they do not require and save memory.** RETURNS: ERROR if the main dosFsLib module has failed to initialize** SEE ALSO dosFsLib*/STATUS dosFsInit (int ignored ) { IMPORT STATUS dosFsFat16Init(void); if( TRUE == dosFsInitCalled ) { return OK; } /* First initialize the main module */ if( dosFsLibInit( 0 ) == ERROR ) return ERROR; /* Initialize sub-modules */ /* Sub-module: VFAT Directory Handler */ dosVDirLibInit(); /* Sub-module: Vintage 8.2 and VxLong Directory Handler */ dosDirOldLibInit(); /* Sub-module: FAT12/FAT16/FAT32 FAT Handler */ dosFsFatInit(); /* Sub-module: Consistency check handler */ dosChkLibInit(); /* Sub-module: Formatter */ dosFsFmtLibInit(); dosFsInitCalled = TRUE ; return OK; }/********************************************************************************* dosFsDevInit - associate a block device with dosFs file system functions** This function is part of the backward compatibility library delivered* with the new MS-DOS file system. It is intended to provide the same* interface as the old version of the MS-DOS file system.** This routine takes a block device structure (BLK_DEV) created by* a device driver and defines it as a DosFs volume. As a result, when* high-level I/O operations (e.g., open(), write()) are performed on* the device, the calls will be routed through dosFsLib. The <pBlkDev>* parameter is the address of the BLK_DEV structure which describes this* device.** This routine associates the name <pDevName> with the device and installs* it in the VxWorks I/O system's device table. The driver number used when* the device is added to the table is that which was assigned to the* DosFs library during dosFsInit().** The <pConfig> parameter is now minimally supported. If <pConfig> is NULL, * it is ignored. If <pConfig> is not NULL, dosFsVolFormat is called with * default formatting options.** If the device being initialized already has a valid DosFs file system on it, * the configuration data will be read from the boot sector of the disk while * the volume will be mounted.** The specific dosFs configuration data to be used for this volume may be * provided during the volume formatting with the new dosFsVolFormat() call.** The FIODISKINIT ioctl() command can be issued now on a preformatted device * only to reformat this one.** This routine allocates and initializes a dummy volume descriptor * (DOS_VOL_DESC) for the device. It returns a pointer to DOS_VOL_DESC.* ** RETURNS: A pointer to the dummy volume descriptor DOS_VOL_DESC, or NULL if* there is an error.** SEE ALSO: dosFsMkfs()*/DOS_VOL_DESC *dosFsDevInit ( char * pDevName, /* device name */ BLK_DEV * pBlkDev, /* pointer to block device struct */ DOS_VOL_CONFIG * pConfig /* pointer to volume config data */ ) { DOS_VOL_DESC * pVolDesc; /* pointer to volume descriptor */ CBIO_DEV_ID cbio; /* Return error if no BLK_DEV */ if (pBlkDev == NULL) { errnoSet (S_dosFsLib_INVALID_PARAMETER); return (NULL); } /* make sure all modules are initialized */ if( FALSE == dosFsInitCalled ) { dosFsInit( 0 ); } /* Create e.g. 128 Kbytes disk cache */ if ( (cbio = dcacheDevCreate( (CBIO_DEV_ID) pBlkDev, NULL, dosFsCacheSizeDefault, pDevName)) == NULL ) return NULL; /* * Create file system with 20 (default) simultaneously open files and * default volume integrity check on mount level (repair + verbous_1). */ if (dosFsDevCreate (pDevName, cbio, 0, NONE) != OK) return NULL; /* * if <pConfig> is not NULL, then dosFsVolFormat the volume * This will help a subsequent diskInit() to function closer * to how dosFs1 user may expect... */ if (NULL != pConfig) { dosFsVolFormat (cbio, DOS_OPT_DEFAULT, NULL); } /* Allocate a dummy dosFs volume descriptor */ pVolDesc = (DOS_VOL_DESC *) KHEAP_ALLOC((sizeof (DOS_VOL_DESC))); if (NULL == pVolDesc) return (NULL); /* no memory */ bzero ((char *)pVolDesc, sizeof (DOS_VOL_DESC)); if ( (*pVolDesc = KHEAP_ALLOC((strlen (pDevName) + 1))) == NULL ) return NULL; /* no memory */ strcpy (*pVolDesc, pDevName); dosFsDateTimeSet(); return (pVolDesc); } /* dosFsDevInit *//********************************************************************************* dosFsDevInitOptionsSet - specify volume options for dosFsDevInit()** This function is part of the backward compatibility library delivered* with the new MS-DOS file system. It is intended to provide the same* interface as the old version of the MS-DOS file system.** Since the volume options which might be specified in this call are * inapplicable now, this routine just returns OK.** RETURNS: OK always.** SEE ALSO: dosFsDevInit(), dosFsVolOptionsSet()* */STATUS dosFsDevInitOptionsSet ( UINT options /* options for future dosFsDevInit() calls */ ) { return (OK); } /* dosFsDevInitOptionsSet *//********************************************************************************* dosFsMkfs - initialize a device and create a dosFs file system** This function is part of the backward compatibility library delivered* with the new MS-DOS file system. It is intended to provide the same* interface as the old version of the MS-DOS file system.** This routine provides a quick method of creating a DosFs file system on* a device.** It uses default values for various DosFs configuration parameters.* These defaults differ from old DosFs ones.** The only long filenames volume option is enabled by this routine now.* This option can be set using dosFsMkfsOptionsSet(). By default, no it is * enabled for disks initialized by dosFsMkfs().** RETURNS: A pointer to a dummy DosFs volume descriptor, or NULL if there is an * error.** SEE ALSO: dosFsDevInit()*/DOS_VOL_DESC * dosFsMkfs ( char * pVolName, /* volume name to use */ BLK_DEV * pBlkDev /* pointer to block device structure */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -