Thursday, April 18, 2013

How to port the Linux Foremost data carving tool to IBMs AIX on POWER


http://foremost.sourceforge.net/pkg/foremost-1.5.3.tar.gz

[root:busen]/data/foremost-1.5.3$ make unix
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c main.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c state.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c helpers.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c config.c
config.c: In function 'translate':
config.c:27: warning: value computed is not used
config.c:32: warning: value computed is not used
config.c:37: warning: value computed is not used
config.c:42: warning: value computed is not used
config.c:47: warning: value computed is not used
config.c:52: warning: value computed is not used
config.c:57: warning: value computed is not used
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c cli.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c engine.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c dir.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c extract.c
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX -c api.c
api.c: In function 'get_dir_info':
api.c:107: warning: comparison is always false due to limited range of data type
        gcc -Wall -O2 -DVERSION=\"1.5.3\" -D__UNIX main.o state.o
helpers.o config.o cli.o engine.o dir.o extract.o api.o -o foremost
Target "unix" is up to date.
[root:busen]/data/foremost-1.5.3$ make install
        install -m 755 foremost /usr/local/bin
install: 0653-233 File 755 was not found.
make: 1254-004 The error code from the last command is 2.


Stop.

AIX has installbsd command so edit makefile.....


=================
#---------------------------------------------------------------------
# INSTALLATION AND REMOVAL
#---------------------------------------------------------------------

install: goals
        installbsd -m 755 $(NAME) $(BIN)
        installbsd -m 444 $(MAN_PAGES) $(MAN)
        installbsd -m 444 foremost.conf $(CONF)
macinstall: BIN = /usr/local/bin/
macinstall: MAN = /usr/share/man/man1/
macinstall: CONF = /usr/local/etc/
macinstall: mac install


uninstall:
        rm -f -- $(BIN)/{$(RM_GOALS)}
        rm -f -- $(MAN)/{$(RM_DOCS)}

macuninstall: BIN = /usr/bin
macuninstall: MAN = /usr/share/man/man1
macuninstall: uninstall

#---------------------------------------------------------------------
# CLEAN UP
"Makefile" 193 lines, 5188 characters
=======================

[root:busen]/data/foremost-1.5.3$ make install
        installbsd -m 755 foremost /usr/local/bin
        installbsd -m 444 foremost.1 /usr/local/man/man1
        installbsd -m 444 foremost.conf /usr/local/etc

WORKS! (I also tested it on some images)

[root:busen]/$ foremost -V
1.5.3
This program is a work of the US Government. In accordance with 17 USC 105,
copyright protection is not available for any work of the US Government.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root:busen]/$ gcc -v
Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: ../gcc-4.1.1/configure --disable-nls
Thread model: aix
gcc version 4.1.1
[root:busen]/$ ldd $(which foremost)
/usr/local/bin/foremost needs:
         /usr/lib/libc.a(shr.o)
         /unix
         /usr/lib/libcrypt.a(shr.o)