userlibandfileserver/fileserver/sfile/sf_std.h
changeset 299 b5a01337d018
parent 286 48e57fb1237e
equal deleted inserted replaced
297:b2826f67641f 299:b5a01337d018
    32 #include <e32const_private.h>
    32 #include <e32const_private.h>
    33 #include "sf_plugin.h"
    33 #include "sf_plugin.h"
    34 #include "sf_func.h"
    34 #include "sf_func.h"
    35 #include <f32plugin.h>
    35 #include <f32plugin.h>
    36 #include "f32trace.h"
    36 #include "f32trace.h"
    37 
    37 #include "sf_pool.h"
    38 
    38 
    39 #define __PRINT1TEMP_ALWAYS(t,a) {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
    39 #define __PRINT1TEMP_ALWAYS(t,a) {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
    40 #define __PRINT2TEMP_ALWAYS(t,a,b) {{TBuf<KMaxFileName>temp(b);RDebug::Print(t,a,&temp);}}
    40 #define __PRINT2TEMP_ALWAYS(t,a,b) {{TBuf<KMaxFileName>temp(b);RDebug::Print(t,a,&temp);}}
    41 #define __PRINT3TEMP_ALWAYS(t,a,b,c) {{TBuf<KMaxFileName>temp(c);RDebug::Print(t,a,b,&temp);}}
    41 #define __PRINT3TEMP_ALWAYS(t,a,b,c) {{TBuf<KMaxFileName>temp(c);RDebug::Print(t,a,b,&temp);}}
    42 #define __PRINT4TEMP_ALWAYS(t,a,b,c,d) {{TBuf<KMaxFileName>temp(d);RDebug::Print(t,a,b,c,&temp);}}
    42 #define __PRINT4TEMP_ALWAYS(t,a,b,c,d) {{TBuf<KMaxFileName>temp(d);RDebug::Print(t,a,b,c,&temp);}}
   453 	ETooManyDrivesPerSocket,
   453 	ETooManyDrivesPerSocket,
   454 	ENotificationFault,
   454 	ENotificationFault,
   455 	EFsObjectOpen,
   455 	EFsObjectOpen,
   456 	EContainerHeapCorruptionOnRemove,
   456 	EContainerHeapCorruptionOnRemove,
   457 	ESessionOpenError,
   457 	ESessionOpenError,
       
   458 	ENotifyPoolCreation,
       
   459 	ENotificationInfoDeletion
   458 	};
   460 	};
   459 
   461 
   460 
   462 
   461 NONSHARABLE_CLASS(CFsObjectConIx) : public CBase
   463 NONSHARABLE_CLASS(CFsObjectConIx) : public CBase
   462 	{
   464 	{
  1004 	{
  1006 	{
  1005 public:
  1007 public:
  1006 	TBool IsChangeNotify() const;
  1008 	TBool IsChangeNotify() const;
  1007 	TBool IsDiskSpaceNotify() const;
  1009 	TBool IsDiskSpaceNotify() const;
  1008 	TBool IsWrite() const;
  1010 	TBool IsWrite() const;
  1009 	TUint NotifyType() const;
       
  1010 	TBool IsCompleted() const;
  1011 	TBool IsCompleted() const;
  1011 	TBool IsOpenSubSess() const; //used to allocate for close as well as open task for subsessions
  1012 	TBool IsOpenSubSess() const; //used to allocate for close as well as open task for subsessions
  1012 	TBool IsCloseSubSess() const;
  1013 	TBool IsCloseSubSess() const;
  1013 
  1014 
  1014 	inline TBool IsSync() const;
  1015 	inline TBool IsSync() const;
  1207 	inline TBool DirectToDrive();
  1208 	inline TBool DirectToDrive();
  1208 	inline TBool IsDescData(TInt aMsgNum);
  1209 	inline TBool IsDescData(TInt aMsgNum);
  1209 	inline TInt FsFunction();
  1210 	inline TInt FsFunction();
  1210 	void Close();	// close the session & dispatch object this request is using
  1211 	void Close();	// close the session & dispatch object this request is using
  1211 
  1212 
  1212 public:
       
  1213 	CFsRequest();
  1213 	CFsRequest();
       
  1214 	
       
  1215 	virtual TUid Uid();
       
  1216 	
  1214 protected:
  1217 protected:
  1215 	inline void Set(const TOperation& aOperation,CSessionFs* aSession);
  1218 	inline void Set(const TOperation& aOperation,CSessionFs* aSession);
  1216 	inline void Set(CSessionFs* aSession);
  1219 	inline void Set(CSessionFs* aSession);
  1217 	inline void SetError(TInt aError);
  1220 	inline void SetError(TInt aError);
  1218 	inline TInt GetError() const;
  1221 	inline TInt GetError() const;
  1260 
  1263 
  1261 NONSHARABLE_CLASS(CFsMessageRequest) : public CFsRequest
  1264 NONSHARABLE_CLASS(CFsMessageRequest) : public CFsRequest
  1262 	{
  1265 	{
  1263 public:
  1266 public:
  1264 	void Set(const RMessage2& aMessage,CSessionFs* aSession);
  1267 	void Set(const RMessage2& aMessage,CSessionFs* aSession);
  1265 	void Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession);
  1268 	void Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession, TUid aUid = TUid::Null());
  1266 	void Set(const TOperation& aOperation);
       
  1267 	inline void SetPostInitialise(TFsRequestFunc aCacheFunction);
  1269 	inline void SetPostInitialise(TFsRequestFunc aCacheFunction);
  1268 	//
  1270 	//
  1269 	inline void SetMessage(RMessage2& aMessage);
  1271 	inline void SetMessage(RMessage2& aMessage);
  1270 	//
  1272 	//
  1271 	virtual void Process();
  1273 	virtual void Process();
  1303 	inline void Init();
  1305 	inline void Init();
  1304 	void ReStart();
  1306 	void ReStart();
  1305 	TBool IsPluginRequest();
  1307 	TBool IsPluginRequest();
  1306 	static inline CFsMessageRequest* RequestFromMessage(const RMessagePtr2& aMessage);
  1308 	static inline CFsMessageRequest* RequestFromMessage(const RMessagePtr2& aMessage);
  1307 	
  1309 	
  1308    // UID of the process to touching the file. (To be used in notification framework).
  1310 	virtual TUid Uid();
  1309    // TUid iUID;
       
  1310 private:
  1311 private:
  1311 	void DoNotify(TInt aError);
  1312 	void DoNotify(TInt aError);
  1312 	void DoNotifyDiskSpace(TInt aError);
  1313 	void DoNotifyDiskSpace(TInt aError);
  1313 	TInt DoInitialise();
  1314 	TInt DoInitialise();
  1314 	TInt PostInitialise();
  1315 	TInt PostInitialise();
  1325 	TDrive* iDrive;
  1326 	TDrive* iDrive;
  1326 	TDrive* iSubstedDrive;
  1327 	TDrive* iSubstedDrive;
  1327 private:
  1328 private:
  1328 	TMsgOperation* iCurrentOperation;
  1329 	TMsgOperation* iCurrentOperation;
  1329 	TInt iLastError;
  1330 	TInt iLastError;
       
  1331     TUid iUID;//UID of the process this message belongs to
  1330 	};
  1332 	};
  1331 
  1333 
  1332 
  1334 
  1333 NONSHARABLE_CLASS(TParsePool)
  1335 NONSHARABLE_CLASS(TParsePool)
  1334 	{
  1336 	{
  1484 
  1486 
  1485 NONSHARABLE_CLASS(CStdChangeInfo) : public CNotifyInfo
  1487 NONSHARABLE_CLASS(CStdChangeInfo) : public CNotifyInfo
  1486 	{
  1488 	{
  1487 public:
  1489 public:
  1488 	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
  1490 	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
  1489 	TUint RequestNotifyType(CFsRequest* aRequest);
  1491 	TUint RequestNotifyType(CFsNotificationInfo* aRequest);
  1490 	TBool IsMatching(CFsRequest* aRequest);
  1492 	TBool IsMatching(CFsNotificationInfo* aRequest);
  1491 protected:
  1493 protected:
  1492 	TNotifyType iChangeType;
  1494 	TNotifyType iChangeType;
  1493 	};
  1495 	};
  1494 
  1496 
  1495 NONSHARABLE_CLASS(CExtChangeInfo) : public CStdChangeInfo
  1497 NONSHARABLE_CLASS(CExtChangeInfo) : public CStdChangeInfo
  1496 	{
  1498 	{
  1497 public:
  1499 public:
  1498 	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,const TDesC& aName);
  1500 	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,const TDesC& aName);
  1499 	TBool IsMatching(CFsRequest* aRequest);
  1501 	TBool IsMatching(CFsNotificationInfo* aRequest);
  1500 private:
  1502 private:
  1501 	TFileName iName;
  1503 	TFileName iName;
  1502 	};
  1504 	};
  1503 
  1505 
  1504 NONSHARABLE_CLASS(CDiskSpaceInfo) : public CNotifyInfo
  1506 NONSHARABLE_CLASS(CDiskSpaceInfo) : public CNotifyInfo
  1555 	{
  1557 	{
  1556 public:
  1558 public:
  1557 	TInt AddNotify(CNotifyInfo* aInfo);
  1559 	TInt AddNotify(CNotifyInfo* aInfo);
  1558 	TBool CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
  1560 	TBool CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
  1559 	void CancelAll(TInt aCompletionCode);
  1561 	void CancelAll(TInt aCompletionCode);
  1560 	void CheckChange(CFsRequest* aRequest);
  1562 	void CheckChange(CFsNotificationInfo& aNotificationInfo);
  1561 	TBool IsEmpty();
  1563 	TBool IsEmpty();
  1562 	};
  1564 	};
  1563 
  1565 
  1564 class TDiskSpaceQue : public TBaseQue
  1566 class TDiskSpaceQue : public TBaseQue
  1565 	{
  1567 	{
  1596 	void CancelAll(TInt aCompletionCode);
  1598 	void CancelAll(TInt aCompletionCode);
  1597 	void CheckDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt aError);
  1599 	void CheckDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt aError);
  1598 	TBool HandlePendingDismount(CSessionFs* aSession, TInt aDrive);
  1600 	TBool HandlePendingDismount(CSessionFs* aSession, TInt aDrive);
  1599 	};
  1601 	};
  1600 
  1602 
       
  1603 class CFsNotificationInfo;
       
  1604 
       
  1605 class CFsNotificationInfoBody : public CBase
       
  1606     {
       
  1607 public:
       
  1608     CFsNotificationInfoBody();
       
  1609 private:    
       
  1610     TParsePtrC iSrc;
       
  1611     TBuf<2> iSrcBuf;
       
  1612     TParsePtrC iDest;
       
  1613     TBool iDestDriveStored;
       
  1614     TInt iDriveNumber;
       
  1615     TInt iFunction;
       
  1616     CFsRequest* iRequest; //Can be NULL
       
  1617     
       
  1618     //CFsNotify framework
       
  1619     TInt64 iData;
       
  1620     TNotificationType iNotificationType;
       
  1621     TUid iUid;
       
  1622     
       
  1623     friend class CFsNotificationInfo;
       
  1624     };
       
  1625 
       
  1626 
  1601 class FsNotify
  1627 class FsNotify
  1602 	{
  1628 	{
  1603 public:
  1629 public:
  1604 	static void Initialise();
  1630 	static void Initialise();
  1605 	static TInt AddChange(CNotifyInfo* aInfo,TInt aDrive);
  1631 	static TInt AddChange(CNotifyInfo* aInfo,TInt aDrive);
  1606 	static TInt AddDiskSpace(CNotifyInfo* aDiskInfo,TInt aDrive);
  1632 	static TInt AddDiskSpace(CNotifyInfo* aDiskInfo,TInt aDrive);
  1607 	static TInt AddDebug(CNotifyInfo* aDebugInfo);
  1633 	static TInt AddDebug(CNotifyInfo* aDebugInfo);
  1608 	static TInt AddDismountNotify(CNotifyInfo* aDismountNotifyInfo);
  1634 	static TInt AddDismountNotify(CNotifyInfo* aDismountNotifyInfo);
  1609 	static void DiskChange(TInt aDrive);
  1635 	static void DiskChange(TInt aDrive);
  1610 	static void HandleChange(CFsRequest* aRequest,TInt aDrive);
  1636 	static void HandleChange(CFsNotificationInfo& aNotificationInfo);
  1611 	static void HandleDiskSpace(CFsRequest* aRequest,TInt aDrive);
  1637 	static void HandleDiskSpace(CFsRequest* aRequest,TInt aDrive);
  1612 	static void HandleDiskSpace(TInt aDrive, TInt64& aFreeSpace);
  1638 	static void HandleDiskSpace(TInt aDrive, TInt64& aFreeSpace);
  1613 	static void HandleDebug(TUint aFunction);
  1639 	static void HandleDebug(TUint aFunction);
  1614 	static void HandleDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt err);
  1640 	static void HandleDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt err);
  1615 	static void CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
  1641 	static void CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
  1687 extern CFsObjectCon* Dirs;
  1713 extern CFsObjectCon* Dirs;
  1688 extern CFsObjectCon* Formats;
  1714 extern CFsObjectCon* Formats;
  1689 extern CFsObjectCon* RawDisks;
  1715 extern CFsObjectCon* RawDisks;
  1690 extern CFsObjectCon* Extensions;
  1716 extern CFsObjectCon* Extensions;
  1691 extern CFsObjectCon* ProxyDrives;
  1717 extern CFsObjectCon* ProxyDrives;
       
  1718 extern CFsPool<CFsNotificationInfo>* NotificationInfoPool;
  1692 
  1719 
  1693 extern CKernEventNotifier* TheKernEventNotifier;
  1720 extern CKernEventNotifier* TheKernEventNotifier;
  1694 
  1721 
  1695 extern RThread TheServerThread;
  1722 extern RThread TheServerThread;
  1696 extern RAllocator* ServerThreadAllocator;
  1723 extern RAllocator* ServerThreadAllocator;
  1765 //#ifdef __DATA_CAGING__
  1792 //#ifdef __DATA_CAGING__
  1766 
  1793 
  1767  TBool CompareResource(const TDesC & aThePath);
  1794  TBool CompareResource(const TDesC & aThePath);
  1768 
  1795 
  1769 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1796 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1770  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const char* aDiag);
  1797  TInt PathCheck(const RMessage2& aMessage, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const char* aDiag);
  1771  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, const char* aDiag);
  1798  TInt PathCheck(const RMessage2& aMessage, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, const char* aDiag);
  1772  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath,const TSecurityPolicy* aCap, const char* aDiag, TBool aExactMatchAllowed = EFalse);
  1799  TInt PathCheck(const RMessage2& aMessage, const TDesC& aThePath,const TSecurityPolicy* aCap, const char* aDiag, TBool aExactMatchAllowed = EFalse);
  1773 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1800 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1774  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, OnlyCreateWithNull aDiag);
  1801  TInt PathCheck(const RMessage2& aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, OnlyCreateWithNull aDiag);
  1775  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, OnlyCreateWithNull aDiag); 
  1802  TInt PathCheck(const RMessage2& aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, OnlyCreateWithNull aDiag); 
  1776  TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath,const TSecurityPolicy* aCap, OnlyCreateWithNull aDiag, TBool aExactMatchAllowed = EFalse);
  1803  TInt PathCheck(const RMessage2& aRequest, const TDesC& aThePath,const TSecurityPolicy* aCap, OnlyCreateWithNull aDiag, TBool aExactMatchAllowed = EFalse);
  1777 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1804 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  1778 
  1805 
  1779  TBool ComparePrivate(const TDesC & aThePath);
  1806  TBool ComparePrivate(const TDesC & aThePath);
  1780  TBool CompareSystem(const TDesC & aThePath);
  1807  TBool CompareSystem(const TDesC & aThePath);
  1781  TBool SIDCheck(CFsRequest* aRequest, const TDesC& aThePath);
  1808  TBool SIDCheck(const RMessage2& aMessage, const TDesC& aThePath);
  1782  TBool ComparePaths(const TDesC& aPath1,const TDesC& aPath2);
  1809  TBool ComparePaths(const TDesC& aPath1,const TDesC& aPath2);
  1783  TUint32 CalcNameHash(const TDesC& aName);
  1810  TUint32 CalcNameHash(const TDesC& aName);
  1784 
  1811 
  1785 const TInt KResourceLength			=	9;
  1812 const TInt KResourceLength			=	9;
  1786 const TInt KSystemLength			=	4;
  1813 const TInt KSystemLength			=	4;