Monday, August 23, 2010

mcopy support in fsdb for ufsutils

I have been looking for something like mcopy support in ufsutils so that I could just copy any files from userspace to the UFS filesystem. This is primarily important because by default kernel is not configured/compiled to have readwrite support for UFS. Either you need to have your own custom compiled kernel or something else so that you can mount the UFS filesystem and then do a copy.

Below is a patch (quick, ugly and dirty) which I wrote for myself which might be useful to you too. It is definitely not the best written but it does its job. Inorder to keep things simple even though I wanted to add a new command "addfile" (or something similar) to fsdb, I have removed other commands from this fsdb and just made it to work like mcopy because I needed it to be integrated with my shell scripts.

Copy the file fsdb.c in the folder ufsutils-7.0/fsdb.ufs/ and then recompile fsdb. If you have a newer version you will want to copy the contents from the original file. Just grep for "MANISH" in the file. Recompile and njoy !!!

Typical invocation would be something like

$./fsdb myufs_file_system local_file_to_copy destination_path_in_FS
eg..

$./fsdb myfs testfile.c /boot/dummyfile.c

Download fsdb.c here

Always verify your FS with fsck after running this :-). I'm not responsible if you lose your data.

* I think it has a small bug while doing truncation of files which are less than size 48K.

No comments: