Interfacing File Systems to the 64-bit File Server

Describes the changes to existing file system interface APIs.

Introduction

64-bit versions of some functions have been added to the plugin framework to allow you to handle large files. Other functions have been modified that they may now handle larger files. Changes you may need to make to existing code are detailed here.

This is a list of 32-bit functions that have been replaced with 64-bit equivalents to enable large files to be handled:

Using the CFileCB functions Size() and SetSize()

New functions have been added to the class CFileCB to allow the handling of 64-bit file sizes. File system plugins using the existing 32-bit functions to support large files should replace these with the 64-bit functions:

The 32-bit versions of these functions are used widely by the file server and the file system. Alter calls to the 32-bit versions of these functions to handle large files.

Using the CFileCB functions ReadL(), WriteL() and SetSizeL()

If you use the ReadL(), WriteL() and SetSize() functions, you must modify the implementation to replace them with their 64-bit versions:

The file system plugin developer must implement the extended interface class CFileCB::MExtendedFileInterface to perform 64-bit file accesses.

The file server retrieves the extended interface by calling CFileCB::GetInterface() with EExtendedFileInterface as an argument. Sub-classes of CFileCB that support large file access will need to inherit this class and implement the interface.

  1. Derive CYourFileSystemFileCB from the classes CFileCB and CFileCB::MExtendedFileInterface.

    class CYourFileSystemFileCB : public CFileCB,
                                  ...
                                  public CFileCB::MExtendedFileInterface
        {
    public:
        // Implement this function to return the CFileCB::MExtendedFileInterface 
        // interface pointer to the file server.
        
        virtual TInt GetInterface(TInt aInterfaceId,
                                  TAny*& aInterface,
                                  TAny* aInput);
    
    public:
        // Implement the CFileCB::MExtendedFileInterface interface extension functions 
        // for 64-bit Read, Write and SetSize.
        virtual void ReadL(TInt64 aPos,
                           TInt& aLength,
                           TDes8* aDes,
                           const RMessagePtr2& aMessage,
                           TInt aOffset);
        virtual void WriteL(TInt64 aPos,
                            TInt& aLength,
                            const TDesC8* aDes,
                            const RMessagePtr2& aMessage,
                            TInt aOffset);
        virtual void SetSizeL(TInt64 aSize);
        ...
        }
  2. In the function CYourFileSystemFileCB::GetInterface(), return the pointer to a CYourFileSystemFileCB object through the aInterface output parameter when the input parameter aInterfaceId is CFileCB::TInterfaceId::EExtendedFileInterface. This enables the file server to invoke the 64-bit functions for file access.

    TInt CYourFileSystemFileCB::GetInterface(TInt aInterfaceId, 
                                             TAny*& aInterface,
                                             TAny* aInput)
        {
        switch(aInterfaceId)
            {
            // For supporting large file ReadFileSection
            case CFileCB::EExtendedFileInterface:
                aInterface = (CFileCB::MExtendedFileInterface*) (this);
                return KErrNone;
            ...
            default:
                return(CFileCB::GetInterface(aInterfaceId, aInterface, aInput));
            }
        }
  3. Implement the CFileCB::MExtendedFileInterface functions ReadL(), WriteL() and SetSizeL() in CYourFileSystemFileCB class to provide the 64-bit file access functionality.

    void CYourFileSystemFileCB::ReadL(TInt64 aPos,
                                    TInt& aLength,
                                    TDes8* aDes,
                                    const RMessagePtr2& aMessage,
                                    TInt aOffset)
        {
        // 64-bit Read implementation.
        ...
        }
    
    void CYourFileSystemFileCB::WriteL(TInt64 aPos,
                                     TInt& aLength,
                                     const TDesC8* aDes,
                                     const RMessagePtr2& aMessage,
                                     TInt aOffset)
        {
        // 64-bit Write implementation.
        ...
        }
    
    void CYourFileSystemFileCB::SetSizeL(TInt64 aSize)
        {
        // 64-bit Set Size implementation.
        ...
        }
Note:

The CFileCB::MExtendedFileInterface also supports fair scheduling. Implementations of the functions CFileCB::MExtendedFileInterface::ReadL() and CFileCB::MExtendedFileInterface::WriteL() should also support Fair scheduling.

Using the CMountCB function ReadSectionL()

To enable large files access, calls to the 32-bit CMountCB::ReadSectionL() function should be replaced by calls to the 64-bit CMountCB::ReadSection64L() function.

ReadSection64L(const TDesC& aName, TInt64 aPos, TAny* aTrg, TInt aLength, const RMessagePtr2& aMessage)

To enable 64-bit file access, you must implement the extended interface class CMountCB::MFileExtendedInterface.

The file server retrieves the interface by calling CMountCB::GetInterface() with EFileExtendedInterface as an argument. Sub-classes of CMountCB that support large file accesses need to inherit this class and implement the interface.

  1. Derive CYourFileSystemMountCB from the classes CMountCB::MFileAccessor and CMountCB.

    class CYourFileSystemMountCB : public CMountCB, public CMountCB::MFileAccessor
        {
        ...  
    
    public:
        // Implement this function to return the CMountCB::MFileExtendedInterface
        // interface pointer to file server.
        virtual TInt GetInterface(TInt aInterfaceId,
                                  TAny*& aInterface,
                                  TAny* aInput);
        ...
    
    public:
        // The CMountCB::MFileExtendedInterface interface extension function 
        // for 64-bit read file section implementation
        virtual void ReadSection64L(const TDesC& aName, 
                                          TInt64 aPos, 
                                          TAny* aTrg, 
                                          TInt aLength,
                                          const RMessagePtr2& aMessage);
        ...
        }
  2. When your implementation of GetInterface() is passed TInterfaceIds::EFileAccessor through the aInterfaceId parameter, return a pointer to the CYourFileSystemMountCB object through the aInterface output parameter.

    TInt CYourFileSystemMountCB::GetInterface(TInt aInterfaceId, TAny*& aInterface, TAny* aInput)
        {
        switch(aInterfaceId)
            {
            case (CMountCB::EFileAccessor):
                ((CMountCB::MFileAccessor*&) aInterface) = this;
                return KErrNone;
            ...
            default:
                return(CMountCB::GetInterface(aInterfaceId, aInterface, aInput));
            }
        }
  3. Implement CYourFileSystemMountCB::ReadSection64L() to perform a 64-bit read from a file.

    void CYourFileSystemMountCB::ReadSection64L(const TDesC& aName,
                                                      TInt64 aPos,
                                                      TAny* aTrg,
                                                      TInt aLength,
                                                      const RMessagePtr2& aMessage)
        {
        // 64-bit Read File Section implementation.
        ...
        }