os/kernelhwsrv/userlibandfileserver/fileserver/automounter/automounter.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 
    15 /*
    16     @file
    17     @internalTechnology
    18 
    19     "fs_auto_mounter" filesystem classes definition
    20 */
    21 
    22 
    23 #ifndef AUTOMOUNTER_FILESYSTEM_H
    24 #define AUTOMOUNTER_FILESYSTEM_H
    25 
    26 #include "filesystem_utils.h"
    27 #include <f32fsys.h>
    28 #include <f32dbg.h>
    29 
    30 
    31 IMPORT_C TUint32 DebugRegister();
    32 
    33 //-- define this for having logs disregarding DebugRegister() settings
    34 //#define FORCE_LOGS
    35 
    36 
    37 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    38 //----------------- DEBUG mode -----------------
    39 
    40 #ifndef FORCE_LOGS 
    41     #define __PRINT(t)          {if (DebugRegister()&KFSYS) RDebug::Print(t);}
    42     #define __PRINT1(t,a)       {if (DebugRegister()&KFSYS) RDebug::Print(t,a);}
    43     #define __PRINT2(t,a,b)     {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b);}
    44     #define __PRINT3(t,a,b,c)   {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c);}
    45     #define __PRINT4(t,a,b,c,d) {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d);}
    46 #else
    47     #define __PRINT(t)          {RDebug::Print(t);}
    48     #define __PRINT1(t,a)       {RDebug::Print(t,a);}
    49     #define __PRINT2(t,a,b)     {RDebug::Print(t,a,b);}
    50     #define __PRINT3(t,a,b,c)   {RDebug::Print(t,a,b,c);}
    51     #define __PRINT4(t,a,b,c,d) {RDebug::Print(t,a,b,c,d);}
    52 #endif
    53 
    54 #define DBG_STATEMENT(text) text
    55 
    56 #else
    57 //----------------- RELEASE mode -----------------
    58 #define __PRINT(t)
    59 #define __PRINT1(t,a)
    60 #define __PRINT2(t,a,b)
    61 #define __PRINT3(t,a,b,c)
    62 #define __PRINT4(t,a,b,c,d)
    63 #define __PRINT8BIT1(t,a)
    64 #define __PRINT1TEMP(t,a)
    65 
    66 #define DBG_STATEMENT(text)
    67 
    68 #endif //#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    69 
    70 
    71 //#######################################################################################################################################
    72 //#     constants definitions here
    73 //#######################################################################################################################################
    74 
    75 
    76 
    77 //-----------------------------------------------------------------------------
    78 
    79 /**
    80 Internal fault codes for Automounter.fsy
    81 */
    82 enum TFault
    83     {
    84     ENotImplemented,
    85     EWrongDriveAttributes,
    86     EPluginInitialise,
    87     EFileSysNotAdded,
    88     EWrongConfiguration,
    89     EIncompatibleFileSystems,
    90 
    91     EMustNotBeCalled
    92 
    93     };
    94 
    95 //-----------------------------------------------------------------------------
    96 
    97 void Fault(TFault aFault);
    98 
    99 
   100 //-----------------------------------------------------------------------------
   101 /**
   102     This class is a container for child file system names that are supported by automounter.
   103     Child FS names are stored in Upper Case to enable simple FSName hash calculations.
   104     The names must be unique.
   105 */
   106 class XStringArray
   107     {
   108  public:
   109     XStringArray();
   110     ~XStringArray();
   111 
   112     void Reset();
   113     const TDesC& operator[](TUint aIndex) const;
   114     TInt Append(const TDesC& aString);
   115     TUint Count() const {return iStrings.Count();}
   116     TUint32 GetStringHash(TUint aIndex) const;
   117 
   118 
   119  private:
   120     XStringArray(const XStringArray&);
   121     XStringArray& operator=(const XStringArray&);
   122 
   123     /** panic codes */
   124     enum TPanicCode
   125         {
   126         EIndexOutOfRange, ///< index out of range
   127         ENotImplemented,  ///< functionality isn't implemented
   128         };
   129 
   130     void Panic(TPanicCode aPanicCode) const;
   131 
   132  private:
   133     RPointerArray<HBufC> iStrings;
   134     
   135     };
   136 
   137 
   138 //-----------------------------------------------------------------------------
   139 
   140 /**
   141     File system class definition
   142 */
   143 class CAutoMounterFileSystem : public CFileSystem, CFileSystem::MFileSystemExtInterface
   144     {
   145 public:
   146     static CAutoMounterFileSystem* New();
   147     ~CAutoMounterFileSystem();
   148 public:
   149     
   150     //-- pure virtual interface implementation, overrides from CFileSystem
   151     TInt Install();
   152     CMountCB* NewMountL() const;
   153     CFileCB* NewFileL() const;
   154     CDirCB* NewDirL() const;
   155     CFormatCB* NewFormatL() const;
   156     
   157     //-- non-pure virtual interface, overrides from CFileSystem
   158 #ifdef _DEBUG
   159     TInt Remove();
   160     TBool QueryVersionSupported(const TVersion& aVer) const;
   161 #endif
   162     
   163     TBool IsExtensionSupported() const;
   164     TInt DefaultPath(TDes& aPath) const;
   165     TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
   166     
   167     
   168     
   169     
   170 protected:
   171     CAutoMounterFileSystem();
   172 
   173     TInt TryMountFilesystem(TDrive* apDrive, CMountCB** apMount, CFileSystem** apFS);
   174 
   175 
   176     //-------------------------------
   177     virtual CMountCB* NewMountExL(TDrive* apDrive, CFileSystem** apFileSystem, TBool aForceMount, TUint32 aFsNameHash);
   178     virtual TInt GetSupportedFileSystemName(TInt aFsNumber, TDes& aFsName) const;   
   179 
   180 
   181 private:
   182     
   183     /** possible states of this object */
   184     enum TState
   185         {
   186         EInvalid = 0,       ///< initial, invalid
   187         ENotInitialised,
   188         EInitialised, 
   189         };
   190 
   191     inline TState State() const {return iState;}
   192     inline void SetState(TState aState) {iState = aState;}
   193 
   194     
   195     /** "default child" file system name index in the child names container. "default child" is used in some weir cases, when
   196         it doesn't matter which particular child FS to use, e.g. getting access to the media driver for media unlocking. */
   197     enum {KDefaultFSNo = 0}; 
   198 
   199 
   200     CFileSystem* GetChildFileSystem(TUint aIndex) const;
   201     CFileSystem* GetChildFileSysteByNameHash(TUint32 aFsNameHash) const;
   202 
   203     void InitialiseFileSystem();
   204     TInt DoProcessProxyDriveSupport();
   205 
   206 private:
   207     
   208     TState       iState;    ///< this object current state
   209     XStringArray iFSNames;  ///< child file system names container.
   210 
   211     };
   212 
   213 
   214 //-----------------------------------------------------------------------------
   215 
   216 #endif //AUTOMOUNTER_FILESYSTEM_H
   217 
   218 
   219 
   220 
   221 
   222