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

📄 tmfat32.h

📁 PNX1500上Fat32文件系统源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
                              // 1        Flush cache after a file is written in
                              //          addition to the cases in 0 and 2.
                              //          Slowest but safest in case of power
                              //          loss or device removal.
                              //
                              // 2        Flush cache after a sync/fsync call,
                              //          file close, when cached sectors need
                              //          to be replaced, or when dismounting the
                              //          volume with tmFat32_Term. Fastest but
                              //          least safe in case of power loss or
                              //          device removal.

    UInt64   baseSector;      // Starting sector where to look for the MBR (Master
                              // Boot Record). By default this is 0 but it can be
                              // anywhere on the disk in case only part of the disk
                              // was formatted.
                              
    tmFat32_NotifyEvent  eventCallback; // If not Null call whenever an event
                                        // occurs
    UInt32               eventMask;     // Mask for tmFat32_NotifyEvent.

} tmFat32_Control_t, *ptmFat32_Control_t;

typedef struct tmFat32_Info 
{
    Bool                 readOnly;      // Mounted as read only?
    Bool                 cleanDismount; // Was it dismounted cleanly the last time?
    Bool                 removable;     // Is it removable?
    UInt64               capacity;      // Capacity in bytes
    UInt64               freeBytes;     // Free bytes
    UInt32               blockSize;     // Bytes per cluster, min block allocation size
    UInt32               numSectors;    // Total number of sectors
    UInt                 maxOpenFiles;  // Maximum number of open files allowed
    UInt                 numOpenFiles;  // Number of open files.
    String               mountName;     // Mount volume name
    String               volumeName;    // DOS volume name
    tmFat32_FSType_t     fsType;        // File system type
    tmFat32_DeviceType_t deviceType;    // Device type
    UInt32               unit;          // Unit number for this device type
    UInt32               devInstance;   // Address of the instance used by the tmdlXXX
                                        // device driver (if applicable) for this volume.
                                        // E.g., for tmdlIde it could be used to manage
                                        // power for IDE devices.
    char                 serial[TM_FAT32_MAX_SERIAL_NAME+1]; // Device serial number
} tmFat32_Info_t, *ptmFat32_Info_t;

typedef struct tmFat32_PartitionInfo 
{
    // Input fields

    tmFat32_PartitionInfoRequest_t what;    // What do you want to know?

    UInt64               baseSector;        // Starting sector where to look for the MBR 
                                            // (Master Boot Record). By default this is 0
                                            // but it can be anywhere on the disk in case 
                                            // only part of the disk was formatted.

    tmFat32_DeviceType_t deviceType;        // Device type

    UInt32               unit;              // Unit number for this device type

    UInt32               partition;         // Partition number

    // Output fields

    UInt32               numUnits;          // Number of physical units for the
                                            // specified deviceType

    UInt32               numPartitions;     // Number of FAT partitions on the
                                            // specificied unit and deviceType

    tmFat32_FSType_t     fsType;            // File system type

    char                 volumeName[TM_FAT32_MAX_VOLUME_NAME+1];      // Volume name

    UInt32               numSectors;        // Total number of sectors

    UInt32               partitionBase;     // Sector number of partition start
    
} tmFat32_PartitionInfo_t, *ptmFat32_PartitionInfo_t;

/* -------------------------------------------------------------------------- */
/*    Exported functions:                                                     */
/* -------------------------------------------------------------------------- */

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_Init
//
// DESCRIPTION: Initialize tmFat32 for access to a single volume.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)
//
// NOTES:       This initializes the tmFat32 data structures for the underlying 
//				media and installs file I/O drivers.
//
//              If ctl is Null the default volume will be initialized.
//
//              On sucess, this function will ...
//-----------------------------------------------------------------------------
//

tmErrorCode_t
tmFat32_Init (
    ptmFat32_Control_t	ctl,      // I: Pointer to tmFat32_Control_t structure
    ptmFat32_Instance_t	*vol      // IO: Pointer to tmFat32 instance pointer
    );

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_GetInfo
//
// DESCRIPTION: Get information about a tmFat32 volume.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)
//
// NOTES:       Return information about a tmFat32 volume.
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_GetInfo(
    ptmFat32_Instance_t	 vol,      // I: tmFat32 instance
    ptmFat32_Info_t		info       // IO: Pointer to tmFat32_Info_t structure
    );
    
