diff -NPru sash-3.4/Makefile sash/Makefile --- sash-3.4/Makefile Sat Sep 25 07:21:56 1999 +++ sash/Makefile Sun Jan 23 00:01:25 2000 @@ -5,27 +5,31 @@ # The HAVE_EXT2 definition adds the -chattr and -lsattr comamnds. # -CFLAGS = -O3 -Wall -Wmissing-prototypes -DHAVE_GZIP -DHAVE_EXT2 -LDFLAGS = -static -s -LIBS = -lz +## FreeBSD: add/remove components as needed. HAVE_EXT2 doesn't work +## for us... +OPTS+=-DHAVE_AR +OPTS+=-DHAVE_DD +OPTS+=-DHAVE_ED +OPTS+=-DHAVE_FILE +OPTS+=-DHAVE_FIND +OPTS+=-DHAVE_GREP +OPTS+=-DHAVE_GZIP +OPTS+=-DHAVE_LS +OPTS+=-DHAVE_TAR + +PROG=sash +CFLAGS += -O2 -Wall -Wmissing-prototypes $(OPTS) +LDADD += -static -s -lz -BINDIR = /bin -MANDIR = /usr/man/man1 +BINDIR = ${PREFIX}/bin +MANDIR = ${PREFIX}/man/man1 - -OBJS = sash.o cmds.o cmd_dd.o cmd_ed.o cmd_grep.o cmd_ls.o cmd_tar.o \ - cmd_gzip.o cmd_find.o cmd_file.o cmd_chattr.o cmd_ar.o utils.o - - -sash: $(OBJS) - $(CC) $(LDFLAGS) -o sash $(OBJS) $(LIBS) - -clean: - rm -f $(OBJS) sash +SRCS= sash.c cmds.c cmd_dd.c cmd_ed.c cmd_grep.c cmd_ls.c cmd_tar.c \ + cmd_gzip.c cmd_find.c cmd_file.c cmd_chattr.c cmd_ar.c utils.c install: sash cp sash $(BINDIR)/sash cp sash.1 $(MANDIR)/sash.1 -$(OBJS): sash.h +.include diff -NPru sash-3.4/README.FreeBSD sash/README.FreeBSD --- sash-3.4/README.FreeBSD Thu Jan 1 01:00:00 1970 +++ sash/README.FreeBSD Sun Jan 23 00:03:20 2000 @@ -0,0 +1,29 @@ +This is a port of SASH to FreeBSD 4.0. Here are the differences to +the original version: + +* The Makefile was rewritten to make use of standard BSD makefiles. + This helps integrating SASH into binaries built with crunchgen. + +* This port contains only a subset of 'mount -t type' commands. The + types that are supported are: + + ufs,msdos,ext2fs,cd9660 + + (the naming follows standard mount(8) command in FreeBSD). + + However, the only supported options for mounting are either read/write + (default, except for cd9660), read-only, or updating the mount + (NOTE: the original code uses '-m', but I changed it to '-u' + to be consistent with standard FreeBSD mount(8) ). + + Also, the built-in mount command doesn't even attempt to autoload + requested vfs KLD, if it's not present in the kernel. In such + case, the mount operation will fail. + +* The code has been modularized (in similar way it was done for ELKS + version), so you can easier select which parts you want to include. + See the Makefile for the options. + +Andrzej Bialecki + +Stockholm, 22.01.2000 diff -NPru sash-3.4/cmd_ar.c sash/cmd_ar.c --- sash-3.4/cmd_ar.c Sat Oct 2 12:09:04 1999 +++ sash/cmd_ar.c Sat Jan 22 23:45:10 2000 @@ -13,6 +13,8 @@ * This allows extraction and listing of ar files. */ +#ifdef HAVE_AR + #include #include #include @@ -1007,5 +1009,6 @@ arch->name); } +#endif /* HAVE_AR */ /* END CODE */ diff -NPru sash-3.4/cmd_dd.c sash/cmd_dd.c --- sash-3.4/cmd_dd.c Sun Apr 11 09:31:39 1999 +++ sash/cmd_dd.c Sat Jan 22 23:45:39 2000 @@ -6,6 +6,8 @@ * The "dd" built-in command. */ +#ifdef HAVE_DD + #include "sash.h" @@ -346,5 +348,7 @@ return value; } + +#endif /* HAVE_DD */ /* END CODE */ diff -NPru sash-3.4/cmd_ed.c sash/cmd_ed.c --- sash-3.4/cmd_ed.c Mon Apr 19 16:57:32 1999 +++ sash/cmd_ed.c Sat Jan 22 23:46:01 2000 @@ -6,6 +6,8 @@ * The "ed" built-in command (much simplified) */ +#ifdef HAVE_ED + #include "sash.h" #define USERSIZE 1024 /* max line length typed in by user */ @@ -1432,5 +1434,7 @@ return TRUE; } + +#endif /* HAVE_ED */ /* END CODE */ diff -NPru sash-3.4/cmd_file.c sash/cmd_file.c --- sash-3.4/cmd_file.c Sun Apr 11 09:31:39 1999 +++ sash/cmd_file.c Sat Jan 22 23:46:23 2000 @@ -6,6 +6,8 @@ * The "file" built-in command. */ +#ifdef HAVE_FILE + #include #include #include @@ -229,5 +231,7 @@ return info; } + +#endif /* HAVE_FILE */ /* END CODE */ diff -NPru sash-3.4/cmd_find.c sash/cmd_find.c --- sash-3.4/cmd_find.c Tue Apr 20 00:48:45 1999 +++ sash/cmd_find.c Sat Jan 22 23:47:12 2000 @@ -6,6 +6,8 @@ * The "find" built-in command. */ +#ifdef HAVE_FIND + #include #include #include @@ -370,5 +372,7 @@ */ return TRUE; } + +#endif /* HAVE_FIND */ /* END CODE */ diff -NPru sash-3.4/cmd_grep.c sash/cmd_grep.c --- sash-3.4/cmd_grep.c Sun Apr 11 09:31:39 1999 +++ sash/cmd_grep.c Sat Jan 22 23:47:32 2000 @@ -6,6 +6,8 @@ * The "grep" built-in command. */ +#ifdef HAVE_GREP + #include #include "sash.h" @@ -187,5 +189,7 @@ string++; } } + +#endif /* HAVE_GREP */ /* END CODE */ diff -NPru sash-3.4/cmd_gzip.c sash/cmd_gzip.c --- sash-3.4/cmd_gzip.c Tue Apr 20 13:46:17 1999 +++ sash/cmd_gzip.c Sat Jan 22 23:47:44 2000 @@ -666,6 +666,6 @@ } -#endif +#endif /* HAVE_GZIP */ /* END CODE */ diff -NPru sash-3.4/cmd_ls.c sash/cmd_ls.c --- sash-3.4/cmd_ls.c Wed Jun 16 13:01:43 1999 +++ sash/cmd_ls.c Sat Jan 22 23:48:06 2000 @@ -6,6 +6,8 @@ * The "ls" built-in command. */ +#ifdef HAVE_LS + #include "sash.h" #include @@ -574,5 +576,7 @@ free(list[listUsed]); } } + +#endif /* HAVE_LS */ /* END CODE */ diff -NPru sash-3.4/cmd_tar.c sash/cmd_tar.c --- sash-3.4/cmd_tar.c Sun Apr 18 14:33:59 1999 +++ sash/cmd_tar.c Sat Jan 22 23:48:24 2000 @@ -7,6 +7,8 @@ * This allows creation, extraction, and listing of tar files. */ +#ifdef HAVE_TAR + #include "sash.h" #include @@ -1229,5 +1231,7 @@ return FALSE; } + +#endif /* HAVE_TAR */ /* END CODE */ diff -NPru sash-3.4/cmds.c sash/cmds.c --- sash-3.4/cmds.c Thu Jun 3 23:42:39 1999 +++ sash/cmds.c Sun Jan 23 00:35:15 2000 @@ -6,17 +6,22 @@ * Most simple built-in commands are here. */ -#include "sash.h" - #include #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include #include #include #include +#ifdef linux #include +#endif + +#include "sash.h" void @@ -501,19 +506,34 @@ } } +#ifdef __FreeBSD__ +#include +#include +#include +#endif void do_mount(int argc, const char ** argv) { - const char * str; - const char * type; - int flags; + const char * str; + const char * type; +#ifdef __FreeBSD__ + u_long flags=0; + struct ufs_args ufs; + struct msdosfs_args msdos; + struct iso_args iso; + void *args; +#else + int flags=MS_MGC_VAL; +#endif argc--; argv++; +#ifdef linux type = "ext2"; - flags = MS_MGC_VAL; - +#else + type = "ufs"; +#endif while ((argc > 0) && (**argv == '-')) { argc--; @@ -533,6 +553,7 @@ argc--; break; +#ifdef linux case 'r': flags |= MS_RDONLY; break; @@ -540,6 +561,16 @@ case 'm': flags |= MS_REMOUNT; break; +#endif +#ifdef __FreeBSD__ + case 'r': + flags |= MNT_RDONLY; + break; + + case 'u': + flags |= MNT_UPDATE; + break; +#endif default: fprintf(stderr, "Unknown option\n"); @@ -555,15 +586,44 @@ return; } +#ifdef linux if (mount(argv[0], argv[1], type, flags, 0) < 0) perror("mount failed"); +#endif +#ifdef __FreeBSD__ + /* Select type of struct args */ + if(strcmp(type,"ufs")==0) { + ufs.fspec=argv[0]; + args=&ufs; + } else if(strcmp(type,"msdos")==0) { + msdos.fspec=argv[0]; + args=&msdos; + } else if(strcmp(type,"ext2fs")==0) { + ufs.fspec=argv[0]; + args=&ufs; + } else if(strcmp(type,"cd9660")==0) { + iso.fspec=argv[0]; + flags|=MNT_RDONLY; + args=&iso; + } else { + fprintf(stderr,"Unsupported FS type %s\n",type); + return; + } + if(mount(type,argv[1],flags,args)!=0) { + perror("mount failed"); + } +#endif } void do_umount(int argc, const char ** argv) { +#ifdef __FreeBSD__ + if (unmount(argv[1],0) < 0) +#else if (umount(argv[1]) < 0) +#endif perror(argv[1]); } diff -NPru sash-3.4/sash.c sash/sash.c --- sash-3.4/sash.c Sat Sep 25 06:03:51 1999 +++ sash/sash.c Sat Jan 22 23:50:57 2000 @@ -57,11 +57,13 @@ "" }, +#ifdef HAVE_AR { "-ar", do_ar, 3, INFINITE_ARGS, "Extract or list files from an AR file", "[txp]v arFileName fileName ..." }, +#endif { "cd", do_cd, 1, 2, @@ -107,11 +109,13 @@ "srcName ... destName" }, +#ifdef HAVE_DD { "-dd", do_dd, 3, INFINITE_ARGS, "Copy data between two files", "if=name of=name [bs=n] [count=n] [skip=n] [seek=n]" }, +#endif { "-echo", do_echo, 1, INFINITE_ARGS, @@ -119,11 +123,13 @@ "[args] ..." }, +#ifdef HAVE_ED { "-ed", do_ed, 1, 2, "Edit a fileName using simple line mode commands", "[fileName]" }, +#endif { "exec", do_exec, 2, INFINITE_ARGS, @@ -137,23 +143,29 @@ "" }, +#ifdef HAVE_FILE { "-file", do_file, 1, INFINITE_ARGS, "Describe information about files", "fileName ..." }, +#endif +#ifdef HAVE_FIND { "-find", do_find, 2, INFINITE_ARGS, "Find files in a directory tree meeting some conditions", "dirName [-xdev] [-type chars] [-name pattern] [-size minSize]" }, +#endif +#ifdef HAVE_GREP { "-grep", do_grep, 3, INFINITE_ARGS, "Look for lines containing a word in some files", "[-in] word fileName ..." }, +#endif #ifdef HAVE_GZIP { @@ -187,11 +199,13 @@ "[-s] srcName ... destName" }, +#ifdef HAVE_LS { "-ls", do_ls, 1, INFINITE_ARGS, "List information about files or directories", "[-lidFC] fileName ..." }, +#endif #ifdef HAVE_EXT2 { @@ -222,7 +236,11 @@ { "-mount", do_mount, 3, INFINITE_ARGS, "Mount or remount a filesystem on a directory", +#ifdef __FreeBSD__ + "[-t type] [-r] [-u] devName dirName" +#else "[-t type] [-r] [-m] devName dirName" +#endif }, { @@ -291,11 +309,13 @@ "" }, +#ifdef HAVE_TAR { "-tar", do_tar, 2, INFINITE_ARGS, "Create, extract, or list files from a TAR file", "[cxtv]f tarFileName fileName ..." }, +#endif { "-touch", do_touch, 2, INFINITE_ARGS, diff -NPru sash-3.4/sash.h sash/sash.h --- sash-3.4/sash.h Sat Sep 25 06:03:51 1999 +++ sash/sash.h Sat Jan 22 19:38:16 2000 @@ -16,7 +16,9 @@ #include #include #include +#ifndef __FreeBSD__ #include +#endif #include #include