diff --git a/headers/os/storage/Volume.h b/headers/os/storage/Volume.h index 49462a8905..01cb793c51 100644 --- a/headers/os/storage/Volume.h +++ b/headers/os/storage/Volume.h @@ -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 @@ public: off_t Capacity() const; off_t FreeBytes() const; + off_t BlockSize() const; status_t GetName(char* name) const; status_t SetName(const char* name); diff --git a/src/kits/storage/Volume.cpp b/src/kits/storage/Volume.cpp index e73e946e94..2c05719b08 100644 --- a/src/kits/storage/Volume.cpp +++ b/src/kits/storage/Volume.cpp @@ -232,6 +232,30 @@ BVolume::FreeBytes() const 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.