⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosfslib.c

📁 vxworks操作系统的文件系统部分原代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    fd = open ("file", O_RDONLY);    status = ioctl (fd, FIOTIMESET, (int)&newTimeBuf);.CE.iP "FIOCHKDSK"This function invokes the integral consistency checking.During the test, the file system will be blocked from application codeaccess, and will emit messages describing any inconsistencies found onthe disk, as well as some statistics, depending on the verbositylevel in the <flags> argument.Depending on the repair permission value in <flags> argument,the inconsistencies will be repaired, and changes written to diskor only reported.Argument <flags> should be composed of bitwise or-edverbosity level value and repair permission value.Possible repair levels are:.RS.iP "DOS_CHK_ONLY (1)"Only report errors, do not modify disk..iP "DOS_CHK_REPAIR (2)"Repair any errors found..LPPossible verbosity levels are:.iP "DOS_CHK_VERB_SILENT (0xff00)"Do not emit any messages, except errors encountered..iP "DOS_CHK_VERB_1 (0x0100)"Display some volume statistics when done testing, as well.iP "DOS_CHK_VERB_2 (0x0200)"In addition to the above option, display path of every file, while itis being checked. This option may significantly slow down the testprocess..IP "NOTE"In environments with reduced RAM size check disk uses reservedFAT copy as temporary buffer, it can cause respectively longtime of execution on a slow CPU architectures...LP.RESee also the reference manual usrFsLib for the chkdsk() user levelutility which may be used to invoke the FIOCHKDSK ioctl().The volume root directory should be opened, and the resulting filedescriptor should be used:.CS    int fd = open (device_name, O_RDONLY, 0);    status = ioctl (fd, FIOCHKDSK, DOS_CHK_REPAIR | DOS_CHK_VERB_1);    close (fd);.CE.LPAny other ioctl() function codes are passed to the underlying.I CBIOmodules for handling.INCLUDE FILES: dosFsLib.hSEE ALSO:ioLib, iosLib, dirLib, usrFsLib, dcacheCbio, dpartCbio, dosFsFmtLib,dosChkLib.I "Microsoft MS-DOS Programmer's Reference"(Microsoft Press),.I "Advanced MS-DOS Programming"(Ray Duncan, Microsoft Press),.I "VxWorks Programmer's Guide: I/O System, Local File Systems"INTERNAL:Note:  To represent a backslash in documentation use "\e", not "\\".The double backslash sometimes works, but results may be unpredictable.*//* includes */#include "vxWorks.h"#include "private/dosFsVerP.h"#include "stat.h"#include "time.h"#include "dirent.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "taskLib.h"#include "tickLib.h"#include "semLib.h"#include "logLib.h"#include "errnoLib.h"#include "memLib.h"#include "utime.h"#include "blkIo.h"#include "private/print64Lib.h"#include "private/dosFsLibP.h"#include "private/dosDirLibP.h"/* defines */#if FALSE#   undef FAT_ALLOC_ONE#   define FAT_ALLOC_ONE        (FAT_ALLOC | 8)#endif /* FALSE *//* macros */#undef DBG_MSG#undef ERR_MSG#undef NDEBUG#ifdef DEBUG#   undef LOCAL#   define LOCAL#   undef ERR_SET_SELF#   define ERR_SET_SELF#   define DBG_MSG( lvl, fmt, arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8 )	\	{ if( (lvl) <= dosFsDebug )					\	    printErr( "%s : %d : " fmt,				\	               __FILE__, __LINE__, arg1,arg2,	\		       arg3,arg4,arg5,arg6,arg7,arg8 ); }#   define ERR_MSG( lvl, fmt, a1,a2,a3,a4,a5,a6 )		\        { logMsg( __FILE__ " : " fmt, (int)(a1), (int)(a2),	\		  (int)(a3), (int)(a4), (int)(a5), (int)(a6) ); }#else	/* NO DEBUG */#   define NDEBUG#   define DBG_MSG(lvl,fmt,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) 	{}#   define ERR_MSG( lvl, fmt, a1,a2,a3,a4,a5,a6 )		\	{ if( (lvl) <= dosFsDebug ) 				\            logMsg( __FILE__ " : " fmt, (int)(a1), (int)(a2),	\		  (int)(a3), (int)(a4), (int)(a5), (int)(a6) ); }#endif /* DEBUG */#include "assert.h"#ifdef ERR_SET_SELF#   define errnoSet( err ) errnoSetOut( __FILE__, __LINE__, #err, (err) )#endif /* ERR_SET_SELF *//* typedefs *//* globals */int	dosFsDrvNum = ERROR; /* dosFs number in vxWorks driver table */u_int	dosFsDebug = 1;/* handlers lists */DOS_HDLR_DESC    dosFatHdlrsList[ DOS_MAX_HDLRS ] = {{0}};DOS_HDLR_DESC    dosDirHdlrsList[ DOS_MAX_HDLRS ] = {{0}};STATUS (*dosFsChkRtn)( DOS_FILE_DESC_ID pFd ) = NULL;					/* check disk routine */STATUS (*dosFsVolFormatRtn)( void * pDev, int opt,                             FUNCPTR pPromptFunc ) = NULL;                          		/* volume format routine *//* locals */LOCAL STATUS dosFsRead( FAST DOS_FILE_DESC_ID pFd, char * pBuf,                        int maxBytes );LOCAL STATUS dosFsIoctl ( FAST DOS_FILE_DESC_ID pFd, int function, int arg );LOCAL DOS_FILE_DESC_ID dosFsOpen ( FAST DOS_VOLUME_DESC * pVolDesc,                                  char * pPath, int flags, int mode );LOCAL STATUS dosFsDelete (DOS_VOLUME_DESC_ID pVolDesc, char * pPath);LOCAL STATUS dosFsClose  (DOS_FILE_DESC_ID pFd);LOCAL STATUS dosFsRename (DOS_FILE_DESC_ID    pFdOld, char * pNewName,                          BOOL        allowOverwrite);#ifdef ERR_SET_SELF/******************************************************************************** errnoSetOut - put error message** This routine is called instead of errnoSet during debugging.*/static VOID errnoSetOut(char * pFile, int line, const char * pStr, int errCode )    {    if( errCode != OK && strcmp( str, "errnoBuf" ) != 0 )        printf( " %s : line %d : %s = %p, task %p\n",                pFile, line, pStr, (void *)errCode,                (void *)taskIdSelf() );    errno = errCode;    }#endif  /* ERR_SET_SELF *//********************************************************************************* dosSetVolCaseSens - set case sensitivity of volume** Pass TRUE to setup a case sensitive volume.  * Pass FALSE to setup a case insensitive volume.  * Note this affects rename lookups only.** RETURNS: TRUE if pVolDesc pointed to a DOS volume.*/STATUS dosSetVolCaseSens     (     DOS_VOLUME_DESC_ID pVolDesc,     BOOL sensitivity     )    {    BOOL isValid; /* Validity flag */    /* If the parameter is aligned OK */    if ( TRUE == (isValid = _WRS_ALIGN_CHECK(pVolDesc, DOS_VOLUME_DESC)))        {        /* Aligned parameter, but is it a DOS volume? */        if ( TRUE == (isValid = (pVolDesc->magic == DOS_FS_MAGIC )) )            {            pVolDesc->volIsCaseSens = sensitivity;            }        }    /* Didn't work? Broken parameter then */    if (FALSE == isValid)        {        /* Not a DOS volume or not aligned so that's an invalid parameter */        errnoSet( S_dosFsLib_INVALID_PARAMETER );        }    /* If it was valid it got set. */    return (isValid);    }/********************************************************************************* dosFsIsValHuge - check if value is grater, than 4GB (max 32 bit).** RETURNS: TRUE if is grater, else return FALSE.*/LOCAL BOOL dosFsIsValHuge    (    fsize_t	val    )    {    return DOS_IS_VAL_HUGE( val );    } /* dosFsIsValHuge() *//********************************************************************************* dosFsVolDescGet - convert a device name into a DOS volume descriptor pointer.* * This routine validates <pDevNameOrPVolDesc> to be a DOS volume* descriptor pointer else a path to a DOS device. This routine * uses the standard iosLib function iosDevFind() to obtain a pointer * to the device descriptor. If device is eligible, <ppTail> is * filled with the pointer to the first character following* the device name.  Note that ppTail is passed to iosDevFind().* <ppTail> may be passed as NULL, in which case it is ignored.** RETURNS: A DOS_VOLUME_DESC_ID or NULL if not a DOSFS device.** ERRNO:* S_dosFsLib_INVALID_PARAMETER*/DOS_VOLUME_DESC_ID dosFsVolDescGet    (    void *      pDevNameOrPVolDesc, /* device name or pointer to dos vol desc */    u_char **   ppTail      /* return ptr for name, used in iosDevFind */        )    {    DOS_VOLUME_DESC_ID	pVolDesc;	/* pointer to volume descriptor */    char *      pDevName = (pDevNameOrPVolDesc == NULL) ?    			  "" : pDevNameOrPVolDesc;    u_char *    pNameTail;    if( ppTail == NULL )    	ppTail = &pNameTail;        *ppTail = NULL;        pVolDesc = pDevNameOrPVolDesc;        /* SPR#71720 NULL is presumed to be an invalid value */        if (NULL == pVolDesc)        {        errnoSet( S_dosFsLib_INVALID_PARAMETER );	return (NULL);        }    /* SPR#71720 ensure alignment and then check the magic cookie */    if (TRUE == _WRS_ALIGN_CHECK(pVolDesc, DOS_VOLUME_DESC))        {        if (pVolDesc->magic == DOS_FS_MAGIC )            {    	    return (pVolDesc);            }        }    /* attempt to extract volume descriptor ptr from device name */    #ifdef _WRS_DOSFS2_VXWORKS_AE    pVolDesc =      (DOS_VOLUME_DESC_ID) iosDevFind (pDevName, (const char **)ppTail);#else    pVolDesc =      (DOS_VOLUME_DESC_ID) iosDevFind (pDevName, (char **) ppTail);#endif /* _WRS_DOSFS2_VXWORKS_AE */    /*      * SPR#76510, if iosDevFind() returned default device,     * then the tail (ppTail) will point to the front of     * the passed name and that is considered a lookup failure.     */    if ((NULL == pVolDesc) || ((char *) *ppTail == pDevName))        {        errnoSet( S_dosFsLib_INVALID_PARAMETER );	return (NULL);        }    /* SPR#71720 ensure alignment and then check the magic cookie */    if (TRUE == _WRS_ALIGN_CHECK(pVolDesc, DOS_VOLUME_DESC))        {        if (pVolDesc->magic == DOS_FS_MAGIC )            {    	    return (pVolDesc);            }        }        errnoSet( S_dosFsLib_INVALID_PARAMETER );     return (NULL);    } /* dosFsVolDescGet() *//********************************************************************************* dosFsFSemTake - take file semaphore.** RETURNS: STATUS as result of semTake.*/LOCAL STATUS dosFsFSemTake    (    DOS_FILE_DESC_ID	pFd,    int			timeout    )    {    STATUS retStat;    assert( pFd - pFd->pVolDesc->pFdList < pFd->pVolDesc->maxFiles );    assert( pFd->pFileHdl - pFd->pVolDesc->pFhdlList <            pFd->pVolDesc->maxFiles );    retStat =  semTake( *(pFd->pVolDesc->pFsemList +     		        (pFd->pFileHdl - pFd->pVolDesc->pFhdlList)),                        timeout);    assert( retStat == OK );    return retStat;    } /* dosFsFSemTake() */    /********************************************************************************* dosFsFSemGive - release file semaphore.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -