os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/tfatbootsector.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/tfatbootsector.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,458 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Inline methods of TFatBootSector class.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalTechnology
    1.24 + 
    1.25 + Returns Sectors in Fat table for 32 bit volume
    1.26 + 
    1.27 + @return iFatSectors32
    1.28 +*/
    1.29 +inline TUint32 TFatBootSector::FatSectors32() const	
    1.30 +	{return iFatSectors32;}
    1.31 +/**
    1.32 +Fat flags
    1.33 +
    1.34 +@return iFATFlags
    1.35 +*/
    1.36 +inline TUint16 TFatBootSector::FATFlags() const		
    1.37 +	{return iFATFlags;}
    1.38 +/**
    1.39 +Version number of the file system
    1.40 +
    1.41 +@return iVersionNumber
    1.42 +*/
    1.43 +inline TUint16 TFatBootSector::VersionNumber() const		
    1.44 +	{return iVersionNumber;}
    1.45 +/**
    1.46 +Cluster number of the root directory
    1.47 +
    1.48 +@return iRootClusterNum
    1.49 +*/
    1.50 +inline TUint32 TFatBootSector::RootClusterNum() const	
    1.51 +	{return iRootClusterNum;}
    1.52 +/**
    1.53 +Sector number containing the FSIInfo structure
    1.54 +
    1.55 +@return iFSInfoSectorNum
    1.56 +*/
    1.57 +inline TUint16 TFatBootSector::FSInfoSectorNum() const
    1.58 +	{return iFSInfoSectorNum;}
    1.59 +/**
    1.60 +Backup boot sector
    1.61 +
    1.62 +@return iBkBootRecSector
    1.63 +*/
    1.64 +inline TUint16 TFatBootSector::BkBootRecSector() const
    1.65 +	{return iBkBootRecSector;}
    1.66 +/**
    1.67 +Sets the number of sectors in Fat table for 32 bit volume
    1.68 +
    1.69 +@param aFatSectors32
    1.70 +*/
    1.71 +inline void TFatBootSector::SetFatSectors32(TUint32	aFatSectors32)
    1.72 +	{iFatSectors32 = aFatSectors32;}
    1.73 +/**
    1.74 +Sets the Fat flags
    1.75 +
    1.76 +@param aFATFlags
    1.77 +*/
    1.78 +inline void TFatBootSector::SetFATFlags(TUint16 aFATFlags)
    1.79 +	{iFATFlags = aFATFlags;}
    1.80 +/**
    1.81 +Sets the version number of the file system
    1.82 +
    1.83 +@param aVersionNumber
    1.84 +*/
    1.85 +inline void TFatBootSector::SetVersionNumber(TUint16 aVersionNumber)
    1.86 +	{iVersionNumber = aVersionNumber;}
    1.87 +/**
    1.88 +Sets the cluster number of the root directory
    1.89 +
    1.90 +@param aRootClusterNum
    1.91 +*/
    1.92 +inline void TFatBootSector::SetRootClusterNum(TUint32 aRootClusterNum)	
    1.93 +	{iRootClusterNum = aRootClusterNum;}
    1.94 +/**
    1.95 +Set the sector number containing the FSIInfo structure
    1.96 +
    1.97 +@param aFSInfoSectorNum
    1.98 +*/
    1.99 +inline void TFatBootSector::SetFSInfoSectorNum(TUint16 aFSInfoSectorNum)
   1.100 +	{iFSInfoSectorNum = aFSInfoSectorNum;}
   1.101 +/**
   1.102 +Set the backup boot sector
   1.103 +
   1.104 +@param aBkBootRecSector
   1.105 +*/
   1.106 +inline void TFatBootSector::SetBkBootRecSector(TUint16 aBkBootRecSector)
   1.107 +	{iBkBootRecSector = aBkBootRecSector;}	
   1.108 +/**
   1.109 +Quick test as to whether the volume is Fat32
   1.110 +
   1.111 +@return True for Fat32
   1.112 +*/
   1.113 +inline TBool TFatBootSector::Is32BitFat()
   1.114 +	{return(iRootDirEntries==0);}
   1.115 +/**
   1.116 +Returns the vendor ID of the file system that formatted the volume
   1.117 +
   1.118 +@return A descriptor containing the vendor ID 
   1.119 +*/
   1.120 +inline const TPtrC8 TFatBootSector::VendorId() const
   1.121 +	{return TPtrC8(iVendorId,KVendorIdSize);}
   1.122 +/**
   1.123 +Return the bytes per sector
   1.124 +
   1.125 +@return iBytesPerSector
   1.126 +*/
   1.127 +inline TUint16 TFatBootSector::BytesPerSector() const
   1.128 +	{return iBytesPerSector;}
   1.129 +/**
   1.130 +Returns the sectors per cluster ratio
   1.131 +
   1.132 +@return iSectorsPerCluster
   1.133 +*/
   1.134 +inline TInt TFatBootSector::SectorsPerCluster() const
   1.135 +	{return iSectorsPerCluster;}
   1.136 +/**
   1.137 +Returns the number of reserved sectors on the volume
   1.138 +
   1.139 +@return iReservedSectors
   1.140 +*/
   1.141 +inline TInt TFatBootSector::ReservedSectors() const
   1.142 +	{return iReservedSectors;}
   1.143 +/**
   1.144 +Returns the number of Fats on the volume
   1.145 +
   1.146 +@return iNumberOfFats
   1.147 +*/
   1.148 +inline TInt TFatBootSector::NumberOfFats() const
   1.149 +	{return iNumberOfFats;}
   1.150 +/**
   1.151 +Returns the number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
   1.152 +
   1.153 +@return iRootDirEntries
   1.154 +*/
   1.155 +inline TInt TFatBootSector::RootDirEntries() const
   1.156 +	{return iRootDirEntries;}
   1.157 +/**
   1.158 +Returns the total sectors on the volume, zero for FAT32
   1.159 +
   1.160 +@return iTotalSectors
   1.161 +*/
   1.162 +inline TInt TFatBootSector::TotalSectors() const
   1.163 +	{return iTotalSectors;}
   1.164 +/**
   1.165 +Returns the media descriptor
   1.166 +
   1.167 +@return iMediaDescriptor
   1.168 +*/
   1.169 +inline TUint8 TFatBootSector::MediaDescriptor() const
   1.170 +	{return iMediaDescriptor;}
   1.171 +/**
   1.172 +Returns sectors used for the Fat table, zero for FAT32
   1.173 +
   1.174 +@return iFatSectors
   1.175 +*/
   1.176 +inline TInt TFatBootSector::FatSectors() const
   1.177 +	{return iFatSectors;}
   1.178 +/**
   1.179 +Returns sectors per track
   1.180 +
   1.181 +@return iSectorsPerTrack
   1.182 +*/
   1.183 +inline TInt TFatBootSector::SectorsPerTrack() const
   1.184 +	{return iSectorsPerTrack;}
   1.185 +/**
   1.186 +Returns the number of heads 
   1.187 +
   1.188 +@return iNumberOfHeads
   1.189 +*/
   1.190 +inline TInt TFatBootSector::NumberOfHeads() const
   1.191 +	{return iNumberOfHeads;}
   1.192 +/**
   1.193 +Returns the number of hidden sectors in the volume
   1.194 +
   1.195 +@return iHiddenSectors
   1.196 +*/
   1.197 +inline TInt TFatBootSector::HiddenSectors() const
   1.198 +	{return iHiddenSectors;}
   1.199 +/**
   1.200 +Returns total sectors in the volume, Used if totalSectors > 65535
   1.201 +
   1.202 +@return iHugeSectors
   1.203 +*/
   1.204 +inline TInt TFatBootSector::HugeSectors() const
   1.205 +	{return iHugeSectors;}
   1.206 +/**
   1.207 +Returns the physical drive number, not used in Symbian OS
   1.208 +
   1.209 +@return iPhysicalDriveNumber
   1.210 +*/
   1.211 +inline TInt TFatBootSector::PhysicalDriveNumber() const
   1.212 +	{return iPhysicalDriveNumber;}
   1.213 +/**
   1.214 +Returns the extended boot signiture
   1.215 +
   1.216 +@return iExtendedBootSignature
   1.217 +*/
   1.218 +inline TInt TFatBootSector::ExtendedBootSignature() const
   1.219 +	{return iExtendedBootSignature;}
   1.220 +/**
   1.221 +Returns the unique volume ID
   1.222 +
   1.223 +@return iUniqueID
   1.224 +*/
   1.225 +inline TUint32 TFatBootSector::UniqueID() const
   1.226 +	{return iUniqueID;}
   1.227 +/**
   1.228 +Returns the volume's label
   1.229 +
   1.230 +@return A descriptor containing the volume label
   1.231 +*/
   1.232 +inline const TPtrC8 TFatBootSector::VolumeLabel() const
   1.233 +	{return TPtrC8(iVolumeLabel,KVolumeLabelSize);}
   1.234 +/**
   1.235 +Returns the file system type
   1.236 +
   1.237 +@return A descriptor containing the file system type
   1.238 +*/
   1.239 +inline const TPtrC8 TFatBootSector::FileSysType() const
   1.240 +	{return TPtrC8(iFileSysType,KFileSysTypeSize);}
   1.241 +/**
   1.242 +Returns the boot sector signiture
   1.243 +
   1.244 +@return KBootSectorSignature
   1.245 +*/
   1.246 +inline TInt TFatBootSector::BootSectorSignature() const
   1.247 +	{return KBootSectorSignature;}
   1.248 +/**
   1.249 +Set the jump instruction 
   1.250 +*/
   1.251 +inline void TFatBootSector::SetJumpInstruction()
   1.252 +	{iJumpInstruction[0]=0xE9;iJumpInstruction[2]=0x90;}
   1.253 +/**
   1.254 +Set the vendor ID of the file system that formatted the volume
   1.255 +
   1.256 +@param aDes Descriptor containing the Vendor ID
   1.257 +*/
   1.258 +inline void TFatBootSector::SetVendorID(const TDesC8& aDes)
   1.259 +	{
   1.260 +	__ASSERT_DEBUG(aDes.Length()<=KVendorIdSize,User::Panic(_L("FATFILESYS"),1));
   1.261 +	TPtr8 buf(iVendorId,KVendorIdSize);
   1.262 +	buf=aDes;
   1.263 +	}
   1.264 +/**
   1.265 +Sets the bytes per sector 
   1.266 +
   1.267 +@param aBytesPerSector Number of bytes per sector
   1.268 +*/
   1.269 +inline void TFatBootSector::SetBytesPerSector(TInt aBytesPerSector)
   1.270 +	{
   1.271 +	__ASSERT_DEBUG(!(aBytesPerSector&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.272 +	iBytesPerSector=(TUint16)aBytesPerSector;
   1.273 +	}
   1.274 +/**
   1.275 +Set the sectors per cluster ratio
   1.276 +
   1.277 +@param aSectorsPerCluster Number of sectors per cluster
   1.278 +*/
   1.279 +inline void TFatBootSector::SetSectorsPerCluster(TInt aSectorsPerCluster)
   1.280 +	{
   1.281 +	__ASSERT_DEBUG(!(aSectorsPerCluster&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
   1.282 +	iSectorsPerCluster=(TUint8)aSectorsPerCluster;
   1.283 +	}
   1.284 +/**
   1.285 +Sets the number of reserved sectors on the volume
   1.286 +
   1.287 +@param aReservedSectors Number of reserved sectors
   1.288 +*/
   1.289 +inline void TFatBootSector::SetReservedSectors(TInt aReservedSectors)
   1.290 +	{
   1.291 +	__ASSERT_DEBUG(!(aReservedSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.292 +	iReservedSectors=(TUint16)aReservedSectors;
   1.293 +	}
   1.294 +/**
   1.295 +Sets the number of Fats on the volume
   1.296 +
   1.297 +@param aNumberOfFats Number of fats
   1.298 +*/
   1.299 +inline void TFatBootSector::SetNumberOfFats(TInt aNumberOfFats)
   1.300 +	{
   1.301 +	__ASSERT_DEBUG(!(aNumberOfFats&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
   1.302 +	iNumberOfFats=(TUint8)aNumberOfFats;
   1.303 +	}
   1.304 +/**
   1.305 +Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
   1.306 +
   1.307 +@param aRootDirEntries
   1.308 +*/
   1.309 +inline void TFatBootSector::SetRootDirEntries(TInt aRootDirEntries)
   1.310 +	{
   1.311 +	__ASSERT_DEBUG(!(aRootDirEntries&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.312 +	iRootDirEntries=(TUint16)aRootDirEntries;
   1.313 +	}
   1.314 +/**
   1.315 +Total sectors on the volume, zero for FAT32
   1.316 +
   1.317 +@param aTotalSectors Total number of sectors
   1.318 +*/
   1.319 +inline void TFatBootSector::SetTotalSectors(TInt aTotalSectors)
   1.320 +	{
   1.321 +	__ASSERT_DEBUG(!(aTotalSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.322 +	iTotalSectors=(TUint16)aTotalSectors;
   1.323 +	}
   1.324 +/**
   1.325 +Set the media descriptor
   1.326 +
   1.327 +@param aMediaDescriptor
   1.328 +*/
   1.329 +inline void TFatBootSector::SetMediaDescriptor(TUint8 aMediaDescriptor)
   1.330 +	{iMediaDescriptor=aMediaDescriptor;}
   1.331 +/**
   1.332 +Sectors used for the Fat table, zero for FAT32
   1.333 +
   1.334 +@param aFatSectors Number of Fat sectors
   1.335 +*/
   1.336 +inline void TFatBootSector::SetFatSectors(TInt aFatSectors)
   1.337 +	{
   1.338 +	__ASSERT_DEBUG(!(aFatSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.339 +	iFatSectors=(TUint16)aFatSectors;
   1.340 +	}
   1.341 +/**
   1.342 +Set the sectors per track
   1.343 +
   1.344 +@param aSectorsPerTrack Number of sectors per track
   1.345 +*/
   1.346 +inline void TFatBootSector::SetSectorsPerTrack(TInt aSectorsPerTrack)
   1.347 +	{
   1.348 +	__ASSERT_DEBUG(!(aSectorsPerTrack&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.349 +	iSectorsPerTrack=(TUint16)aSectorsPerTrack;
   1.350 +	}
   1.351 +/**
   1.352 +Set the number of heads
   1.353 +
   1.354 +@param aNumberOfHeads Number of heads
   1.355 +*/
   1.356 +inline void TFatBootSector::SetNumberOfHeads(TInt aNumberOfHeads)
   1.357 +	{
   1.358 +	__ASSERT_DEBUG(!(aNumberOfHeads&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
   1.359 +	iNumberOfHeads=(TUint16)aNumberOfHeads;
   1.360 +	}
   1.361 +/**
   1.362 +Set the number of hidden sectors in the volume
   1.363 +
   1.364 +@param aHiddenSectors Number of hidden sectors
   1.365 +*/
   1.366 +inline void TFatBootSector::SetHiddenSectors(TUint32 aHiddenSectors)
   1.367 +	{
   1.368 +	iHiddenSectors=(TUint32)(aHiddenSectors);
   1.369 +	}
   1.370 +/**
   1.371 +Set the total sectors in the volume, Used if totalSectors > 65535
   1.372 +
   1.373 +@param aHugeSectors
   1.374 +*/
   1.375 +inline void TFatBootSector::SetHugeSectors(TUint32 aHugeSectors)
   1.376 +	{iHugeSectors=aHugeSectors;}
   1.377 +/**
   1.378 +Physical drive number, not used in Symbian OS
   1.379 +
   1.380 +@param aPhysicalDriveNumber Physical drive number 
   1.381 +*/
   1.382 +inline void TFatBootSector::SetPhysicalDriveNumber(TInt aPhysicalDriveNumber)
   1.383 +	{
   1.384 +	__ASSERT_DEBUG(!(aPhysicalDriveNumber&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
   1.385 +	iPhysicalDriveNumber=(TUint8)aPhysicalDriveNumber;
   1.386 +	}
   1.387 +/**
   1.388 +Set the reserved byte value
   1.389 +
   1.390 +@param aReservedByte Value for reserved byte
   1.391 +*/
   1.392 +inline void TFatBootSector::SetReservedByte(TUint8 aReservedByte)
   1.393 +	{iReserved=aReservedByte;}
   1.394 +/**
   1.395 +Set the extended boot signiture
   1.396 +
   1.397 +@param anExtendedBootSignature The extended boot signiture
   1.398 +*/
   1.399 +inline void TFatBootSector::SetExtendedBootSignature(TInt anExtendedBootSignature)
   1.400 +	{
   1.401 +	__ASSERT_DEBUG(!(anExtendedBootSignature&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
   1.402 +	iExtendedBootSignature=(TUint8)anExtendedBootSignature;
   1.403 +	}
   1.404 +/**
   1.405 +Set the unique volume ID
   1.406 +
   1.407 +@param anUniqueID Set the unique ID
   1.408 +*/
   1.409 +inline void TFatBootSector::SetUniqueID(TUint32 anUniqueID)
   1.410 +	{iUniqueID=anUniqueID;}
   1.411 +/**
   1.412 +Set the volume's label
   1.413 +
   1.414 +@param aDes A descriptor containg the volume label
   1.415 +*/
   1.416 +inline void TFatBootSector::SetVolumeLabel(const TDesC8& aDes)
   1.417 +	{
   1.418 +	__ASSERT_DEBUG(aDes.Length()<=KVolumeLabelSize,User::Panic(_L("FATFILESYS"),1));
   1.419 +	TPtr8 buf(iVolumeLabel,KVolumeLabelSize);
   1.420 +	buf=aDes;
   1.421 +	}
   1.422 +/**
   1.423 +Set the file system type
   1.424 +
   1.425 +@param aDes A descriptor containing the file system type
   1.426 +*/
   1.427 +inline void TFatBootSector::SetFileSysType(const TDesC8& aDes)
   1.428 +	{
   1.429 +	__ASSERT_DEBUG(aDes.Length()<=8,User::Panic(_L("FATFILESYS"),1));
   1.430 +	TPtr8 buf(iFileSysType,8);
   1.431 +	buf=aDes;
   1.432 +	}
   1.433 +/**
   1.434 +Tests if the volume is Fat 16 or not
   1.435 +
   1.436 +@return True if the volume is Fat16
   1.437 +*/
   1.438 +inline TBool TFatBootSector::Is16BitFat()
   1.439 +	{return(FileSysType()==_L8("FAT16   "));}
   1.440 +/**
   1.441 +Returns the position of the first sector of the first Fat
   1.442 +
   1.443 +@return The first Fat sector's byte position
   1.444 +*/
   1.445 +inline TInt TFatBootSector::FirstFatSectorPos()
   1.446 +	{return(ReservedSectors()*BytesPerSector());}
   1.447 +/**
   1.448 +Returns the start sector number of the root directory
   1.449 +
   1.450 +@return Start sector number of the root directory
   1.451 +*/
   1.452 +inline TInt TFatBootSector::RootDirStartSector()
   1.453 +	{return(ReservedSectors()+FatSectors()*NumberOfFats());}
   1.454 +/**
   1.455 +Returns the sector number of the first sector after the root directory 
   1.456 +
   1.457 +@return 
   1.458 +*/
   1.459 +inline TInt TFatBootSector::FirstFreeSector()
   1.460 +	{return(RootDirStartSector()+(RootDirEntries()*KSizeOfFatDirEntry+BytesPerSector()-1)/BytesPerSector());}
   1.461 +