How do I get a list of disks in Haiku?
You can use Devices app to see physical drives.
If you want detailed infos with mount points and partitions, you can use DriveSetup app.
Edit: Forgot the obvious, if you only want to mount a partition use the right mouse button.
Or use ‘df’ in the terminal.
I meant how to get the list of disks in the program. Is there any file with this list as in Linux?
I think they mean how to get the list of disks programmatically, i.e. via the OS API.
I don’t know the answer and I can’t find anything obvious in the docs at The Haiku Book: Welcome to the Haiku Book
But actually I would be interested in this myself. At least I have a probably similar use case, in my case I’d like to get a list of CD / DVD drives available.
Maybe look at the df command sources.
Why look at a ported command from Linux?
Just look at the API documentation instead, it will be much easier to understand.
The classes you need are BVolumeRoster and BVolume which are part of the storage kit: The Be Book - System Overview
I think it is a native app
I program in Pascal and would like to port my program to Haiku. I am using libroot.so library. I can use other libraries but I don’t have OS Api documentation. The only thing I’m missing is the list of disks. On Linux it is enough to read the contents of the file “/proc/mounts”.
C++ code is not suitable for me. It can also be assembly or Pascal code.
Oh! Then you should start by having a look here.
I’m guessing the simplest way to get there is to execute df redirected to a /tmp file, and parse the output. You probably have a
system() function to execute
"df > /tmp/fslist".
@Starcrasher What’s the connection between your link and needing name demangled API references? I’m guessing you were making some underhanded slam on Pascal programmers needing to learn C++.
I would not find that amusing considering all the competing standards of APIs that could have been easily laid to rest by using FreePascal’s Object Pascal API wrappers instead of C++ and its hodgepodge of quasi-standards littered across the decentralized landscape of digital fiefdoms in the tech sector. It should be noted that Borland Delphi (now owned by Embarcadero) shares at least one author with the more recent .NET framework.
In Haiku you will have little choice, several of the APIs are available only in C++. If calling C++ directly from Pascal isn’t possible, you will have to provide your own wrappers.
This can be done manually by writing a C++ file that exports functions you need as
extern "C" (then they will have standard C calling convention and no mangling), or it can also be automated using tools like SWIG, I think.
I don’t have a compiler. Can anyone help me compile diskinfo.cpp? I want the compilation output to be a library called diskinfo.so for x64 Haiku.
You can download file diskinfo.cpp from here:
The compiler is in HaikuDepot if I don’t (or somebody else doesn’t) get around to it.
I am trying to use the compiler on a Haiku system but ran into some bugs:
undefined reference to “BDirectory::BDirectory()”
Try adding -lbe to gcc/g++ cmdl
I was able to compile the library with the -shared parameter. I encountered a message when starting my program:
“runtime_lodader: Can not open file libdi.so: No such file or directory”.
When I try to copy a file with this command:
mv libdi.so /boot/system/lib
I get the information:
mv: inter-device move failed, …, unable to remove target, Read-only file system.
You can put libraries into /boot/system/non-packaged/lib or /boot/home/config/non-packaged/lib