Author: stippi Date: 2009-11-18 10:47:42 +0100 (Wed, 18 Nov 2009) New Revision: 34106 Changeset: http://dev.haiku-os.org/changeset/34106/haiku Modified: haiku/trunk/headers/os/storage/Volume.h haiku/trunk/src/kits/storage/Volume.cpp Log: Added method BlockSize() to get the block size of the underlying file system. Untested but with good chances to actually work. Modified: haiku/trunk/headers/os/storage/Volume.h =================================================================== --- haiku/trunk/headers/os/storage/Volume.h 2009-11-18 08:55:27 UTC (rev 34105) +++ haiku/trunk/headers/os/storage/Volume.h 2009-11-18 09:47:42 UTC (rev 34106) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Haiku Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _VOLUME_H @@ -34,6 +34,7 @@ off_t Capacity() const; off_t FreeBytes() const; + off_t BlockSize() const; status_t GetName(char* name) const; status_t SetName(const char* name); Modified: haiku/trunk/src/kits/storage/Volume.cpp =================================================================== --- haiku/trunk/src/kits/storage/Volume.cpp 2009-11-18 08:55:27 UTC (rev 34105) +++ haiku/trunk/src/kits/storage/Volume.cpp 2009-11-18 09:47:42 UTC (rev 34106) @@ -232,6 +232,30 @@ return (error == B_OK ? info.free_blocks * info.block_size : error); } + +/*! \brief Returns the size of one block (in bytes). It depends on the + underlying file system what this means exactly. + \return + - The block size in bytes. + - \c B_NO_INIT if the volume is not initialized. + - Other errors forwarded from the file system. +*/ +off_t +BVolume::BlockSize() const +{ + // check initialization + if (InitCheck() != B_OK) + return B_NO_INIT; + + // get FS stat + fs_info info; + if (fs_stat_dev(fDevice, &info) != 0) + return errno; + + return info.block_size; +} + + // GetName /*! \brief Returns the name of the volume.