Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Accessing File Systems Larger than 4GB

The IFileMgr interface does not provide complete support for file systems larger than 4GBytes due to the 32-bit unsigned integer limitation. The maximum amount of space expressible with a 32-bit unsigned integer is 4GBytes (2^32 = 4294967296 Bytes = 4 GBytes).

Due to the 4GByte limitation, Brew MP applications cannot determine accurately the total and free space on a file system larger than 4GBytes. As a direct result, when more than 4GBytes of space is available as total or free space, the result returned by the existing APIs (i.e. IFILEMGR_GetFreeSpace() and IFILEMGR_GetFreeSpaceEx()) will not be accurate.

Despite this limitation, the other access functions (e.g. read, write) operate correctly on file systems larger than 4GBytes.

Problem resolution

The Brew MP ISHELL_GetDeviceInfoEx() function retrieves information for a specific Device Item ID, which can be used to retrieve the total space and free space for the following file system locations:

  • External Memory Storage: File system space accessible via the canonical file path "fs:/card0/" or the AEEFS_CARD0_DIR macro.
  • Internal Memory Storage: File system space accessible via the canonical file path "fs:/" or the AEEFS_ROOT_DIR macro.
  • USB Memory Storage: File system spaces accessible via the AEEFS_USB_HOST_MASS_STORAGE1 and AEEFS_USB_HOST_MASS_STORAGE2.

The mapping of these file storage spaces to Device Item IDs is shown in the following table:

Storage File Path Macro Device Item ID

External Memory Storage

AEEFS_CARD0_DIR

AEE_DEVICEITEM_FSSPACE_CARD0

Internal Memory Storage

AEEFS_ROOT_DIR

AEE_DEVICEITEM_FSSPACE_ROOT

USB Memory Storage 1

AEEFS_USB_HOST_MASS_STORAGE1

AEE_DEVICEITEM_FSSPACE_USBHMS1

USB Memory Storage 2

AEEFS_USB_HOST_MASS_STORAGE2

AEE_DEVICEITEM_FSSPACE_USBHMS2

One of the required parameters to ISHELL_GetDeviceInfoEx() is the AEEFSFreeSpace structure, which is defined as follows:

typedef struct _AEEFSFreeSpace
 {
    uint64 qwTotalSpace;  // [out] Total space in bytes
                          // on the File System
    uint64 qwFreeSpace;   // [out] Free space in	bytes
                          // on the File System
 } AEEFSFreeSpace; 
		

Where:

  • qwTotalSpace contains the total space on the file system specified by the Device Item ID
  • qwFreeSpace contains the free space on the file system specified by the Device Item ID

Any Brew MP application or extension that expects to deal with file systems larger than 4GBytes needs to replace all calls to IFILEMGR_GetFreeSpace() and IFILEMGR_GetFreeSpaceEx() with calls to ISHELL_GetDeviceInfoEx. The following topics show the required code changes for different types of file systems.

Limitations

  • File Size Limitation: this solution does not allow any single file on the file system to be larger than 4GBytes; therefore, the largest file that a Brew MP application or extension can operate with cannot exceed 4GBytes.
  • Privilege Check: IFILEMGR_GetFreeSpace() and IFILEMGR_GetFreeSpaceEx() check whether the caller has read access to the path specified when retrieving the file system free and total space information. However, ISHELL_GetDeviceInfoEx() with the new Device Items does not make this privilege check. The impact to Brew MP applications is that just to query for the file system free and total space it does not require any privileges. All other file system functions (e.g. read, write, create, delete, etc.) are still protected under the PL_FILE privilege.