//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_GetPartitionInfo
//
// DESCRIPTION: Get information about tmFat32 partitions.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)
//
// NOTES:       Return information about tmFat32 partitions. This allows you
//              to scan a single physical unit of a specified device type and
//              find information about all tmFat32 partitions that it contains. 
//              It returns an error if the request fails. On entry the pInfo
//              structure has the field 'what' which specifies what request
//              you have. Valid requests are:
//
//              tmFat32_GetNumUnits
//
//                  For the given deviceType the function will return the
//                  maximum number of units available in the field numUnits.
//                  No other fields of pInfo will be modified.
//
//              tmFat32_GetNumPartitions
//
//                  For the given deviceType and unit the function will return 
//                  the number of FAT (FAT12, FAT16, or FAT32) partitions found
//                  in the field numPartitions. No other fields of pInfo will 
//                  be modified. Unit number is zero based, 0 is the first unit.
//
//              tmFat32_GetPartitionData
//
//                  For the given deviceType, unit, and partition the function
//                  will set the following fields in pInfo for this partition:
//                      fsType
//                      volumeName
//                      numSectors
//                      partitionBase
//                  No other fields of pInfo will be modified. Unit number and
//                  partition are zero based, e.g., partition 0 is the first
//                  partition.
//
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_GetPartitionInfo(
    ptmFat32_PartitionInfo_t  pInfo  // IO: Pointer to tmFat32_PartitionInfo_t 
                                     // structure
    );

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_GetSWVersion:
//
// DESCRIPTION: This function returns the software version information for the
//              tmFat32 component.
//
// RETURN:      TM_OK
//
// NOTES:       None
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_GetSwVersion(
    ptmSWVersion_t      pVersion);  //  O: Software version info struct ptr


//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_Format
//
// DESCRIPTION: Format a volume.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)
//
// NOTES:       If fspec is Null the volume is formatted using the
//              default format specifications.
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_Format(
    ptmFat32_Format_t    fspec     // I: Pointer format specification.
    );

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_GetAttribute
//
// DESCRIPTION: Get file or directory attribute.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS). If 'path'
//              does not exist the function will return an error and the
//              content of 'attr' is not set.
//
// NOTES:       Return FAT12/FAT16/FAT32 file or directory attributes. The 'attr'
//              argument will contain a bit mask of attributes which you can
//              AND to determine if the attribute of interest is set. E.g.,
//              if (TM_FAT32_ATTR_HIDDEN & *attr) is nonzero the file or
//              directory is hidden.
//
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_GetAttribute(
    String  path,  // I:  Pathname to file or directory
    UInt8  *attr   // IO: Pointer to a byte containing returned attributes
    );

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_SetAttribute
//
// DESCRIPTION: Get file or directory attribute.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS). Function
//              will return an error if
//                * 'path' does not exist
//                * File system is mounted readonly
//                * An attempt is made to make a file readonly if it is
//                  open for writing.
//
// NOTES:       Set FAT12/FAT16/FAT32 file or directory attributes. The 'attr'
//              argument will contain a bit mask of attributes you want to set
//              or unset. If 'enable' is True all attributes in 'attr'
//              will be set. If 'enable' is False all attributes in 'attr'
//              mask will be unset. Currently you can only set attributes
//              of files but not directories.
//
//-----------------------------------------------------------------------------
//

tmErrorCode_t tmFat32_SetAttribute(
    String  path,     // I:  Pathname to file or directory
    UInt8   attr,     // I:  Mask of attributes to set
    Bool    enable    // I:  Enable or disable
    );

//-----------------------------------------------------------------------------
// FUNCTION:    tmFat32_Term
//
// DESCRIPTION: Terminate tmFat32 for access to a single volume.
//
// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)
//
// NOTES:       This terminates access to a single tmFat32 volume.
//-----------------------------------------------------------------------------
//

tmErrorCode_t
tmFat32_Term (
    ptmFat32_Instance_t	 vol      // I: tmFat32 instance
    );

// Missing prototype in TCS

int fcntl(int fd, int cmd, ...);

/* -------------------------------------------------------------------------- */
/* End of extern c for C++ prototypes                                         */
/* -------------------------------------------------------------------------- */

#if defined(__cplusplus)
}
#endif

#endif	/* !defined(_TMFAT32_H_) */

⌨️ 快捷键说明

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