Copying files from and to Haiku from within Linux using bfs_shell

This is a tutorial on how to use the bfs_shell to copy files to and from a Haiku partition or image from within Linux.
Please use caution when you are working with partitions. In short, if you don't know for sure what you're doing here, please don't, unless you have backups of everything and are willing to restore everything.
This tuturial assumes you have completed:

With that out of the way, there are two ways to do this:

The quick and dirty way

You can fire up the bfs_shell with jam and the path to the image or partition: jam run ":<build>bfs_shell" /dev/sda57

This will unleash bfs_shell onto a fictitious partition /dev/sda57. Replace this path with the path to your Haiku image or Haiku partition you set up in the tutorial above. You might need to change permissions if you're accessing a partition directly; this can be done with: sudo chmod o+rw /dev/sda57

After this, you will be greeted with the fssh:/> prompt.

pieter@pieter-laptop:~/develop/haiku/trunk$ sudo chmod o+rw /dev/sda57
[sudo] password for pieter:
pieter@pieter-laptop:~/develop/haiku/trunk$ jam run ":<build>bfs_shell" /dev/sda57
...found 675 target(s)...
...updating 1 target(s)...
RunCommandLine1 run_0 
bfs: mounted "Haiku" (root node at 262144, device = /dev/sda57)
fssh:/> 

To find out what bfs_shell is capable of, type in help.

fssh:/> help
supported commands:
cd               - change current directory
chmod            - change file permissions
cp               - copy files and directories
exit             - quit the shell
help             - list supported commands
ln               - create a hard or symbolic link
ls               - list files or directories
mkdir            - create directories
mkindex          - create an index
query            - query for files
quit             - quit the shell
rm               - remove files and directories
sync             - syncs the file system

Pretty much the only thing this does not explain, is that paths on Linux should be preceded with a :.
So let's try to browse around a bit.

fssh:/> ls
.:
drwxrwxrwx  0  0          0 2008-07-12 09:53:21 .
drwxrwxrwx  0  0          0 2008-07-12 09:53:21 ..
drwxr-xr-x  0  0       2048 2008-07-12 09:10:56 myfs
fssh:/> ls myfs
.:
drwxr-xr-x  0  0       2048 2008-07-12 09:10:56 .
drwxrwxrwx  0  0          0 2008-07-12 09:53:21 ..
drwxr-xr-x  0  0       2048 2008-07-12 11:13:53 apps
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 beos
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 common
drwxr-xr-x  0  0       2048 2008-07-12 11:13:53 develop
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 home
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 optional
drwxr-xr-x  0  0       2048 2008-07-12 11:13:53 preferences
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 var
fssh:/> ls myfs/home/config/settings
myfs/home/config/settings:
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 .
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 ..
-rw-r--r--  0  0        474 2008-07-12 11:43:47 Archive.zip
drwxrwxrwx  0  0       2048 2008-07-12 11:16:59 Cortex
-rw-r--r--  0  0          8 2008-07-12 11:13:52 Deskbar_security_code
-rw-r--r--  0  0         43 2008-07-12 11:45:42 Deskbar_settings
-rw-r--r--  0  0         28 2008-07-12 11:44:08 DiskProbe_data
-rw-r--r--  0  0        233 2008-07-12 11:24:08 DriveSetup
-rw-r--r--  0  0         31 2008-07-12 11:44:19 Expander_Settings
-rw-r--r--  0  0         50 2008-07-12 11:37:32 Font_Settings
-rw-r--r--  0  0       7691 2008-07-12 11:13:51 Key_map
----------  0  0         35 2008-07-12 11:37:32 Magnify_prefs
drwxr-xr-x  0  0       2048 2008-07-12 11:24:17 Media
-rw-r--r--  0  0         44 2008-07-12 11:16:42 MediaPrefs Settings
-rw-r--r--  0  0         44 2008-07-12 11:32:15 Mouse_settings
-rw-r--r--  0  0          8 2008-07-12 11:35:19 Screen_data
drwxr-xr-x  0  0       2048 2008-07-12 11:13:53 Tracker
-rw-r--r--  0  0          8 2008-07-12 11:17:16 VM_data
-rw-r--r--  0  0         55 2008-07-12 11:43:47 ZipOMatic.msg
drwxr-xr-x  0  0       2048 2008-07-12 09:11:28 beos_mime
drwxr-xr-x  0  0       2048 2008-07-12 09:10:57 kernel
-rw-r--r--  0  0        119 2008-07-12 11:45:43 print_server_settings
drwxr-xr-x  0  0       2048 2008-07-12 09:10:58 printers
drwxr-xr-x  0  0       2048 2008-07-12 11:13:50 system
-rw-------  0  0          1 2008-07-12 11:38:01 time_dststatus
-rw-r--r--  0  0         59 2008-07-12 11:45:42 x-vnd.Haiku-desklink

Now I'll copy a file I created in Haiku (/haiku/home/config/settings/Archive.zip) to Linux.

fssh:/> cp myfs/home/config/settings/Archive.zip :/home/pieter

The cp command copied source file myfs/home/config/settings/Archive.zip to destination path :/home/pieter. Here you see the where to use the : for a path on the host (Linux).
You can also copy something in the other direction in a similar way. When you're done, type exit.

fssh:/> exit
...updated 1 target(s)...

The Profile Way

Build profiles allow you to have different, well, build profiles. You can define a few and simply type jam -q @<profile_name> to compile that profile. When you've created build profiles, you will want to build Haiku this way now. They can save you a lot of modifying the UserBuildConfig if you have a lot of different images/partitions to build Haiku on. For example, as the UserBuildConfig.ReadMe suggests, you can have multiple Vmware image profiles with their own settings and their own images.

  1. Read the trunk/build/jam/UserBuildConfig.ReadMe. It is not called ReadMe for no reason, and it actually contains some neat tips and settings.
  2. Set up build profiles:
    Copy the Build Profiles section from the UserBuildConfig.ReadMe to UserBuildConfig. They should both be located in trunk/build/jam. If you don't have a UserBuildConfig yet, create one first.
  3. Use the jam -q @<profile_name> mount to start bfs_shell on a profile (pick the profile that applies to you, for me it is jam -q @disk mount). Again, you might need to change permissions on the partition as explained for the quick and dirty way. If you previously had set up the UserBuildConfig from the tutorial linked above, you may want to move the usual lines you had and place them in the right section of the UserBuildConfig, which start with this:

    case "" : {
  4. So after you've typed jam -q @<profile_name> mount, you will be greeted by the fssh:/> prompt.

    pieter@pieter-laptop:~/develop/haiku/trunk$ jam -q @disk mount
    ...found 675 target(s)...
    ...updating 1 target(s)...
    RunCommandLine1 run_0 
    bfs: mounted "Haiku" (root node at 262144, device = /dev/sda57)
    fssh:/>
    

    Now you work with the same commands as with the quick and dirty way. Start with help.

I hope this was useful, please let me know if you have any feedback.