00001 #include "kr_diskspace.h" 00002 00003 #if defined(__EPOC32__) 00004 00005 #include "ac_app_context.h" 00006 #include "application_config.h" 00007 #include "er_errors.h" 00008 00009 void CheckLoggingMediumReadyL(RFs& fs) 00010 { 00011 TChar driveLetter = DATABASE_DRIVE_LETTER; 00012 TInt driveNum = 0; 00013 User::LeaveIfError(RFs::CharToDrive(driveLetter, driveNum)); 00014 00015 // Could use RFs::IsValidDrive to check whether the drive number is 00016 // valid, but presumably this is redundant. Surely we cannot 00017 // successfully get drive information for a drive number that is not 00018 // valid. 00019 TVolumeInfo volumeInfo; 00020 User::LeaveIfError(fs.Volume(volumeInfo, driveNum)); 00021 TDriveInfo& driveInfo = volumeInfo.iDrive; 00022 00023 if (driveInfo.iType == EMediaNotPresent) { 00024 logt("logging hardware not available"); 00025 User::Leave(KErrHardwareNotAvailable); 00026 } 00027 // The C: drive seems to have the write protected attribute set (on 00028 // all the devices I have tried). 00029 if ((driveLetter != 'c') && 00030 (driveLetter != 'C') && 00031 (driveInfo.iType & KMediaAttWriteProtected)) { 00032 logt("logging medium write protected"); 00033 User::Leave(KErrAccessDenied); 00034 } 00035 00036 int database_disk_threshold = ac_STATIC_GET(database_disk_threshold); 00037 if (volumeInfo.iFree < database_disk_threshold) { 00038 logt("logging medium (almost) full"); 00039 User::Leave(KErrDiskFull); 00040 } 00041 } 00042 00043 #if 1 00044 // Optimization, use shared RFs session. 00045 00046 #include "ac_app_context.h" 00047 00048 static void CheckLoggingMediumReadyL() 00049 { 00050 RFs& fs = ac_Fs(ac_get_global_AppContext()); 00051 CheckLoggingMediumReadyL(fs); 00052 } 00053 #else 00054 static void CheckLoggingMediumReadyL() 00055 { 00056 RFs fs; 00057 User::LeaveIfError(fs.Connect()); 00058 CleanupClosePushL(fs); 00059 00060 CheckLoggingMediumReadyL(fs); 00061 00062 CleanupStack::PopAndDestroy(); // fs 00063 } 00064 #endif 00065 00066 extern "C" gboolean check_logging_medium_ready(GError** error) 00067 { 00068 TRAPD(errCode, CheckLoggingMediumReadyL()); 00069 if (errCode) { 00070 if (error) { 00071 const char* fmt; 00072 if (errCode == KErrDiskFull) 00073 fmt = "Logging medium full: %s (%d)"; 00074 else 00075 fmt = "Logging medium not ready: %s (%d)"; 00076 *error = gx_error_new(domain_symbian, errCode, fmt, plat_error_strerror(errCode), errCode); 00077 } 00078 return FALSE; 00079 } 00080 return TRUE; 00081 } 00082 00083 #endif /* defined(__EPOC32__) */ 00084 00085 /** 00086 00087 kr_diskspace.cpp 00088 00089 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00090 and the authors. All rights reserved. 00091 00092 Authors: Tero Hasu <tero.hasu@hut.fi> 00093 00094 Permission is hereby granted, free of charge, to any person 00095 obtaining a copy of this software and associated documentation files 00096 (the "Software"), to deal in the Software without restriction, 00097 including without limitation the rights to use, copy, modify, merge, 00098 publish, distribute, sublicense, and/or sell copies of the Software, 00099 and to permit persons to whom the Software is furnished to do so, 00100 subject to the following conditions: 00101 00102 The above copyright notice and this permission notice shall be 00103 included in all copies or substantial portions of the Software. 00104 00105 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00106 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00107 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00108 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00109 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00110 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00111 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00112 SOFTWARE. 00113 00114 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1