You also have to take into account that some of the factors of what size will write to a particular disk is dependent on the drive in which it will be used, as some drives are able to squeeze more than others. I think there's a hanlde in the window's API for this, I'm not sure on Linux. That would be the best way to do it. Otherwise, your solution might be a little bit Kludgy.