Custom Search

Wednesday, January 26, 2011

Midnight Commander

Got around to try using mc(1) (Midnight Commander)
for ftp and ssh file operations. Didn’t have any problem
with ssh, but I couldn’t get anything going with ftp except
errors, especially:

ftpfs: invalid value for ai_flags

Read the man page and the Makefile, searched some of
the OpenBSD mailing lists, and came up with:

Midnight Commander error on 4.7:

Here’s a snippet from that link:

I’m not a good C coder, so I just did some basic
research and replaced line 703 in ftpfs.c:
old: “hints.ai_flags = AI_ADDRCONFIG;”.
new: “hints.ai_flags = 1;”

Now it works as expected.


I didn’t have any idea how to do the above, but figured
it was time I learned, so first I used pkg_delete(1) to
uninstall mc(1). I knew when you build a port it will
download the port file and extract all its files in
subdirectories under /usr/ports. I found the file I
needed, ftpfs.c, under:

/data2/mktemp/obj/mc-4.7.0.6p0/mc-4.7.0.6/lib/vfs/mc-vfs

That’s because of limited space on my main drive and
fixing that problem by creating /etc/mk.conf and adding:

WRKOBJDIR=/data2/mktemp/obj
DISTDIR=/data2/mktemp/distfiles
PACKAGE_REPOSITORY=/data2/mktemp/packages


I edited ftpfs.c as described above, deleted the installed
package, changed directory into /usr/ports/misc/mc,
and did:

sudo make -D –with-vfs -D –with-samba \
-D –with-screen=slang -D –with-subshell \
-D –enable-charset


I don’t know if there is a way to tie all those together
without all the extra -D’s, and comments are welcome,
but I was tired at that point of all the searching to fix the
problem, so I did it the long way and it worked. Then I
did make install, then opened mc and this time ftp worked.
Mission accomplished! :-)

Labels: , , , , ,