mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-02 08:12:54 +02:00
git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
18
src/install+setup/install/CVS/Entries
Normal file
18
src/install+setup/install/CVS/Entries
Normal file
@@ -0,0 +1,18 @@
|
||||
/Makefile/1.6.2.2/Wed Jan 11 01:01:38 2006//TIPCOP_v1_4_0
|
||||
/cdrom.c/1.6.2.1/Wed Apr 14 22:05:39 2004//TIPCOP_v1_4_0
|
||||
/config.c/1.6.2.3/Wed Dec 7 20:42:48 2005//TIPCOP_v1_4_0
|
||||
/grubbatch/1.1.2.5/Mon Sep 13 17:00:53 2004//TIPCOP_v1_4_0
|
||||
/ide.c/1.4/Thu Dec 11 11:25:53 2003//TIPCOP_v1_4_0
|
||||
/install.h/1.10.2.4/Wed Jan 11 01:01:38 2006//TIPCOP_v1_4_0
|
||||
/install2.c/1.1.2.3/Tue Jan 31 00:51:50 2006//TIPCOP_v1_4_0
|
||||
/main.c/1.63.2.64/Wed Jan 11 01:01:38 2006//TIPCOP_v1_4_0
|
||||
/net.c/1.8.2.2/Wed Apr 14 22:05:40 2004//TIPCOP_v1_4_0
|
||||
/nic.c/1.8.2.2/Sat Dec 24 09:08:26 2005//TIPCOP_v1_4_0
|
||||
/pcmcia.c/1.6.2.4/Thu Dec 8 02:12:28 2005//TIPCOP_v1_4_0
|
||||
/pcmcia.h/1.1/Sun Jan 25 09:34:59 2004//TIPCOP_v1_4_0
|
||||
/probescsi.sh/1.8.2.4/Mon Sep 20 19:42:32 2004//TIPCOP_v1_4_0
|
||||
/scsi.c/1.2.2.1/Tue Dec 6 18:26:36 2005//TIPCOP_v1_4_0
|
||||
/upgrade-v12-v13.c/1.2.2.3/Thu Nov 11 09:39:25 2004//TIPCOP_v1_4_0
|
||||
/upgrade-v130-v140.c/1.12.2.35/Thu Nov 11 09:40:03 2004//TIPCOP_v1_4_0
|
||||
/usb.c/1.9.2.8/Sat Dec 10 00:18:23 2005//TIPCOP_v1_4_0
|
||||
D
|
||||
1
src/install+setup/install/CVS/Repository
Normal file
1
src/install+setup/install/CVS/Repository
Normal file
@@ -0,0 +1 @@
|
||||
ipcop/src/install+setup/install
|
||||
1
src/install+setup/install/CVS/Root
Normal file
1
src/install+setup/install/CVS/Root
Normal file
@@ -0,0 +1 @@
|
||||
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ipcop
|
||||
1
src/install+setup/install/CVS/Tag
Normal file
1
src/install+setup/install/CVS/Tag
Normal file
@@ -0,0 +1 @@
|
||||
TIPCOP_v1_4_0
|
||||
72
src/install+setup/install/Makefile
Normal file
72
src/install+setup/install/Makefile
Normal file
@@ -0,0 +1,72 @@
|
||||
#
|
||||
# $Id: Makefile,v 1.6.2.2 2006/01/11 01:01:38 franck78 Exp $
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Os -Wall
|
||||
INCLUDE = -I/install/include
|
||||
|
||||
LD = gcc
|
||||
LDFLAGS = -L/install/lib
|
||||
LIBS = -lnewt -lslang -lpci
|
||||
|
||||
COMPILE = $(CC) -c $(INCLUDE) $(CFLAGS)
|
||||
|
||||
LINK = $(LD) $(LDFLAGS)
|
||||
|
||||
all : programs
|
||||
|
||||
programs : install install2
|
||||
|
||||
clean :
|
||||
-rm -f *.o install core
|
||||
|
||||
######
|
||||
# Macro to extract from the full set of translations only what is really used
|
||||
# into the installer (install&install2). Each needed entry have a "comment
|
||||
# inside the main source file"
|
||||
define lang_install
|
||||
rm $(OBJS3); \
|
||||
for i in /usr/src/langs/*/install/lang_*.c ; do \
|
||||
path=$${i%/*}/; \
|
||||
file=../libsmooth/$${i/$$path/}; \
|
||||
echo "#include \"libsmooth.h\"" > $$file; \
|
||||
grep "^char \*" $$i >> $$file; \
|
||||
echo "#include \"libsmooth.h\"" > $$file; \
|
||||
grep "^char \*" $$i >> $$file; \
|
||||
grep "^/\* TR_*" ../install/$$SELECT|xargs -i% grep -FA1 % $$i >> $$file; \
|
||||
echo "};">>$$file; \
|
||||
done
|
||||
#build the tr_strings include file
|
||||
awk 'BEGIN{ print"enum trstrings{" } \
|
||||
$$0 ~/\/\* (TR_[A-Z0-9_]*)/ {print $$2"," }\
|
||||
END{ print "};" }' ../libsmooth/lang_en.c > ../libsmooth/langs.h
|
||||
endef
|
||||
|
||||
lang_install:
|
||||
SELECT=main.c; \
|
||||
$(lang_install)
|
||||
cp ../libsmooth/langs.h main_langs.h
|
||||
|
||||
lang_install2:
|
||||
SELECT=install2.c; \
|
||||
$(lang_install)
|
||||
cp ../libsmooth/langs.h install_langs.h
|
||||
|
||||
OBJS1=main.o ide.o cdrom.o nic.o net.o config.o pcmcia.o usb.o scsi.o
|
||||
OBJS2=install2.o upgrade-v12-v13.o upgrade-v130-v140.o
|
||||
OBJS3=../libsmooth/main.o ../libsmooth/netstuff.o ../libsmooth/varval.o
|
||||
|
||||
install: lang_install $(OBJS1) $(OBJS3) install.h ../libsmooth/langs.h ../libsmooth/libsmooth.h /install/include/newt.h
|
||||
$(LINK) $(OBJS1) $(OBJS3) -o $@ $(LIBS)
|
||||
|
||||
install2: lang_install2 $(OBJS2) $(OBJS3)
|
||||
#strange 'make': even if files $OBJS3 are deleted, they are not recompiled,
|
||||
#so I explicitly recompile them (needed because langs.h have changed).
|
||||
$(foreach I, $(OBJS3), $(COMPILE) $(patsubst %.o,%.c,$(I)) -o $(I);)
|
||||
$(LINK) $(OBJS2) $(OBJS3) -o $@ $(LIBS)
|
||||
|
||||
%.o : %.c
|
||||
$(COMPILE) $< -o $@
|
||||
|
||||
.PHONY : lang_install lang_install2 clean
|
||||
36
src/install+setup/install/cdrom.c
Normal file
36
src/install+setup/install/cdrom.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* CDROM menu. Get "misc" driver name etc.
|
||||
*
|
||||
* $Id: cdrom.c,v 1.6.2.1 2004/04/14 22:05:39 gespinasse Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
/* Ejects the CDROM. returns 0 for failure, 1 for success. */
|
||||
int ejectcdrom(char *dev)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(dev, O_RDONLY|O_NONBLOCK)) == -1)
|
||||
return 0;
|
||||
|
||||
if (ioctl(fd, CDROMEJECT) == -1)
|
||||
{
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
125
src/install+setup/install/config.c
Normal file
125
src/install+setup/install/config.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Write the config and get password stuff.
|
||||
*
|
||||
* $Id: config.c,v 1.6.2.3 2005/12/07 20:42:48 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
extern char **ctr; // text translation table
|
||||
|
||||
/* called to write out all config files using the keyvalue interface. */
|
||||
int write_disk_configs(struct devparams *dp)
|
||||
{
|
||||
char devnode[STRING_SIZE];
|
||||
char partition[STRING_SIZE];
|
||||
char *messages[5] = { NULL,
|
||||
ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1],
|
||||
ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2],
|
||||
ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3],
|
||||
ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4]
|
||||
};
|
||||
/* dev node links. */
|
||||
sprintf(devnode, "%s", dp->devnode_disk_run);
|
||||
if (symlink(devnode, "/harddisk/dev/harddisk"))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int j;
|
||||
for (j=1; j<5; j++) {
|
||||
sprintf(devnode, "%s%d", dp->devnode_part_run,j);
|
||||
sprintf(partition,"/harddisk/dev/harddisk%d",j);
|
||||
if (symlink(devnode, partition))
|
||||
{
|
||||
errorbox( messages[j] );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add /dev/root symlink linking to the root filesystem to
|
||||
* keep updfstab happy */
|
||||
sprintf(devnode, "%s4", dp->devnode_part_run);
|
||||
if (symlink(devnode, "/harddisk/dev/root"))
|
||||
{
|
||||
errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int write_lang_configs( char *lang)
|
||||
{
|
||||
struct keyvalue *kv = initkeyvalues();
|
||||
|
||||
/* default stuff for main/settings. */
|
||||
replacekeyvalue(kv, "LANGUAGE", lang);
|
||||
replacekeyvalue(kv, "HOSTNAME", SNAME);
|
||||
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");
|
||||
freekeyvalues(kv);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int write_ethernet_configs(struct keyvalue *ethernetkv)
|
||||
{
|
||||
/* Write out the network settings we got from a few mins ago. */
|
||||
writekeyvalues(ethernetkv, "/harddisk" CONFIG_ROOT "/ethernet/settings");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Taken from the cdrom one. */
|
||||
int getpassword(char *password, char *text)
|
||||
{
|
||||
char *values[] = { NULL, NULL, NULL }; /* pointers for the values. */
|
||||
struct newtWinEntry entries[] =
|
||||
{
|
||||
{ ctr[TR_PASSWORD_PROMPT], &values[0], 2 },
|
||||
{ ctr[TR_AGAIN_PROMPT], &values[1], 2 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
char title[STRING_SIZE];
|
||||
int rc;
|
||||
int done;
|
||||
|
||||
do
|
||||
{
|
||||
done = 1;
|
||||
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
|
||||
rc = newtWinEntries(title, text,
|
||||
50, 5, 5, 20, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
|
||||
|
||||
if (rc != 2)
|
||||
{
|
||||
if (strlen(values[0]) == 0 || strlen(values[1]) == 0)
|
||||
{
|
||||
errorbox(ctr[TR_PASSWORD_CANNOT_BE_BLANK]);
|
||||
done = 0;
|
||||
strcpy(values[0], "");
|
||||
strcpy(values[1], "");
|
||||
}
|
||||
else if (strcmp(values[0], values[1]) != 0)
|
||||
{
|
||||
errorbox(ctr[TR_PASSWORDS_DO_NOT_MATCH]);
|
||||
done = 0;
|
||||
strcpy(values[0], "");
|
||||
strcpy(values[1], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
|
||||
strncpy(password, values[0], STRING_SIZE);
|
||||
|
||||
if (values[0]) free(values[0]);
|
||||
if (values[1]) free(values[1]);
|
||||
|
||||
return rc;
|
||||
}
|
||||
9
src/install+setup/install/grubbatch
Normal file
9
src/install+setup/install/grubbatch
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
/bin/cp -f /usr/share/grub/i386-pc/* /boot/grub
|
||||
/usr/sbin/grub --no-floppy --batch <<EOT > /dev/null 2> /dev/null
|
||||
device (hd0) DEVICE
|
||||
root (hd0,0)
|
||||
setup (hd0,0)
|
||||
setup (hd0)
|
||||
quit
|
||||
EOT
|
||||
61
src/install+setup/install/ide.c
Normal file
61
src/install+setup/install/ide.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Contains some functs for scanning /proc for ide info on CDROMS and
|
||||
* harddisks.
|
||||
*
|
||||
* $Id: ide.c,v 1.4 2003/12/11 11:25:53 riddles Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
/* checkide(). Scans the named drive letter and returns the IDE_??? type. */
|
||||
int checkide(char letter)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
char filename[STRING_SIZE];
|
||||
char buffer[STRING_SIZE];
|
||||
|
||||
sprintf(filename, "/proc/ide/hd%c/media", letter);
|
||||
|
||||
if (!(f = fopen(filename, "r")))
|
||||
return IDE_EMPTY;
|
||||
|
||||
if (!(fgets(buffer, STRING_SIZE, f)))
|
||||
{
|
||||
printf("Couldn't read from %s\n", filename);
|
||||
fclose(f);
|
||||
return IDE_EMPTY;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
stripnl(buffer);
|
||||
|
||||
if (strcmp(buffer, "cdrom") == 0)
|
||||
return IDE_CDROM;
|
||||
else if (strcmp(buffer, "disk") == 0)
|
||||
return IDE_HD;
|
||||
else
|
||||
return IDE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* findidetype(). Finds the first ide deveice of the given IDE_?? type. */
|
||||
char findidetype(int type)
|
||||
{
|
||||
char letter;
|
||||
|
||||
for (letter = 'a'; letter <= 'z'; letter++)
|
||||
{
|
||||
if ((checkide(letter)) == type)
|
||||
{
|
||||
return letter;
|
||||
}
|
||||
}
|
||||
return '\0';
|
||||
}
|
||||
|
||||
92
src/install+setup/install/install.h
Normal file
92
src/install+setup/install/install.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Main include file.
|
||||
*
|
||||
* $Id: install.h,v 1.10.2.4 2006/01/11 01:01:38 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../libsmooth/libsmooth.h"
|
||||
|
||||
#define IDE_EMPTY 0
|
||||
#define IDE_CDROM 1
|
||||
#define IDE_HD 2
|
||||
#define IDE_UNKNOWN 3
|
||||
|
||||
/* CDROMS and harddisks. */
|
||||
struct devparams
|
||||
{
|
||||
char devnode_disk[30]; // when single partition is addressed
|
||||
char devnode_part[30]; // when the RAID partition is addressed
|
||||
char devnode_disk_run[30]; // the same dev but after installation
|
||||
char devnode_part_run[30];
|
||||
char modulename[STRING_SIZE];
|
||||
char options[STRING_SIZE];
|
||||
// int module;
|
||||
};
|
||||
|
||||
/* ide.c */
|
||||
int checkide(char letter);
|
||||
char findidetype(int type);
|
||||
|
||||
/* cdrom.c */
|
||||
int ejectcdrom(char *dev);
|
||||
|
||||
/* nic.c */
|
||||
int networkmenu(struct keyvalue *ethernetkv);
|
||||
|
||||
/* net.c */
|
||||
int checktarball(char *);
|
||||
|
||||
/* config.c */
|
||||
int write_disk_configs(struct devparams *dp);
|
||||
int write_lang_configs( char *lang);
|
||||
int write_ethernet_configs(struct keyvalue *ethernetkv);
|
||||
|
||||
/* pcmcia.c */
|
||||
char * initialize_pcmcia (void);
|
||||
|
||||
/* upgrade_v12_v13.c */
|
||||
int upgrade_v12_v13();
|
||||
|
||||
/* upgrade_v130_v131.c */
|
||||
int upgrade_v130_v140();
|
||||
|
||||
/* usb.c */
|
||||
int initialize_usb();
|
||||
int write_usb_modules_conf();
|
||||
int checkusb (char *partition);
|
||||
|
||||
/* scsi.c */
|
||||
int try_scsi(char *dev);
|
||||
int get_boot(char *dev);
|
||||
|
||||
/*main.c */
|
||||
int modprobe (char *mod);
|
||||
int rmmod (char *mod);
|
||||
|
||||
extern char *bz_tr[];
|
||||
extern char *cs_tr[];
|
||||
extern char *da_tr[];
|
||||
extern char *en_tr[];
|
||||
extern char *es_tr[];
|
||||
extern char *fi_tr[];
|
||||
extern char *fr_tr[];
|
||||
extern char *hu_tr[];
|
||||
extern char *la_tr[];
|
||||
extern char *nl_tr[];
|
||||
extern char *de_tr[];
|
||||
extern char *tr_tr[];
|
||||
extern char *it_tr[];
|
||||
extern char *el_tr[];
|
||||
extern char *pl_tr[];
|
||||
extern char *pt_tr[];
|
||||
extern char *sk_tr[];
|
||||
extern char *so_tr[];
|
||||
extern char *sv_tr[];
|
||||
extern char *no_tr[];
|
||||
extern char *vi_tr[];
|
||||
424
src/install+setup/install/install2.c
Normal file
424
src/install+setup/install/install2.c
Normal file
@@ -0,0 +1,424 @@
|
||||
/* IPCop install2 program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* (c) Franck Bourdonnec, 2006
|
||||
* Contains update/restore code
|
||||
*
|
||||
* $Id: install2.c,v 1.1.2.3 2006/01/31 00:51:50 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
#include "install.h"
|
||||
|
||||
FILE *flog = NULL;
|
||||
char *mylog;
|
||||
char **ctr;
|
||||
|
||||
/*
|
||||
To include a translated string in the final installer, you must reference
|
||||
it here with a simplr comment. This save a lot a space in the installer
|
||||
*/
|
||||
|
||||
/* TR_BUILDING_INITRD */
|
||||
/* TR_HELPLINE */
|
||||
/* TR_SKIP */
|
||||
/* TR_RESTORE_CONFIGURATION */
|
||||
/* TR_RESTORE */
|
||||
/* TR_OK */
|
||||
/* TR_CANCEL */
|
||||
/* TR_ERROR */
|
||||
/* TR_INSTALLING_FILES */
|
||||
/* TR_FAILED_TO_FIND */
|
||||
/* TR_UNABLE_TO_INSTALL_FILES */
|
||||
/* TR_LOADING_PCMCIA */
|
||||
|
||||
//libsmooth
|
||||
/* TR_INTERFACE */
|
||||
/* TR_ENTER_THE_IP_ADDRESS_INFORMATION */
|
||||
/* TR_STATIC */
|
||||
/* TR_DHCP_HOSTNAME */
|
||||
/* TR_IP_ADDRESS_PROMPT */
|
||||
/* TR_NETMASK_PROMPT */
|
||||
/* TR_INVALID_FIELDS */
|
||||
/* TR_IP_ADDRESS_CR */
|
||||
/* TR_NETWORK_MASK_CR */
|
||||
/* TR_DHCP_HOSTNAME_CR */
|
||||
/* TR_LOOKING_FOR_NIC */
|
||||
/* TR_MANUAL */
|
||||
/* TR_SELECT_NETWORK_DRIVER */
|
||||
/* TR_SELECT_NETWORK_DRIVER_LONG */
|
||||
/* TR_UNABLE_TO_LOAD_DRIVER_MODULE */
|
||||
/* TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED */
|
||||
/* TR_MODULE_PARAMETERS */
|
||||
/* TR_LOADING_MODULE */
|
||||
/* TR_MODULE_NAME_CANNOT_BE_BLANK */
|
||||
|
||||
//upgrade 120
|
||||
/* TR_UNABLE_TO_OPEN_SETTINGS_FILE */
|
||||
/* TR_DOMAINNAME */
|
||||
/* TR_ENTER_DOMAINNAME */
|
||||
/* TR_DOMAINNAME_CANNOT_CONTAIN_SPACES */
|
||||
/* TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM */
|
||||
/* TR_UNABLE_TO_WRITE_ETC_FSTAB */
|
||||
|
||||
// dir to find files, chrooted or not...
|
||||
#define TMP_EXTRACT_CH "/tmp/ipcop"
|
||||
#define TMP_EXTRACT "/harddisk" TMP_EXTRACT_CH
|
||||
#define MOUNT_BACKUP_CH "/mnt/usb"
|
||||
#define MOUNT_BACKUP "/harddisk" MOUNT_BACKUP_CH
|
||||
/*
|
||||
return 0 when dev contains a backup set
|
||||
leave dev mounted
|
||||
*/
|
||||
int try_mount (char *dev, char *testfile) {
|
||||
char commandstring[STRING_SIZE];
|
||||
mysystem("/bin/umount " MOUNT_BACKUP);
|
||||
sprintf(commandstring, "/bin/mount -t vfat -o ro %s " MOUNT_BACKUP, dev);
|
||||
mysystem(commandstring);
|
||||
|
||||
/*verify it's what we want */
|
||||
sprintf(commandstring, MOUNT_BACKUP "/%s.dat", testfile);
|
||||
FILE *handle = fopen(commandstring, "r");
|
||||
if (handle == NULL) {
|
||||
return 1; /* bad disk ! */
|
||||
}
|
||||
fclose(handle);
|
||||
|
||||
handle = fopen(MOUNT_BACKUP "/backup.key", "r");
|
||||
if (handle == NULL) {
|
||||
return 1; /* bad disk ! */
|
||||
}
|
||||
fclose(handle);
|
||||
return 0; //success
|
||||
}
|
||||
|
||||
/* try to mount usb device until backup.tgz is found except the
|
||||
destination device (scsi names are identical with usb key)
|
||||
check "sda sdb sdc sdd"
|
||||
*/
|
||||
int mountbackup (char *testfile, char *destination_device) {
|
||||
char sourcedev[30];
|
||||
char i,j;
|
||||
for (i = 'a'; i < 'e'; i++) {
|
||||
sprintf (sourcedev,"/dev/sd%c ",i);
|
||||
if (strcmp (destination_device, sourcedev) != 0) {
|
||||
if (!try_mount (sourcedev, testfile)) return 0;
|
||||
}
|
||||
for (j = '1'; j < '5'; j++) {
|
||||
sourcedev[8] = j;
|
||||
if (strcmp (destination_device, sourcedev) != 0) {
|
||||
if (!try_mount (sourcedev, testfile)) return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int floppy_locate() {
|
||||
/* Temporarily mount /proc under /harddisk/proc,
|
||||
run updfstab to locate the floppy, and unmount /harddisk/proc
|
||||
again. This should be run each time the user tries to restore
|
||||
so it can properly detect removable devices */
|
||||
if (mysystem("/bin/mount -n -t proc /proc /harddisk/proc")) {
|
||||
errorbox(ctr[TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM]);
|
||||
return 1;
|
||||
}
|
||||
if (mysystem("/bin/chroot /harddisk /usr/sbin/updfstab")) {
|
||||
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_FSTAB]);
|
||||
return 1;
|
||||
}
|
||||
mysystem("/bin/umount /harddisk/proc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check the SQUID acl file exists, if not use our 1.4 copy */
|
||||
void fixup_squidacl() {
|
||||
FILE *aclreadfile;
|
||||
if ((aclreadfile = fopen ("/harddisk" CONFIG_ROOT "/proxy/acl", "r"))) {
|
||||
unlink ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4");
|
||||
fclose(aclreadfile);
|
||||
} else {
|
||||
rename ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4",
|
||||
"/harddisk" CONFIG_ROOT "/proxy/acl");
|
||||
}
|
||||
chown ("/harddisk" CONFIG_ROOT "/proxy/acl", 99, 99);
|
||||
}
|
||||
/* if we detected SCSI then fixup */
|
||||
void fixup_initrd() {
|
||||
FILE *handle;
|
||||
char line[STRING_SIZE];
|
||||
char commandstring[STRING_SIZE];
|
||||
|
||||
if (!(handle = fopen("/scsidriver", "r")))
|
||||
return;
|
||||
|
||||
char *driver;
|
||||
fgets(line, STRING_SIZE-1, handle);
|
||||
fclose(handle);
|
||||
line[strlen(line) - 1] = 0;
|
||||
driver = strtok(line, ".");
|
||||
fprintf(flog, "Detected SCSI driver %s\n", driver);
|
||||
if (!strlen(driver) > 1)
|
||||
return;
|
||||
|
||||
fprintf(flog, "Fixing up ipcoprd.img\n");
|
||||
mysystem("/bin/chroot /harddisk /sbin/modprobe loop");
|
||||
mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);
|
||||
sprintf(commandstring, "/bin/chroot /harddisk /sbin/mkinitrd"
|
||||
" --with=scsi_mod --with=%s --with=sd_mod"
|
||||
" --with=sr_mod --with=libata"
|
||||
" --with=ataraid /boot/ipcoprd.img "KERNEL_VERSION,
|
||||
driver );
|
||||
runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
|
||||
#ifdef __i386__
|
||||
sprintf(commandstring, "/bin/chroot /harddisk /sbin/mkinitrd"
|
||||
" --with=scsi_mod --with=%s --with=sd_mod"
|
||||
" --with=sr_mod --with=libata"
|
||||
" --with=ataraid /boot/ipcoprd-smp.img "KERNEL_VERSION"-smp",
|
||||
driver );
|
||||
runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
|
||||
mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
|
||||
#endif
|
||||
#ifdef __alpha__
|
||||
runcommandwithstatus("/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf", ctr[TR_BUILDING_INITRD]);
|
||||
#endif
|
||||
}
|
||||
/* when backup is ready in tmpdir, move files to definitive location */
|
||||
void do_copy_files(int upgrade_level) {
|
||||
mysystem("/bin/chroot /harddisk /bin/cp -af "TMP_EXTRACT_CH"/. /");
|
||||
/* Upgrade necessary files from v1.2 to v1.3 to v1.4 */
|
||||
switch (upgrade_level) {
|
||||
case 1:
|
||||
upgrade_v12_v13();
|
||||
upgrade_v130_v140();
|
||||
case 2: //some 1.4 files format changed
|
||||
//between 1.4.0 & 1.4.11 If possible de determine backup/version
|
||||
//the update code should go here
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#define LANG argv[1]
|
||||
#define DEST_DEV argv[2]
|
||||
#define WGET argv[3]
|
||||
|
||||
#ifdef LANG_EN_ONLY
|
||||
char **langtrs[] = { en_tr, NULL };
|
||||
#else
|
||||
char **langtrs[] = { bz_tr, cs_tr, da_tr, de_tr, en_tr, es_tr, fr_tr, el_tr, it_tr, la_tr, hu_tr, nl_tr, no_tr, pl_tr, pt_tr, sk_tr, so_tr, fi_tr, sv_tr, tr_tr, vi_tr, NULL };
|
||||
#endif
|
||||
char message[1000];
|
||||
char title[STRING_SIZE];
|
||||
char commandstring[STRING_SIZE];
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
/* Log file/terminal stuff. */
|
||||
mylog = "/dev/tty2";
|
||||
ctr = langtrs[ atoi(LANG) ];
|
||||
|
||||
if (!(flog = fopen(mylog, "w+")))
|
||||
{
|
||||
printf("Couldn't open log terminal\n");
|
||||
return 0;
|
||||
}
|
||||
fprintf(flog, "Install2 program started.\n");
|
||||
newtInit();
|
||||
newtCls();
|
||||
strcpy (title, NAME " v" VERSION " - " SLOGAN);
|
||||
newtDrawRootText(14, 0, title);
|
||||
newtPushHelpLine(ctr[TR_HELPLINE]);
|
||||
/*
|
||||
// build now the device node
|
||||
runcommandwithstatus("echo 'cd /dev; ./make_devices'>/harddisk/X;"
|
||||
"chroot /harddisk chmod +x /X;"
|
||||
"chroot /harddisk /X;"
|
||||
"chroot /harddisk rm /X"
|
||||
, ctr[TR_INSTALLING_FILES]);
|
||||
*/
|
||||
/* working dirs... */
|
||||
mkdir(MOUNT_BACKUP, S_IRWXU|S_IRWXG|S_IRWXO);
|
||||
|
||||
//create the GUI screen and objects
|
||||
newtComponent form, header, labelfile, labelkey, file, key, radio0, radio1, radio2, radio3, radio4, ok;
|
||||
|
||||
newtCenteredWindow (55,20,ctr[TR_RESTORE]);
|
||||
form = newtForm (NULL, NULL,0);
|
||||
|
||||
sprintf(message, ctr[TR_RESTORE_CONFIGURATION], NAME);
|
||||
header = newtTextboxReflowed (2,1,message,51,0,0,0);
|
||||
newtFormAddComponent(form, header);
|
||||
|
||||
// The four method of restauration
|
||||
int start1=1, start2=0, start3=0, start4=0;
|
||||
radio1 = newtRadiobutton (17, 5, ctr[TR_SKIP], start1, NULL);
|
||||
radio2 = newtRadiobutton (17, 6, "Floppy (legacy)", start2, radio1);
|
||||
radio3 = newtRadiobutton (17, 7, "Usb-storage/CDROM", start3, radio2);
|
||||
if (strcmp(WGET,"none"))
|
||||
radio4 = newtRadiobutton (17, 8, "HTTP/FTP", start4, radio3);
|
||||
else
|
||||
radio4 = NULL;
|
||||
newtFormAddComponents(form, radio1, radio2, radio3, radio4, NULL);
|
||||
|
||||
// The optionnal filename for 'backup'
|
||||
labelfile=newtTextbox(12, 10, 35, 1, 0);
|
||||
newtTextboxSetText (labelfile, "Filename");
|
||||
newtFormAddComponent(form, labelfile);
|
||||
char *filevalue;
|
||||
char fileinit[STRING_SIZE] = "backup";
|
||||
file = newtEntry (17, 11, fileinit, 20, &filevalue, 0);
|
||||
newtFormAddComponent(form, file);
|
||||
|
||||
// The optionnal password for the key
|
||||
labelkey=newtTextbox(12, 13, 35, 1, 0);
|
||||
newtTextboxSetText (labelkey, "Backup key password");
|
||||
newtFormAddComponent(form, labelkey);
|
||||
char *keyvalue;
|
||||
char keyinit[STRING_SIZE] = "";
|
||||
key = newtEntry (17, 14, keyinit, 20, &keyvalue, 0);
|
||||
newtFormAddComponent(form, key);
|
||||
|
||||
// The OK button
|
||||
ok=newtButton (23, 16, ctr[TR_OK]);
|
||||
newtFormAddComponent(form, ok);
|
||||
|
||||
/* loop until succeeds or user skips out */
|
||||
int retcode = -1;
|
||||
while ( retcode<0 ) {
|
||||
|
||||
// run the windows
|
||||
struct newtExitStruct reponse;
|
||||
newtFormRun (form, &reponse);
|
||||
radio0 = newtRadioGetCurrent(radio1);
|
||||
int radio;
|
||||
radio = radio0 == radio1 ? 1 : radio0 == radio2 ? 2 : radio0 == radio3 ? 3 : radio0 == radio4 ? 4 : 0;
|
||||
strcpy(keyinit,keyvalue); //reuse actual value
|
||||
strcpy(fileinit,filevalue);
|
||||
|
||||
if (radio==1) {
|
||||
retcode = 1; // no restore: nothing special
|
||||
break; // out of the while loop
|
||||
}
|
||||
|
||||
mkdir(TMP_EXTRACT, S_IRWXU|S_IRWXG|S_IRWXO);
|
||||
statuswindow(45, 4, title, ctr[TR_INSTALLING_FILES]);
|
||||
switch (radio) {
|
||||
case 4: // network
|
||||
sprintf(commandstring,"/bin/wget -P " TMP_EXTRACT " %s/%s.dat", WGET, filevalue);
|
||||
mysystem (commandstring);
|
||||
sprintf(commandstring,"/bin/wget -P " TMP_EXTRACT " %s/%s.key", WGET, filevalue);
|
||||
if (mysystem (commandstring)) {
|
||||
errorbox(ctr[TR_FAILED_TO_FIND]);
|
||||
break;
|
||||
};
|
||||
goto COMMON;
|
||||
case 3: // normal backup
|
||||
if (mountbackup( filevalue, DEST_DEV )) {
|
||||
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);//mess=no device with backup found
|
||||
break;
|
||||
};
|
||||
// link files to a COMMON location
|
||||
sprintf (commandstring, "chroot /harddisk ln -s "MOUNT_BACKUP_CH"/%s.dat " TMP_EXTRACT_CH "/%s.dat", filevalue, filevalue);
|
||||
mysystem (commandstring);
|
||||
sprintf (commandstring, "chroot /harddisk ln -s "MOUNT_BACKUP_CH"/%s.key " TMP_EXTRACT_CH "/%s.key", filevalue, filevalue);
|
||||
mysystem (commandstring);
|
||||
|
||||
COMMON: // DECRYPT THE TARBALL
|
||||
// Copy the key to a new location because we decrypt it!
|
||||
if (strcmp(keyvalue, "")) { // password provided: decrypt the key
|
||||
sprintf(commandstring, "/bin/chroot /harddisk /usr/bin/openssl enc"
|
||||
" -a -d -aes256 -salt"
|
||||
" -pass pass:%s"
|
||||
" -in " TMP_EXTRACT_CH "/%s.key"
|
||||
" -out " TMP_EXTRACT_CH "/__tmp.key",
|
||||
keyvalue, filevalue);
|
||||
} else { //just copy to new name
|
||||
sprintf(commandstring, "/bin/chroot /harddisk cp"
|
||||
" " TMP_EXTRACT_CH "/%s.key"
|
||||
" " TMP_EXTRACT_CH "/__tmp.key",
|
||||
filevalue);
|
||||
}
|
||||
mysystem (commandstring);
|
||||
|
||||
sprintf(commandstring, "/bin/chroot /harddisk /usr/bin/openssl des3"
|
||||
" -d -salt"
|
||||
" -in " TMP_EXTRACT_CH "/%s.dat"
|
||||
" -out " TMP_EXTRACT_CH "/backup.tgz"
|
||||
" -kfile " TMP_EXTRACT_CH "/__tmp.key",
|
||||
filevalue);
|
||||
|
||||
if (mysystem (commandstring)) {
|
||||
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);//mess=decrypt error:invalid key?
|
||||
break;
|
||||
}
|
||||
strcpy(commandstring, "/bin/chroot /harddisk /bin/tar"
|
||||
" -X " CONFIG_ROOT "/backup/exclude.system"
|
||||
" -C " TMP_EXTRACT_CH
|
||||
" -xzf " TMP_EXTRACT_CH "/backup.tgz");
|
||||
|
||||
if (mysystem(commandstring)) {
|
||||
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
|
||||
break;
|
||||
}
|
||||
sprintf(commandstring, TMP_EXTRACT "/%s.dat", filevalue);
|
||||
unlink(commandstring ); //dont need them anymore
|
||||
unlink( TMP_EXTRACT "/backup.tgz");
|
||||
sprintf(commandstring, TMP_EXTRACT "/%s.key", filevalue);
|
||||
unlink(commandstring );
|
||||
unlink( TMP_EXTRACT "/__tmp.key");
|
||||
|
||||
/* Now copy to correct location */
|
||||
do_copy_files(0);
|
||||
retcode = 0; /* successfully restored */
|
||||
break;
|
||||
case 2:
|
||||
// diskette change
|
||||
if (floppy_locate()) {
|
||||
retcode = 2; // this an error!
|
||||
break;
|
||||
}
|
||||
|
||||
/* Always extract to /tmp/ipcop for temporary extraction
|
||||
just in case floppy fails.
|
||||
try a compressed backup first because it's quicker to fail.
|
||||
In exclude.system, files name must be without leading / or
|
||||
on extraction, name will never match
|
||||
*/
|
||||
sprintf(commandstring,
|
||||
"/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C "TMP_EXTRACT_CH" -xvzf /dev/floppy > %s 2> /dev/null", mylog);
|
||||
if (system(commandstring)) {
|
||||
/* if it's not compressed, try uncompressed first before failing*/
|
||||
sprintf(commandstring,
|
||||
"/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C "TMP_EXTRACT_CH" -xvf /dev/floppy > %s 2> /dev/null", mylog);
|
||||
if (system(commandstring)) {
|
||||
/* command failed trying to read from floppy */
|
||||
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Now copy to correct location */
|
||||
do_copy_files(1);
|
||||
retcode = 0; /* successfully restored */
|
||||
}//switch
|
||||
/* remove possible badly restored files */
|
||||
mysystem("/bin/chroot /harddisk /bin/rm -rf " TMP_EXTRACT_CH );
|
||||
newtPopWindow(); // close windows
|
||||
}//while
|
||||
newtFormDestroy(form);
|
||||
|
||||
/* cleanup */
|
||||
mysystem("/bin/umount " MOUNT_BACKUP);
|
||||
mysystem("/bin/chroot /harddisk /bin/rmdir " MOUNT_BACKUP_CH);
|
||||
|
||||
/* others operations moved from install to install2 */
|
||||
fixup_squidacl();
|
||||
fixup_initrd();
|
||||
|
||||
fprintf(flog, "Install2 program ended.\n");
|
||||
fflush(flog);
|
||||
fclose(flog);
|
||||
newtFinished();
|
||||
return retcode;
|
||||
}
|
||||
|
||||
1051
src/install+setup/install/main.c
Normal file
1051
src/install+setup/install/main.c
Normal file
File diff suppressed because it is too large
Load Diff
77
src/install+setup/install/net.c
Normal file
77
src/install+setup/install/net.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Stuff for downloading the smoothwall tarball using wget.
|
||||
*
|
||||
* $Id: net.c,v 1.8.2.2 2004/04/14 22:05:40 gespinasse Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
static int got_url = 0;
|
||||
|
||||
char url[STRING_SIZE];
|
||||
|
||||
static int gettarballurl();
|
||||
|
||||
int checktarball(char *file)
|
||||
{
|
||||
int done;
|
||||
int tries = 0;
|
||||
char commandstring[STRING_SIZE];
|
||||
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
if (!got_url && gettarballurl() != 1)
|
||||
return 0;
|
||||
|
||||
/* remove any successive /'s */
|
||||
while (url[strlen(url)-1] == '/') { url[strlen(url)-1] = '\0'; }
|
||||
|
||||
snprintf(commandstring, STRING_SIZE, "/bin/wget -s -O /dev/null %s/%s", url, file);
|
||||
if (!(runcommandwithstatus(commandstring, ctr[TR_CHECKING])))
|
||||
{
|
||||
done = 1;
|
||||
got_url = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorbox(ctr[TR_FAILED_TO_FIND]);
|
||||
got_url = 0;
|
||||
if (tries == 3)
|
||||
return 0;
|
||||
}
|
||||
tries++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int gettarballurl()
|
||||
{
|
||||
char *values[] = { NULL, NULL }; /* pointers for the values. */
|
||||
struct newtWinEntry entries[] =
|
||||
{ { "", &values[0], 0,}, { NULL, NULL, 0 } };
|
||||
char title[STRING_SIZE];
|
||||
char message[1000];
|
||||
int rc;
|
||||
|
||||
sprintf(message, ctr[TR_ENTER_URL]);
|
||||
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
|
||||
rc = newtWinEntries(title, message,
|
||||
60, 5, 5, 50, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
|
||||
|
||||
strncpy(url, values[0], STRING_SIZE);
|
||||
|
||||
return rc;
|
||||
}
|
||||
98
src/install+setup/install/nic.c
Normal file
98
src/install+setup/install/nic.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/* SmoothWall install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Lawrence Manning, 2001
|
||||
* Contains stuff related to firing up the network card, including a crude
|
||||
* autodector.
|
||||
*
|
||||
* $Id: nic.c,v 1.8.2.2 2005/12/24 09:08:26 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
extern char **ctr;
|
||||
extern struct nic nics[];
|
||||
|
||||
int networkmenu(struct keyvalue *ethernetkv)
|
||||
{
|
||||
int rc;
|
||||
char driver[STRING_SIZE] = "";
|
||||
char driveroptions[STRING_SIZE] = "";
|
||||
int result = 0;
|
||||
char commandstring[STRING_SIZE];
|
||||
char address[STRING_SIZE], netmask[STRING_SIZE];
|
||||
int done;
|
||||
char description[1000];
|
||||
char message[1000];
|
||||
char title[STRING_SIZE];
|
||||
done = 0;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE],
|
||||
ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
|
||||
|
||||
if (rc == 0 || rc == 1)
|
||||
{
|
||||
probecards(driver, driveroptions);
|
||||
if (!strlen(driver))
|
||||
errorbox(ctr[TR_PROBE_FAILED]);
|
||||
else
|
||||
{
|
||||
findnicdescription(driver, description);
|
||||
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
|
||||
sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
|
||||
newtWinMessage(title, ctr[TR_OK], message);
|
||||
}
|
||||
}
|
||||
else if (rc == 2)
|
||||
choosecards(driver, driveroptions);
|
||||
else
|
||||
done = 1;
|
||||
|
||||
if (strlen(driver))
|
||||
done = 1;
|
||||
}
|
||||
|
||||
if (!strlen(driver))
|
||||
goto EXIT;
|
||||
|
||||
/* Default is a GREEN nic only. */
|
||||
/* Smoothie is not untarred yet, so we have to delay actually writing the
|
||||
* settings till later. */
|
||||
replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
|
||||
replacekeyvalue(ethernetkv, "GREEN_DRIVER", driver);
|
||||
replacekeyvalue(ethernetkv, "GREEN_DRIVER_OPTIONS", driveroptions);
|
||||
replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
|
||||
replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);
|
||||
|
||||
if (!(changeaddress(ethernetkv, "GREEN", 0, "")))
|
||||
goto EXIT;
|
||||
|
||||
strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);
|
||||
strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);
|
||||
|
||||
snprintf(commandstring, STRING_SIZE, "/bin/ifconfig eth0 %s netmask %s up",
|
||||
address, netmask);
|
||||
if (mysystem(commandstring))
|
||||
{
|
||||
errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
result = 1;
|
||||
|
||||
EXIT:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
332
src/install+setup/install/pcmcia.c
Normal file
332
src/install+setup/install/pcmcia.c
Normal file
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* PCMCIA bridge device probe
|
||||
*
|
||||
* This file is part of the IPCop Firewall.
|
||||
*
|
||||
* IPCop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* IPCop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with IPCop; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* The initial developer of the original code is David A. Hinds
|
||||
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
|
||||
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
|
||||
*
|
||||
* $Id: pcmcia.c,v 1.6.2.4 2005/12/08 02:12:28 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
#include "pcmcia.h"
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/io.h>
|
||||
#else
|
||||
#include <asm/io.h>
|
||||
#endif
|
||||
|
||||
extern FILE *flog;
|
||||
extern int modprobe(char *);
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
typedef struct {
|
||||
u_short vendor, device;
|
||||
char *modname;
|
||||
char *name;
|
||||
} pci_id_t;
|
||||
|
||||
pci_id_t pci_id[] = {
|
||||
{ 0x1013, 0x1100, "i82365", "Cirrus Logic CL 6729" },
|
||||
{ 0x1013, 0x1110, "yenta_socket", "Cirrus Logic PD 6832" },
|
||||
{ 0x10b3, 0xb106, "yenta_socket", "SMC 34C90" },
|
||||
{ 0x1180, 0x0465, "yenta_socket", "Ricoh RL5C465" },
|
||||
{ 0x1180, 0x0466, "yenta_socket", "Ricoh RL5C466" },
|
||||
{ 0x1180, 0x0475, "yenta_socket", "Ricoh RL5C475" },
|
||||
{ 0x1180, 0x0476, "yenta_socket", "Ricoh RL5C476" },
|
||||
{ 0x1180, 0x0477, "yenta_socket", "Ricoh RL5C477" },
|
||||
{ 0x1180, 0x0478, "yenta_socket", "Ricoh RL5C478" },
|
||||
{ 0x104c, 0xac12, "yenta_socket", "Texas Instruments PCI1130" },
|
||||
{ 0x104c, 0xac13, "yenta_socket", "Texas Instruments PCI1031" },
|
||||
{ 0x104c, 0xac15, "yenta_socket", "Texas Instruments PCI1131" },
|
||||
{ 0x104c, 0xac1a, "yenta_socket", "Texas Instruments PCI1210" },
|
||||
{ 0x104c, 0xac1e, "yenta_socket", "Texas Instruments PCI1211" },
|
||||
{ 0x104c, 0xac17, "yenta_socket", "Texas Instruments PCI1220" },
|
||||
{ 0x104c, 0xac19, "yenta_socket", "Texas Instruments PCI1221" },
|
||||
{ 0x104c, 0xac1c, "yenta_socket", "Texas Instruments PCI1225" },
|
||||
{ 0x104c, 0xac16, "yenta_socket", "Texas Instruments PCI1250" },
|
||||
{ 0x104c, 0xac1d, "yenta_socket", "Texas Instruments PCI1251A" },
|
||||
{ 0x104c, 0xac1f, "yenta_socket", "Texas Instruments PCI1251B" },
|
||||
{ 0x104c, 0xac50, "yenta_socket", "Texas Instruments PCI1410" },
|
||||
{ 0x104c, 0xac51, "yenta_socket", "Texas Instruments PCI1420" },
|
||||
{ 0x104c, 0xac1b, "yenta_socket", "Texas Instruments PCI1450" },
|
||||
{ 0x104c, 0xac52, "yenta_socket", "Texas Instruments PCI1451" },
|
||||
{ 0x104c, 0xac56, "yenta_socket", "Texas Instruments PCI1510" },
|
||||
{ 0x104c, 0xac55, "yenta_socket", "Texas Instruments PCI1520" },
|
||||
{ 0x104c, 0xac54, "yenta_socket", "Texas Instruments PCI1620" },
|
||||
{ 0x104c, 0xac41, "yenta_socket", "Texas Instruments PCI4410" },
|
||||
{ 0x104c, 0xac40, "yenta_socket", "Texas Instruments PCI4450" },
|
||||
{ 0x104c, 0xac42, "yenta_socket", "Texas Instruments PCI4451" },
|
||||
{ 0x104c, 0xac44, "yenta_socket", "Texas Instruments PCI4510" },
|
||||
{ 0x104c, 0xac46, "yenta_socket", "Texas Instruments PCI4520" },
|
||||
{ 0x104c, 0xac49, "yenta_socket", "Texas Instruments PCI7410" },
|
||||
{ 0x104c, 0xac47, "yenta_socket", "Texas Instruments PCI7510" },
|
||||
{ 0x104c, 0xac48, "yenta_socket", "Texas Instruments PCI7610" },
|
||||
{ 0x1217, 0x6729, "i82365", "O2 Micro 6729" },
|
||||
{ 0x1217, 0x673a, "i82365", "O2 Micro 6730" },
|
||||
{ 0x1217, 0x6832, "yenta_socket", "O2 Micro 6832/6833" },
|
||||
{ 0x1217, 0x6836, "yenta_socket", "O2 Micro 6836/6860" },
|
||||
{ 0x1217, 0x6872, "yenta_socket", "O2 Micro 6812" },
|
||||
{ 0x1217, 0x6925, "yenta_socket", "O2 Micro 6922" },
|
||||
{ 0x1217, 0x6933, "yenta_socket", "O2 Micro 6933" },
|
||||
{ 0x1217, 0x6972, "yenta_socket", "O2 Micro 6912" },
|
||||
{ 0x1179, 0x0603, "i82365", "Toshiba ToPIC95-A" },
|
||||
{ 0x1179, 0x060a, "yenta_socket", "Toshiba ToPIC95-B" },
|
||||
{ 0x1179, 0x060f, "yenta_socket", "Toshiba ToPIC97" },
|
||||
{ 0x1179, 0x0617, "yenta_socket", "Toshiba ToPIC100" },
|
||||
{ 0x119b, 0x1221, "i82365", "Omega Micro 82C092G" },
|
||||
{ 0x8086, 0x1221, "i82092", "Intel 82092AA_0" },
|
||||
{ 0x8086, 0x1222, "i82092", "Intel 82092AA_1" },
|
||||
{ 0x1524, 0x1211, "yenta_socket", "ENE 1211" },
|
||||
{ 0x1524, 0x1225, "yenta_socket", "ENE 1225" },
|
||||
{ 0x1524, 0x1410, "yenta_socket", "ENE 1410" },
|
||||
{ 0x1524, 0x1420, "yenta_socket", "ENE 1420" },
|
||||
};
|
||||
#define PCI_COUNT (sizeof(pci_id)/sizeof(pci_id_t))
|
||||
|
||||
static char * pci_probe()
|
||||
{
|
||||
char s[256], *modname = NULL;
|
||||
u_int device, vendor, i;
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen("/proc/bus/pci/devices", "r")) != NULL) {
|
||||
while (fgets(s, 256, f) != NULL) {
|
||||
u_int n = strtoul(s+5, NULL, 16);
|
||||
vendor = (n >> 16); device = (n & 0xffff);
|
||||
for (i = 0; i < PCI_COUNT; i++)
|
||||
if ((vendor == pci_id[i].vendor) &&
|
||||
(device == pci_id[i].device)) break;
|
||||
|
||||
if (i < PCI_COUNT) {
|
||||
modname = pci_id[i].modname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modname;
|
||||
}
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
#ifndef __alpha__
|
||||
typedef u_short ioaddr_t;
|
||||
|
||||
static ioaddr_t i365_base = 0x03e0;
|
||||
|
||||
static u_char i365_get(u_short sock, u_short reg)
|
||||
{
|
||||
u_char val = I365_REG(sock, reg);
|
||||
outb(val, i365_base); val = inb(i365_base+1);
|
||||
return val;
|
||||
}
|
||||
|
||||
#if 0 // the following code do nothing usefull, it ends with return 0 anyway
|
||||
|
||||
static void i365_set(u_short sock, u_short reg, u_char data)
|
||||
{
|
||||
u_char val = I365_REG(sock, reg);
|
||||
outb(val, i365_base); outb(data, i365_base+1);
|
||||
}
|
||||
|
||||
static void i365_bset(u_short sock, u_short reg, u_char mask)
|
||||
{
|
||||
u_char d = i365_get(sock, reg);
|
||||
d |= mask;
|
||||
i365_set(sock, reg, d);
|
||||
}
|
||||
|
||||
static void i365_bclr(u_short sock, u_short reg, u_char mask)
|
||||
{
|
||||
u_char d = i365_get(sock, reg);
|
||||
d &= ~mask;
|
||||
i365_set(sock, reg, d);
|
||||
}
|
||||
#endif
|
||||
|
||||
int i365_probe()
|
||||
{
|
||||
int val, slot, sock, done;
|
||||
// char *name = "i82365sl";
|
||||
|
||||
ioperm(i365_base, 4, 1);
|
||||
ioperm(0x80, 1, 1);
|
||||
for (slot = 0; slot < 2; slot++) {
|
||||
for (sock = done = 0; sock < 2; sock++) {
|
||||
val = i365_get(sock, I365_IDENT);
|
||||
switch (val) {
|
||||
case 0x82:
|
||||
// name = "i82365sl A step";
|
||||
// break;
|
||||
case 0x83:
|
||||
// name = "i82365sl B step";
|
||||
// break;
|
||||
case 0x84:
|
||||
// name = "VLSI 82C146";
|
||||
// break;
|
||||
case 0x88: case 0x89: case 0x8a:
|
||||
// name = "IBM Clone";
|
||||
// break;
|
||||
case 0x8b: case 0x8c:
|
||||
break;
|
||||
default:
|
||||
done = 1;
|
||||
}
|
||||
if (done) break;
|
||||
}
|
||||
if (done && sock) break;
|
||||
i365_base += 2;
|
||||
}
|
||||
|
||||
if (sock == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0 // the following code do nothing usefull, it ends with return 0 anyway
|
||||
if ((sock == 2) && (strcmp(name, "VLSI 82C146") == 0))
|
||||
name = "i82365sl DF";
|
||||
|
||||
/* Check for Vadem chips */
|
||||
outb(0x0e, i365_base);
|
||||
outb(0x37, i365_base);
|
||||
i365_bset(0, VG468_MISC, VG468_MISC_VADEMREV);
|
||||
val = i365_get(0, I365_IDENT);
|
||||
if (val & I365_IDENT_VADEM) {
|
||||
if ((val & 7) < 4)
|
||||
name = "Vadem VG-468";
|
||||
else
|
||||
name = "Vadem VG-469";
|
||||
i365_bclr(0, VG468_MISC, VG468_MISC_VADEMREV);
|
||||
}
|
||||
|
||||
/* Check for Cirrus CL-PD67xx chips */
|
||||
i365_set(0, PD67_CHIP_INFO, 0);
|
||||
val = i365_get(0, PD67_CHIP_INFO);
|
||||
if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) {
|
||||
val = i365_get(0, PD67_CHIP_INFO);
|
||||
if ((val & PD67_INFO_CHIP_ID) == 0) {
|
||||
if (val & PD67_INFO_SLOTS)
|
||||
name = "Cirrus CL-PD672x";
|
||||
else {
|
||||
name = "Cirrus CL-PD6710";
|
||||
sock = 1;
|
||||
}
|
||||
i365_set(0, PD67_EXT_INDEX, 0xe5);
|
||||
if (i365_get(0, PD67_EXT_INDEX) != 0xe5)
|
||||
name = "VIA VT83C469";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
} /* i365_probe */
|
||||
#endif
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
#ifndef __alpha__
|
||||
static u_short tcic_getw(ioaddr_t base, u_char reg)
|
||||
{
|
||||
u_short val = inw(base+reg);
|
||||
return val;
|
||||
}
|
||||
|
||||
static void tcic_setw(ioaddr_t base, u_char reg, u_short data)
|
||||
{
|
||||
outw(data, base+reg);
|
||||
}
|
||||
|
||||
int tcic_probe_at(ioaddr_t base)
|
||||
{
|
||||
int i;
|
||||
u_short old;
|
||||
|
||||
/* Anything there?? */
|
||||
for (i = 0; i < 0x10; i += 2)
|
||||
if (tcic_getw(base, i) == 0xffff)
|
||||
return -1;
|
||||
|
||||
/* Try to reset the chip */
|
||||
tcic_setw(base, TCIC_SCTRL, TCIC_SCTRL_RESET);
|
||||
tcic_setw(base, TCIC_SCTRL, 0);
|
||||
|
||||
/* Can we set the addr register? */
|
||||
old = tcic_getw(base, TCIC_ADDR);
|
||||
tcic_setw(base, TCIC_ADDR, 0);
|
||||
if (tcic_getw(base, TCIC_ADDR) != 0) {
|
||||
tcic_setw(base, TCIC_ADDR, old);
|
||||
return -2;
|
||||
}
|
||||
|
||||
tcic_setw(base, TCIC_ADDR, 0xc3a5);
|
||||
if (tcic_getw(base, TCIC_ADDR) != 0xc3a5)
|
||||
return -3;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int tcic_probe(ioaddr_t base)
|
||||
{
|
||||
int sock;
|
||||
|
||||
ioperm(base, 16, 1);
|
||||
ioperm(0x80, 1, 1);
|
||||
sock = tcic_probe_at(base);
|
||||
|
||||
if (sock <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
} /* tcic_probe */
|
||||
#endif
|
||||
|
||||
/*====================================================================*/
|
||||
char * initialize_pcmcia (void)
|
||||
{
|
||||
#ifndef __alpha__
|
||||
ioaddr_t tcic_base = TCIC_BASE;
|
||||
#endif
|
||||
char* pcmcia;
|
||||
|
||||
if ((pcmcia = pci_probe()))
|
||||
return pcmcia; /* we're all done */
|
||||
#ifndef __alpha__
|
||||
else if (i365_probe() == 0)
|
||||
return "i82365";
|
||||
else if (tcic_probe(tcic_base) == 0)
|
||||
return "tcic";
|
||||
#endif
|
||||
else {
|
||||
/* Detect ISAPNP based i82365 controllers */
|
||||
FILE *f;
|
||||
modprobe("i82365");
|
||||
if ((f = fopen("/proc/bus/pccard/00/info", "r"))) {
|
||||
fclose(f);
|
||||
return "i82365";
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
614
src/install+setup/install/pcmcia.h
Normal file
614
src/install+setup/install/pcmcia.h
Normal file
@@ -0,0 +1,614 @@
|
||||
/*
|
||||
* PCMCIA bridge device probe
|
||||
*
|
||||
* This file is part of the IPCop Firewall.
|
||||
*
|
||||
* IPCop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* IPCop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with IPCop; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* The initial developer of the original code is David A. Hinds
|
||||
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
|
||||
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
|
||||
*
|
||||
* $Id: pcmcia.h,v 1.1 2004/01/25 09:34:59 riddles Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#define TCIC_BASE 0x240
|
||||
|
||||
/* offsets of registers from TCIC_BASE */
|
||||
#define TCIC_DATA 0x00
|
||||
#define TCIC_ADDR 0x02
|
||||
#define TCIC_SCTRL 0x06
|
||||
#define TCIC_SSTAT 0x07
|
||||
#define TCIC_MODE 0x08
|
||||
#define TCIC_PWR 0x09
|
||||
#define TCIC_EDC 0x0A
|
||||
#define TCIC_ICSR 0x0C
|
||||
#define TCIC_IENA 0x0D
|
||||
#define TCIC_AUX 0x0E
|
||||
|
||||
#define TCIC_SS_SHFT 12
|
||||
#define TCIC_SS_MASK 0x7000
|
||||
|
||||
/* Flags for TCIC_ADDR */
|
||||
#define TCIC_ADR2_REG 0x8000
|
||||
#define TCIC_ADR2_INDREG 0x0800
|
||||
|
||||
#define TCIC_ADDR_REG 0x80000000
|
||||
#define TCIC_ADDR_SS_SHFT (TCIC_SS_SHFT+16)
|
||||
#define TCIC_ADDR_SS_MASK (TCIC_SS_MASK<<16)
|
||||
#define TCIC_ADDR_INDREG 0x08000000
|
||||
#define TCIC_ADDR_IO 0x04000000
|
||||
#define TCIC_ADDR_MASK 0x03ffffff
|
||||
|
||||
/* Flags for TCIC_SCTRL */
|
||||
#define TCIC_SCTRL_ENA 0x01
|
||||
#define TCIC_SCTRL_INCMODE 0x18
|
||||
#define TCIC_SCTRL_INCMODE_HOLD 0x00
|
||||
#define TCIC_SCTRL_INCMODE_WORD 0x08
|
||||
#define TCIC_SCTRL_INCMODE_REG 0x10
|
||||
#define TCIC_SCTRL_INCMODE_AUTO 0x18
|
||||
#define TCIC_SCTRL_EDCSUM 0x20
|
||||
#define TCIC_SCTRL_RESET 0x80
|
||||
|
||||
/* Flags for TCIC_SSTAT */
|
||||
#define TCIC_SSTAT_6US 0x01
|
||||
#define TCIC_SSTAT_10US 0x02
|
||||
#define TCIC_SSTAT_PROGTIME 0x04
|
||||
#define TCIC_SSTAT_LBAT1 0x08
|
||||
#define TCIC_SSTAT_LBAT2 0x10
|
||||
#define TCIC_SSTAT_RDY 0x20 /* Inverted */
|
||||
#define TCIC_SSTAT_WP 0x40
|
||||
#define TCIC_SSTAT_CD 0x80 /* Card detect */
|
||||
|
||||
/* Flags for TCIC_MODE */
|
||||
#define TCIC_MODE_PGMMASK 0x1f
|
||||
#define TCIC_MODE_NORMAL 0x00
|
||||
#define TCIC_MODE_PGMWR 0x01
|
||||
#define TCIC_MODE_PGMRD 0x02
|
||||
#define TCIC_MODE_PGMCE 0x04
|
||||
#define TCIC_MODE_PGMDBW 0x08
|
||||
#define TCIC_MODE_PGMWORD 0x10
|
||||
#define TCIC_MODE_AUXSEL_MASK 0xe0
|
||||
|
||||
/* Registers accessed through TCIC_AUX, by setting TCIC_MODE */
|
||||
#define TCIC_AUX_TCTL (0<<5)
|
||||
#define TCIC_AUX_PCTL (1<<5)
|
||||
#define TCIC_AUX_WCTL (2<<5)
|
||||
#define TCIC_AUX_EXTERN (3<<5)
|
||||
#define TCIC_AUX_PDATA (4<<5)
|
||||
#define TCIC_AUX_SYSCFG (5<<5)
|
||||
#define TCIC_AUX_ILOCK (6<<5)
|
||||
#define TCIC_AUX_TEST (7<<5)
|
||||
|
||||
/* Flags for TCIC_PWR */
|
||||
#define TCIC_PWR_VCC(sock) (0x01<<(sock))
|
||||
#define TCIC_PWR_VCC_MASK 0x03
|
||||
#define TCIC_PWR_VPP(sock) (0x08<<(sock))
|
||||
#define TCIC_PWR_VPP_MASK 0x18
|
||||
#define TCIC_PWR_CLIMENA 0x40
|
||||
#define TCIC_PWR_CLIMSTAT 0x80
|
||||
|
||||
/* Flags for TCIC_ICSR */
|
||||
#define TCIC_ICSR_CLEAR 0x01
|
||||
#define TCIC_ICSR_SET 0x02
|
||||
#define TCIC_ICSR_JAM (TCIC_ICSR_CLEAR|TCIC_ICSR_SET)
|
||||
#define TCIC_ICSR_STOPCPU 0x04
|
||||
#define TCIC_ICSR_ILOCK 0x08
|
||||
#define TCIC_ICSR_PROGTIME 0x10
|
||||
#define TCIC_ICSR_ERR 0x20
|
||||
#define TCIC_ICSR_CDCHG 0x40
|
||||
#define TCIC_ICSR_IOCHK 0x80
|
||||
|
||||
/* Flags for TCIC_IENA */
|
||||
#define TCIC_IENA_CFG_MASK 0x03
|
||||
#define TCIC_IENA_CFG_OFF 0x00 /* disabled */
|
||||
#define TCIC_IENA_CFG_OD 0x01 /* active low, open drain */
|
||||
#define TCIC_IENA_CFG_LOW 0x02 /* active low, totem pole */
|
||||
#define TCIC_IENA_CFG_HIGH 0x03 /* active high, totem pole */
|
||||
#define TCIC_IENA_ILOCK 0x08
|
||||
#define TCIC_IENA_PROGTIME 0x10
|
||||
#define TCIC_IENA_ERR 0x20 /* overcurrent or iochk */
|
||||
#define TCIC_IENA_CDCHG 0x40
|
||||
|
||||
/* Flags for TCIC_AUX_WCTL */
|
||||
#define TCIC_WAIT_COUNT_MASK 0x001f
|
||||
#define TCIC_WAIT_ASYNC 0x0020
|
||||
#define TCIC_WAIT_SENSE 0x0040
|
||||
#define TCIC_WAIT_SRC 0x0080
|
||||
#define TCIC_WCTL_WR 0x0100
|
||||
#define TCIC_WCTL_RD 0x0200
|
||||
#define TCIC_WCTL_CE 0x0400
|
||||
#define TCIC_WCTL_LLBAT1 0x0800
|
||||
#define TCIC_WCTL_LLBAT2 0x1000
|
||||
#define TCIC_WCTL_LRDY 0x2000
|
||||
#define TCIC_WCTL_LWP 0x4000
|
||||
#define TCIC_WCTL_LCD 0x8000
|
||||
|
||||
/* Flags for TCIC_AUX_SYSCFG */
|
||||
#define TCIC_SYSCFG_IRQ_MASK 0x000f
|
||||
#define TCIC_SYSCFG_MCSFULL 0x0010
|
||||
#define TCIC_SYSCFG_IO1723 0x0020
|
||||
#define TCIC_SYSCFG_MCSXB 0x0040
|
||||
#define TCIC_SYSCFG_ICSXB 0x0080
|
||||
#define TCIC_SYSCFG_NOPDN 0x0100
|
||||
#define TCIC_SYSCFG_MPSEL_SHFT 9
|
||||
#define TCIC_SYSCFG_MPSEL_MASK 0x0e00
|
||||
#define TCIC_SYSCFG_MPSENSE 0x2000
|
||||
#define TCIC_SYSCFG_AUTOBUSY 0x4000
|
||||
#define TCIC_SYSCFG_ACC 0x8000
|
||||
|
||||
#define TCIC_ILOCK_OUT 0x01
|
||||
#define TCIC_ILOCK_SENSE 0x02
|
||||
#define TCIC_ILOCK_CRESET 0x04
|
||||
#define TCIC_ILOCK_CRESENA 0x08
|
||||
#define TCIC_ILOCK_CWAIT 0x10
|
||||
#define TCIC_ILOCK_CWAITSNS 0x20
|
||||
#define TCIC_ILOCK_HOLD_MASK 0xc0
|
||||
#define TCIC_ILOCK_HOLD_CCLK 0xc0
|
||||
|
||||
#define TCIC_ILOCKTEST_ID_SH 8
|
||||
#define TCIC_ILOCKTEST_ID_MASK 0x7f00
|
||||
#define TCIC_ILOCKTEST_MCIC_1 0x8000
|
||||
|
||||
#define TCIC_ID_DB86082 0x02
|
||||
#define TCIC_ID_DB86082A 0x03
|
||||
#define TCIC_ID_DB86084 0x04
|
||||
#define TCIC_ID_DB86084A 0x08
|
||||
#define TCIC_ID_DB86072 0x15
|
||||
#define TCIC_ID_DB86184 0x14
|
||||
#define TCIC_ID_DB86082B 0x17
|
||||
|
||||
#define TCIC_TEST_DIAG 0x8000
|
||||
|
||||
/*
|
||||
* Indirectly addressed registers
|
||||
*/
|
||||
|
||||
#define TCIC_SCF1(sock) ((sock)<<3)
|
||||
#define TCIC_SCF2(sock) (((sock)<<3)+2)
|
||||
|
||||
/* Flags for SCF1 */
|
||||
#define TCIC_SCF1_IRQ_MASK 0x000f
|
||||
#define TCIC_SCF1_IRQ_OFF 0x0000
|
||||
#define TCIC_SCF1_IRQOC 0x0010
|
||||
#define TCIC_SCF1_PCVT 0x0020
|
||||
#define TCIC_SCF1_IRDY 0x0040
|
||||
#define TCIC_SCF1_ATA 0x0080
|
||||
#define TCIC_SCF1_DMA_SHIFT 8
|
||||
#define TCIC_SCF1_DMA_MASK 0x0700
|
||||
#define TCIC_SCF1_DMA_OFF 0
|
||||
#define TCIC_SCF1_DREQ2 2
|
||||
#define TCIC_SCF1_IOSTS 0x0800
|
||||
#define TCIC_SCF1_SPKR 0x1000
|
||||
#define TCIC_SCF1_FINPACK 0x2000
|
||||
#define TCIC_SCF1_DELWR 0x4000
|
||||
#define TCIC_SCF1_HD7IDE 0x8000
|
||||
|
||||
/* Flags for SCF2 */
|
||||
#define TCIC_SCF2_RI 0x0001
|
||||
#define TCIC_SCF2_IDBR 0x0002
|
||||
#define TCIC_SCF2_MDBR 0x0004
|
||||
#define TCIC_SCF2_MLBAT1 0x0008
|
||||
#define TCIC_SCF2_MLBAT2 0x0010
|
||||
#define TCIC_SCF2_MRDY 0x0020
|
||||
#define TCIC_SCF2_MWP 0x0040
|
||||
#define TCIC_SCF2_MCD 0x0080
|
||||
#define TCIC_SCF2_MALL 0x00f8
|
||||
|
||||
/* Indirect addresses for memory window registers */
|
||||
#define TCIC_MWIN(sock,map) (0x100+(((map)+((sock)<<2))<<3))
|
||||
#define TCIC_MBASE_X 2
|
||||
#define TCIC_MMAP_X 4
|
||||
#define TCIC_MCTL_X 6
|
||||
|
||||
#define TCIC_MBASE_4K_BIT 0x4000
|
||||
#define TCIC_MBASE_HA_SHFT 12
|
||||
#define TCIC_MBASE_HA_MASK 0x0fff
|
||||
|
||||
#define TCIC_MMAP_REG 0x8000
|
||||
#define TCIC_MMAP_CA_SHFT 12
|
||||
#define TCIC_MMAP_CA_MASK 0x3fff
|
||||
|
||||
#define TCIC_MCTL_WSCNT_MASK 0x001f
|
||||
#define TCIC_MCTL_WCLK 0x0020
|
||||
#define TCIC_MCTL_WCLK_CCLK 0x0000
|
||||
#define TCIC_MCTL_WCLK_BCLK 0x0020
|
||||
#define TCIC_MCTL_QUIET 0x0040
|
||||
#define TCIC_MCTL_WP 0x0080
|
||||
#define TCIC_MCTL_ACC 0x0100
|
||||
#define TCIC_MCTL_KE 0x0200
|
||||
#define TCIC_MCTL_EDC 0x0400
|
||||
#define TCIC_MCTL_B8 0x0800
|
||||
#define TCIC_MCTL_SS_SHFT TCIC_SS_SHFT
|
||||
#define TCIC_MCTL_SS_MASK TCIC_SS_MASK
|
||||
#define TCIC_MCTL_ENA 0x8000
|
||||
|
||||
/* Indirect addresses for I/O window registers */
|
||||
#define TCIC_IWIN(sock,map) (0x200+(((map)+((sock)<<1))<<2))
|
||||
#define TCIC_IBASE_X 0
|
||||
#define TCIC_ICTL_X 2
|
||||
|
||||
#define TCIC_ICTL_WSCNT_MASK TCIC_MCTL_WSCNT_MASK
|
||||
#define TCIC_ICTL_QUIET TCIC_MCTL_QUIET
|
||||
#define TCIC_ICTL_1K 0x0080
|
||||
#define TCIC_ICTL_PASS16 0x0100
|
||||
#define TCIC_ICTL_ACC TCIC_MCTL_ACC
|
||||
#define TCIC_ICTL_TINY 0x0200
|
||||
#define TCIC_ICTL_B16 0x0400
|
||||
#define TCIC_ICTL_B8 TCIC_MCTL_B8
|
||||
#define TCIC_ICTL_BW_MASK (TCIC_ICTL_B16|TCIC_ICTL_B8)
|
||||
#define TCIC_ICTL_BW_DYN 0
|
||||
#define TCIC_ICTL_BW_8 TCIC_ICTL_B8
|
||||
#define TCIC_ICTL_BW_16 TCIC_ICTL_B16
|
||||
#define TCIC_ICTL_BW_ATA (TCIC_ICTL_B16|TCIC_ICTL_B8)
|
||||
#define TCIC_ICTL_SS_SHFT TCIC_SS_SHFT
|
||||
#define TCIC_ICTL_SS_MASK TCIC_SS_MASK
|
||||
#define TCIC_ICTL_ENA TCIC_MCTL_ENA
|
||||
|
||||
/* register definitions for the Intel 82365SL PCMCIA controller */
|
||||
|
||||
/* Offsets for PCIC registers */
|
||||
#define I365_IDENT 0x00 /* Identification and revision */
|
||||
#define I365_STATUS 0x01 /* Interface status */
|
||||
#define I365_POWER 0x02 /* Power and RESETDRV control */
|
||||
#define I365_INTCTL 0x03 /* Interrupt and general control */
|
||||
#define I365_CSC 0x04 /* Card status change */
|
||||
#define I365_CSCINT 0x05 /* Card status change interrupt control */
|
||||
#define I365_ADDRWIN 0x06 /* Address window enable */
|
||||
#define I365_IOCTL 0x07 /* I/O control */
|
||||
#define I365_GENCTL 0x16 /* Card detect and general control */
|
||||
#define I365_GBLCTL 0x1E /* Global control register */
|
||||
|
||||
/* Offsets for I/O and memory window registers */
|
||||
#define I365_IO(map) (0x08+((map)<<2))
|
||||
#define I365_MEM(map) (0x10+((map)<<3))
|
||||
#define I365_W_START 0
|
||||
#define I365_W_STOP 2
|
||||
#define I365_W_OFF 4
|
||||
|
||||
/* Flags for I365_STATUS */
|
||||
#define I365_CS_BVD1 0x01
|
||||
#define I365_CS_STSCHG 0x01
|
||||
#define I365_CS_BVD2 0x02
|
||||
#define I365_CS_SPKR 0x02
|
||||
#define I365_CS_DETECT 0x0C
|
||||
#define I365_CS_WRPROT 0x10
|
||||
#define I365_CS_READY 0x20 /* Inverted */
|
||||
#define I365_CS_POWERON 0x40
|
||||
#define I365_CS_GPI 0x80
|
||||
|
||||
/* Flags for I365_POWER */
|
||||
#define I365_PWR_OFF 0x00 /* Turn off the socket */
|
||||
#define I365_PWR_OUT 0x80 /* Output enable */
|
||||
#define I365_PWR_NORESET 0x40 /* Disable RESETDRV on resume */
|
||||
#define I365_PWR_AUTO 0x20 /* Auto pwr switch enable */
|
||||
#define I365_VCC_MASK 0x18 /* Mask for turning off Vcc */
|
||||
/* There are different layouts for B-step and DF-step chips: the B
|
||||
step has independent Vpp1/Vpp2 control, and the DF step has only
|
||||
Vpp1 control, plus 3V control */
|
||||
#define I365_VCC_5V 0x10 /* Vcc = 5.0v */
|
||||
#define I365_VCC_3V 0x18 /* Vcc = 3.3v */
|
||||
#define I365_VPP2_MASK 0x0c /* Mask for turning off Vpp2 */
|
||||
#define I365_VPP2_5V 0x04 /* Vpp2 = 5.0v */
|
||||
#define I365_VPP2_12V 0x08 /* Vpp2 = 12.0v */
|
||||
#define I365_VPP1_MASK 0x03 /* Mask for turning off Vpp1 */
|
||||
#define I365_VPP1_5V 0x01 /* Vpp2 = 5.0v */
|
||||
#define I365_VPP1_12V 0x02 /* Vpp2 = 12.0v */
|
||||
|
||||
/* Flags for I365_INTCTL */
|
||||
#define I365_RING_ENA 0x80
|
||||
#define I365_PC_RESET 0x40
|
||||
#define I365_PC_IOCARD 0x20
|
||||
#define I365_INTR_ENA 0x10
|
||||
#define I365_IRQ_MASK 0x0F
|
||||
|
||||
/* Flags for I365_CSC and I365_CSCINT*/
|
||||
#define I365_CSC_BVD1 0x01
|
||||
#define I365_CSC_STSCHG 0x01
|
||||
#define I365_CSC_BVD2 0x02
|
||||
#define I365_CSC_READY 0x04
|
||||
#define I365_CSC_DETECT 0x08
|
||||
#define I365_CSC_ANY 0x0F
|
||||
#define I365_CSC_GPI 0x10
|
||||
|
||||
/* Flags for I365_ADDRWIN */
|
||||
#define I365_ADDR_MEMCS16 0x20
|
||||
#define I365_ENA_IO(map) (0x40 << (map))
|
||||
#define I365_ENA_MEM(map) (0x01 << (map))
|
||||
|
||||
/* Flags for I365_IOCTL */
|
||||
#define I365_IOCTL_MASK(map) (0x0F << (map<<2))
|
||||
#define I365_IOCTL_WAIT(map) (0x08 << (map<<2))
|
||||
#define I365_IOCTL_0WS(map) (0x04 << (map<<2))
|
||||
#define I365_IOCTL_IOCS16(map) (0x02 << (map<<2))
|
||||
#define I365_IOCTL_16BIT(map) (0x01 << (map<<2))
|
||||
|
||||
/* Flags for I365_GENCTL */
|
||||
#define I365_CTL_16DELAY 0x01
|
||||
#define I365_CTL_RESET 0x02
|
||||
#define I365_CTL_GPI_ENA 0x04
|
||||
#define I365_CTL_GPI_CTL 0x08
|
||||
#define I365_CTL_RESUME 0x10
|
||||
#define I365_CTL_SW_IRQ 0x20
|
||||
|
||||
/* Flags for I365_GBLCTL */
|
||||
#define I365_GBL_PWRDOWN 0x01
|
||||
#define I365_GBL_CSC_LEV 0x02
|
||||
#define I365_GBL_WRBACK 0x04
|
||||
#define I365_GBL_IRQ_0_LEV 0x08
|
||||
#define I365_GBL_IRQ_1_LEV 0x10
|
||||
|
||||
/* Flags for memory window registers */
|
||||
#define I365_MEM_16BIT 0x8000 /* In memory start high byte */
|
||||
#define I365_MEM_0WS 0x4000
|
||||
#define I365_MEM_WS1 0x8000 /* In memory stop high byte */
|
||||
#define I365_MEM_WS0 0x4000
|
||||
#define I365_MEM_WRPROT 0x8000 /* In offset high byte */
|
||||
#define I365_MEM_REG 0x4000
|
||||
|
||||
#define I365_REG(slot, reg) (((slot) << 6) | (reg))
|
||||
|
||||
/* Default ISA interrupt mask */
|
||||
#define I365_ISA_IRQ_MASK 0xdeb8 /* irq's 3-5,7,9-12,14,15 */
|
||||
|
||||
/* Device ID's for PCI-to-PCMCIA bridges */
|
||||
|
||||
#ifndef PCI_VENDOR_ID_INTEL
|
||||
#define PCI_VENDOR_ID_INTEL 0x8086
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_INTEL_82092AA_0
|
||||
#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
|
||||
#endif
|
||||
#ifndef PCI_VENDOR_ID_OMEGA
|
||||
#define PCI_VENDOR_ID_OMEGA 0x119b
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_OMEGA_82C092G
|
||||
#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221
|
||||
#endif
|
||||
|
||||
#ifndef PCI_VENDOR_ID_CIRRUS
|
||||
#define PCI_VENDOR_ID_CIRRUS 0x1013
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_CIRRUS_6729
|
||||
#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
|
||||
#endif
|
||||
#ifndef PCI_DEVICE_ID_CIRRUS_6832
|
||||
#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
|
||||
#endif
|
||||
|
||||
#define PD67_MISC_CTL_1 0x16 /* Misc control 1 */
|
||||
#define PD67_FIFO_CTL 0x17 /* FIFO control */
|
||||
#define PD67_MISC_CTL_2 0x1E /* Misc control 2 */
|
||||
#define PD67_CHIP_INFO 0x1f /* Chip information */
|
||||
#define PD67_ATA_CTL 0x026 /* 6730: ATA control */
|
||||
#define PD67_EXT_INDEX 0x2e /* Extension index */
|
||||
#define PD67_EXT_DATA 0x2f /* Extension data */
|
||||
|
||||
#define pd67_ext_get(s, r) \
|
||||
(i365_set(s, PD67_EXT_INDEX, r), i365_get(s, PD67_EXT_DATA))
|
||||
#define pd67_ext_set(s, r, v) \
|
||||
(i365_set(s, PD67_EXT_INDEX, r), i365_set(s, PD67_EXT_DATA, v))
|
||||
|
||||
/* PD6722 extension registers -- indexed in PD67_EXT_INDEX */
|
||||
#define PD67_DATA_MASK0 0x01 /* Data mask 0 */
|
||||
#define PD67_DATA_MASK1 0x02 /* Data mask 1 */
|
||||
#define PD67_DMA_CTL 0x03 /* DMA control */
|
||||
|
||||
/* PD6730 extension registers -- indexed in PD67_EXT_INDEX */
|
||||
#define PD67_EXT_CTL_1 0x03 /* Extension control 1 */
|
||||
#define PD67_MEM_PAGE(n) ((n)+5) /* PCI window bits 31:24 */
|
||||
#define PD67_EXTERN_DATA 0x0a
|
||||
#define PD67_EXT_CTL_2 0x0b
|
||||
#define PD67_MISC_CTL_3 0x25
|
||||
#define PD67_SMB_PWR_CTL 0x26
|
||||
|
||||
/* I/O window address offset */
|
||||
#define PD67_IO_OFF(w) (0x36+((w)<<1))
|
||||
|
||||
/* Timing register sets */
|
||||
#define PD67_TIME_SETUP(n) (0x3a + 3*(n))
|
||||
#define PD67_TIME_CMD(n) (0x3b + 3*(n))
|
||||
#define PD67_TIME_RECOV(n) (0x3c + 3*(n))
|
||||
|
||||
/* Flags for PD67_MISC_CTL_1 */
|
||||
#define PD67_MC1_5V_DET 0x01 /* 5v detect */
|
||||
#define PD67_MC1_MEDIA_ENA 0x01 /* 6730: Multimedia enable */
|
||||
#define PD67_MC1_VCC_3V 0x02 /* 3.3v Vcc */
|
||||
#define PD67_MC1_PULSE_MGMT 0x04
|
||||
#define PD67_MC1_PULSE_IRQ 0x08
|
||||
#define PD67_MC1_SPKR_ENA 0x10
|
||||
#define PD67_MC1_INPACK_ENA 0x80
|
||||
|
||||
/* Flags for PD67_FIFO_CTL */
|
||||
#define PD67_FIFO_EMPTY 0x80
|
||||
|
||||
/* Flags for PD67_MISC_CTL_2 */
|
||||
#define PD67_MC2_FREQ_BYPASS 0x01
|
||||
#define PD67_MC2_DYNAMIC_MODE 0x02
|
||||
#define PD67_MC2_SUSPEND 0x04
|
||||
#define PD67_MC2_5V_CORE 0x08
|
||||
#define PD67_MC2_LED_ENA 0x10 /* IRQ 12 is LED enable */
|
||||
#define PD67_MC2_FAST_PCI 0x10 /* 6729: PCI bus > 25 MHz */
|
||||
#define PD67_MC2_3STATE_BIT7 0x20 /* Floppy change bit */
|
||||
#define PD67_MC2_DMA_MODE 0x40
|
||||
#define PD67_MC2_IRQ15_RI 0x80 /* IRQ 15 is ring enable */
|
||||
|
||||
/* Flags for PD67_CHIP_INFO */
|
||||
#define PD67_INFO_SLOTS 0x20 /* 0 = 1 slot, 1 = 2 slots */
|
||||
#define PD67_INFO_CHIP_ID 0xc0
|
||||
#define PD67_INFO_REV 0x1c
|
||||
|
||||
/* Fields in PD67_TIME_* registers */
|
||||
#define PD67_TIME_SCALE 0xc0
|
||||
#define PD67_TIME_SCALE_1 0x00
|
||||
#define PD67_TIME_SCALE_16 0x40
|
||||
#define PD67_TIME_SCALE_256 0x80
|
||||
#define PD67_TIME_SCALE_4096 0xc0
|
||||
#define PD67_TIME_MULT 0x3f
|
||||
|
||||
/* Fields in PD67_DMA_CTL */
|
||||
#define PD67_DMA_MODE 0xc0
|
||||
#define PD67_DMA_OFF 0x00
|
||||
#define PD67_DMA_DREQ_INPACK 0x40
|
||||
#define PD67_DMA_DREQ_WP 0x80
|
||||
#define PD67_DMA_DREQ_BVD2 0xc0
|
||||
#define PD67_DMA_PULLUP 0x20 /* Disable socket pullups? */
|
||||
|
||||
/* Fields in PD67_EXT_CTL_1 */
|
||||
#define PD67_EC1_VCC_PWR_LOCK 0x01
|
||||
#define PD67_EC1_AUTO_PWR_CLEAR 0x02
|
||||
#define PD67_EC1_LED_ENA 0x04
|
||||
#define PD67_EC1_INV_CARD_IRQ 0x08
|
||||
#define PD67_EC1_INV_MGMT_IRQ 0x10
|
||||
#define PD67_EC1_PULLUP_CTL 0x20
|
||||
|
||||
/* Fields in PD67_EXTERN_DATA */
|
||||
#define PD67_EXD_VS1(s) (0x01 << ((s)<<1))
|
||||
#define PD67_EXD_VS2(s) (0x02 << ((s)<<1))
|
||||
|
||||
/* Fields in PD67_EXT_CTL_2 */
|
||||
#define PD67_EC2_GPSTB_TOTEM 0x04
|
||||
#define PD67_EC2_GPSTB_IOR 0x08
|
||||
#define PD67_EC2_GPSTB_IOW 0x10
|
||||
#define PD67_EC2_GPSTB_HIGH 0x20
|
||||
|
||||
/* Fields in PD67_MISC_CTL_3 */
|
||||
#define PD67_MC3_IRQ_MASK 0x03
|
||||
#define PD67_MC3_IRQ_PCPCI 0x00
|
||||
#define PD67_MC3_IRQ_EXTERN 0x01
|
||||
#define PD67_MC3_IRQ_PCIWAY 0x02
|
||||
#define PD67_MC3_IRQ_PCI 0x03
|
||||
#define PD67_MC3_PWR_MASK 0x0c
|
||||
#define PD67_MC3_PWR_SERIAL 0x00
|
||||
#define PD67_MC3_PWR_TI2202 0x08
|
||||
#define PD67_MC3_PWR_SMB 0x0c
|
||||
|
||||
/* Register definitions for Cirrus PD6832 PCI-to-CardBus bridge */
|
||||
|
||||
/* PD6832 extension registers -- indexed in PD67_EXT_INDEX */
|
||||
#define PD68_PCI_SPACE 0x22
|
||||
#define PD68_PCCARD_SPACE 0x23
|
||||
#define PD68_WINDOW_TYPE 0x24
|
||||
#define PD68_EXT_CSC 0x2e
|
||||
#define PD68_MISC_CTL_4 0x2f
|
||||
#define PD68_MISC_CTL_5 0x30
|
||||
#define PD68_MISC_CTL_6 0x31
|
||||
|
||||
/* Extra flags in PD67_MISC_CTL_3 */
|
||||
#define PD68_MC3_HW_SUSP 0x10
|
||||
#define PD68_MC3_MM_EXPAND 0x40
|
||||
#define PD68_MC3_MM_ARM 0x80
|
||||
|
||||
/* Bridge Control Register */
|
||||
#define PD6832_BCR_MGMT_IRQ_ENA 0x0800
|
||||
|
||||
/* Socket Number Register */
|
||||
#define PD6832_SOCKET_NUMBER 0x004c /* 8 bit */
|
||||
|
||||
/* Data structure for tracking vendor-specific state */
|
||||
typedef struct cirrus_state_t {
|
||||
u_char misc1; /* PD67_MISC_CTL_1 */
|
||||
u_char misc2; /* PD67_MISC_CTL_2 */
|
||||
u_char ectl1; /* PD67_EXT_CTL_1 */
|
||||
u_char timer[6]; /* PD67_TIME_* */
|
||||
} cirrus_state_t;
|
||||
|
||||
#define CIRRUS_PCIC_ID \
|
||||
IS_PD6729, IS_PD6730, IS_PD6832
|
||||
|
||||
#define CIRRUS_PCIC_INFO \
|
||||
{ "Cirrus PD6729", IS_CIRRUS|IS_PCI, ID(CIRRUS, 6729) }, \
|
||||
{ "Cirrus PD6730", IS_CIRRUS|IS_PCI, PCI_VENDOR_ID_CIRRUS, -1 }, \
|
||||
{ "Cirrus PD6832", IS_CIRRUS|IS_CARDBUS, ID(CIRRUS, 6832) }
|
||||
|
||||
/* Special bit in I365_IDENT used for Vadem chip detection */
|
||||
#define I365_IDENT_VADEM 0x08
|
||||
|
||||
/* Special definitions in I365_POWER */
|
||||
#define VG468_VPP2_MASK 0x0c
|
||||
#define VG468_VPP2_5V 0x04
|
||||
#define VG468_VPP2_12V 0x08
|
||||
|
||||
/* Unique Vadem registers */
|
||||
#define VG469_VSENSE 0x1f /* Card voltage sense */
|
||||
#define VG469_VSELECT 0x2f /* Card voltage select */
|
||||
#define VG468_CTL 0x38 /* Control register */
|
||||
#define VG468_TIMER 0x39 /* Timer control */
|
||||
#define VG468_MISC 0x3a /* Miscellaneous */
|
||||
#define VG468_GPIO_CFG 0x3b /* GPIO configuration */
|
||||
#define VG469_EXT_MODE 0x3c /* Extended mode register */
|
||||
#define VG468_SELECT 0x3d /* Programmable chip select */
|
||||
#define VG468_SELECT_CFG 0x3e /* Chip select configuration */
|
||||
#define VG468_ATA 0x3f /* ATA control */
|
||||
|
||||
/* Flags for VG469_VSENSE */
|
||||
#define VG469_VSENSE_A_VS1 0x01
|
||||
#define VG469_VSENSE_A_VS2 0x02
|
||||
#define VG469_VSENSE_B_VS1 0x04
|
||||
#define VG469_VSENSE_B_VS2 0x08
|
||||
|
||||
/* Flags for VG469_VSELECT */
|
||||
#define VG469_VSEL_VCC 0x03
|
||||
#define VG469_VSEL_5V 0x00
|
||||
#define VG469_VSEL_3V 0x03
|
||||
#define VG469_VSEL_MAX 0x0c
|
||||
#define VG469_VSEL_EXT_STAT 0x10
|
||||
#define VG469_VSEL_EXT_BUS 0x20
|
||||
#define VG469_VSEL_MIXED 0x40
|
||||
#define VG469_VSEL_ISA 0x80
|
||||
|
||||
/* Flags for VG468_CTL */
|
||||
#define VG468_CTL_SLOW 0x01 /* 600ns memory timing */
|
||||
#define VG468_CTL_ASYNC 0x02 /* Asynchronous bus clocking */
|
||||
#define VG468_CTL_TSSI 0x08 /* Tri-state some outputs */
|
||||
#define VG468_CTL_DELAY 0x10 /* Card detect debounce */
|
||||
#define VG468_CTL_INPACK 0x20 /* Obey INPACK signal? */
|
||||
#define VG468_CTL_POLARITY 0x40 /* VCCEN polarity */
|
||||
#define VG468_CTL_COMPAT 0x80 /* Compatibility stuff */
|
||||
|
||||
#define VG469_CTL_WS_COMPAT 0x04 /* Wait state compatibility */
|
||||
#define VG469_CTL_STRETCH 0x10 /* LED stretch */
|
||||
|
||||
/* Flags for VG468_TIMER */
|
||||
#define VG468_TIMER_ZEROPWR 0x10 /* Zero power control */
|
||||
#define VG468_TIMER_SIGEN 0x20 /* Power up */
|
||||
#define VG468_TIMER_STATUS 0x40 /* Activity timer status */
|
||||
#define VG468_TIMER_RES 0x80 /* Timer resolution */
|
||||
#define VG468_TIMER_MASK 0x0f /* Activity timer timeout */
|
||||
|
||||
/* Flags for VG468_MISC */
|
||||
#define VG468_MISC_GPIO 0x04 /* General-purpose IO */
|
||||
#define VG468_MISC_DMAWSB 0x08 /* DMA wait state control */
|
||||
#define VG469_MISC_LEDENA 0x10 /* LED enable */
|
||||
#define VG468_MISC_VADEMREV 0x40 /* Vadem revision control */
|
||||
#define VG468_MISC_UNLOCK 0x80 /* Unique register lock */
|
||||
|
||||
/* Flags for VG469_EXT_MODE_A */
|
||||
#define VG469_MODE_VPPST 0x03 /* Vpp steering control */
|
||||
#define VG469_MODE_INT_SENSE 0x04 /* Internal voltage sense */
|
||||
#define VG469_MODE_CABLE 0x08
|
||||
#define VG469_MODE_COMPAT 0x10 /* i82365sl B or DF step */
|
||||
#define VG469_MODE_TEST 0x20
|
||||
#define VG469_MODE_RIO 0x40 /* Steer RIO to INTR? */
|
||||
|
||||
/* Flags for VG469_EXT_MODE_B */
|
||||
#define VG469_MODE_B_3V 0x01 /* 3.3v for socket B */
|
||||
|
||||
/* Data structure for tracking vendor-specific state */
|
||||
typedef struct vg46x_state_t {
|
||||
u_char ctl; /* VG468_CTL */
|
||||
u_char ema; /* VG468_EXT_MODE_A */
|
||||
} vg46x_state_t;
|
||||
64
src/install+setup/install/probescsi.sh
Normal file
64
src/install+setup/install/probescsi.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
OLDDIR=`pwd`
|
||||
cd /lib/modules/*/kernel/drivers/scsi
|
||||
/bin/modprobe scsi_mod.o.gz > /dev/null 2>&1
|
||||
/bin/modprobe sd_mod.o.gz > /dev/null 2>&1
|
||||
/bin/modprobe sr_mod.o.gz > /dev/null 2>&1
|
||||
/bin/modprobe sg.o.gz > /dev/null 2>&1
|
||||
/bin/modprobe libata.o.gz > /dev/null 2>&1
|
||||
echo "Trying cpqarray";
|
||||
if /bin/modprobe cpqarray > /dev/null 2>&1; then
|
||||
echo "cpqarray.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
echo "Trying cciss";
|
||||
if /bin/modprobe cciss > /dev/null 2>&1; then
|
||||
echo "cciss.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
echo "Trying DAC960";
|
||||
if /bin/modprobe DAC960 > /dev/null 2>&1; then
|
||||
echo "DAC960.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
/bin/modprobe ataraid.o.gz > /dev/null 2>&1
|
||||
echo "Trying medley";
|
||||
if /bin/modprobe medley > /dev/null 2>&1; then
|
||||
echo "medley.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
echo "Trying hptraid";
|
||||
if /bin/modprobe hptraid > /dev/null 2>&1; then
|
||||
echo "hptraid.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
echo "Trying pdcraid";
|
||||
if /bin/modprobe pdcraid > /dev/null 2>&1; then
|
||||
echo "pdcraid.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
echo "Trying silraid";
|
||||
if /bin/modprobe silraid > /dev/null 2>&1; then
|
||||
echo "silraid.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
for i in * message/fusion/mptscsih.o.gz ;
|
||||
do
|
||||
# Skip the generic scsi modules and ancillary support modules
|
||||
# Added eata_dma to skip list because it crashes some machines. Probe last.
|
||||
if [ $i != "scsi_mod.o.gz" -a $i != "sd_mod.o.gz" -a $i != "sg.o.gz" -a $i != "sr_mod.o.gz" -a $i != "53c700.o.gz" -a $i != "NCR53C9x.o.gz" -a $i != "eata_dma.o.gz" -a $i != "libata.o.gz" ]; then
|
||||
DRIVER=`echo $i | sed 's/.o.gz//'`
|
||||
echo "Trying $DRIVER";
|
||||
if /bin/modprobe $DRIVER > /dev/null 2>&1; then
|
||||
echo $i > /scsidriver;
|
||||
/bin/cat /proc/scsi/scsi;
|
||||
exit 0;
|
||||
fi;
|
||||
fi;
|
||||
done
|
||||
echo "Trying eata_dma";
|
||||
if /bin/modprobe eata_dma > /dev/null 2>&1; then
|
||||
echo "eata_dma.o.gz" > /scsidriver;
|
||||
exit 0;
|
||||
fi
|
||||
cd $OLDDIR
|
||||
28
src/install+setup/install/scsi.c
Normal file
28
src/install+setup/install/scsi.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* IPCop install program.
|
||||
*
|
||||
* This program is distributed under the terms of the GNU General Public
|
||||
* Licence. See the file COPYING for details.
|
||||
*
|
||||
* (c) Alan Hourihane, 2003 <alanh@fairlite.demon.co.uk>
|
||||
*
|
||||
* $Id: scsi.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
int
|
||||
try_scsi(char *disk_device)
|
||||
{
|
||||
int fd;
|
||||
char dev[10];
|
||||
|
||||
sprintf(dev, "/dev/%s", disk_device);
|
||||
|
||||
if ((fd = open(dev, O_RDONLY)) < 0)
|
||||
return 0;
|
||||
|
||||
close(fd);
|
||||
// remove usb scsi
|
||||
return ( checkusb(disk_device) ? 0:1 );
|
||||
}
|
||||
340
src/install+setup/install/upgrade-v12-v13.c
Normal file
340
src/install+setup/install/upgrade-v12-v13.c
Normal file
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* This file is part of the IPCop Firewall.
|
||||
*
|
||||
* IPCop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* IPCop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with IPCop; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Copyright 2002: Mark Wormgoor <mark@wormgoor.com>
|
||||
*
|
||||
* $Id: upgrade-v12-v13.c,v 1.2.2.3 2004/11/11 09:39:25 alanh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
void _convert_ppp_settings() {
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char filename[STRING_SIZE];
|
||||
|
||||
dirp = opendir( "/harddisk/var/ipcop/ppp" );
|
||||
while ( (dp = readdir( dirp )) != NULL ) {
|
||||
if ( strstr( dp->d_name, "settings" ) == dp->d_name ) {
|
||||
snprintf (filename, STRING_SIZE-1, "%s/%s",
|
||||
"/harddisk/var/ipcop/ppp", dp->d_name);
|
||||
|
||||
/* reduce furthur replacements from commands below */
|
||||
replace (filename, "TYPE=modem", "");
|
||||
replace (filename, "COMPORT=ttyS0", "TYPE=modem\nCOMPORT=ttyS0");
|
||||
replace (filename, "COMPORT=ttyS1", "TYPE=modem\nCOMPORT=ttyS1");
|
||||
replace (filename, "COMPORT=ttyS2", "TYPE=modem\nCOMPORT=ttyS2");
|
||||
replace (filename, "COMPORT=ttyS3", "TYPE=modem\nCOMPORT=ttyS3");
|
||||
/* reduce furthur replacements from commands below */
|
||||
replace (filename, "TYPE=isdn", "");
|
||||
replace (filename, "COMPORT=isdn1", "TYPE=isdn\nCOMPORT=isdn1");
|
||||
replace (filename, "COMPORT=isdn2", "TYPE=isdn\nCOMPORT=isdn2");
|
||||
replace (filename, "COMPORT=pppoe", "TYPE=pppoe");
|
||||
replace (filename, "COMPORT=pptp", "TYPE=pptp");
|
||||
replace (filename, "COMPORT=usbadsl", "TYPE=alcatelusb");
|
||||
replace (filename, "COMPORT=pppoa", "TYPE=pulsardsl");
|
||||
|
||||
chown (filename, 99, 99);
|
||||
}
|
||||
}
|
||||
(void) closedir( dirp );
|
||||
}
|
||||
|
||||
int _convert_xtaccess() {
|
||||
int count=1, count2=0;
|
||||
FILE *portfw1, *portfw2;
|
||||
char portsrctemp[STRING_SIZE], portdsttemp[STRING_SIZE];
|
||||
char *portproto, *portsrcip, *portsrcport, *portdstip, *portdstport, *portenabled, *portremip;
|
||||
|
||||
FILE *xtaccess1, *xtaccess2;
|
||||
char xtsrctemp[STRING_SIZE], xtdsttemp[STRING_SIZE];
|
||||
char *xtproto, *xtsrcip, *xtdstip, *xtdstport, *xtenabled;
|
||||
|
||||
if (!(portfw1 = fopen ("/harddisk/var/ipcop/portfw/config", "r"))) return 1;
|
||||
if (!(portfw2 = fopen ("/harddisk/var/ipcop/portfw/config.new", "w")))
|
||||
{
|
||||
fclose(portfw1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (fgets (portsrctemp, STRING_SIZE, portfw1) != NULL) {
|
||||
count2 = 0;
|
||||
portproto = NULL;
|
||||
portsrcip = NULL;
|
||||
portsrcport = NULL;
|
||||
portdstip = NULL;
|
||||
portdstport = NULL;
|
||||
portremip = NULL;
|
||||
portenabled = NULL;
|
||||
|
||||
if (!(xtaccess1 = fopen ("/harddisk/var/ipcop/xtaccess/config", "r")))
|
||||
{
|
||||
fclose(portfw1);
|
||||
fclose(portfw2);
|
||||
return 1;
|
||||
}
|
||||
if (!(xtaccess2 = fopen ("/harddisk/var/ipcop/xtaccess/config.new", "w")))
|
||||
{
|
||||
fclose(portfw1);
|
||||
fclose(portfw2);
|
||||
fclose(xtaccess1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (isdigit (portsrctemp[0])) {
|
||||
/* Already converted to new format */
|
||||
fputs(portsrctemp, portfw2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (portsrctemp[strlen(portsrctemp) - 1] == '\n')
|
||||
portsrctemp[strlen(portsrctemp) - 1] = '\0';
|
||||
portproto = strtok (portsrctemp, ",");
|
||||
portsrcport = strtok (NULL, ",");
|
||||
portdstip = strtok (NULL, ",");
|
||||
portdstport = strtok (NULL, ",");
|
||||
portenabled = strtok (NULL, ",");
|
||||
portsrcip = strtok (NULL, ",");
|
||||
portremip = strtok (NULL, ",");
|
||||
if (!(portproto && portsrcport && portdstip &&
|
||||
portdstport && portenabled ))
|
||||
continue;
|
||||
|
||||
if (portsrcip == NULL) portsrcip = strdup ("0.0.0.0");
|
||||
|
||||
while (fgets (xtsrctemp, STRING_SIZE, xtaccess1)) {
|
||||
xtproto = NULL;
|
||||
xtsrcip = NULL;
|
||||
xtdstip = NULL;
|
||||
xtdstport = NULL;
|
||||
xtenabled = NULL;
|
||||
|
||||
if (xtsrctemp[strlen(xtsrctemp) - 1] == '\n')
|
||||
xtsrctemp[strlen(xtsrctemp) - 1] = '\0';
|
||||
xtproto = strtok (xtsrctemp, ",");
|
||||
xtsrcip = strtok (NULL, ",");
|
||||
xtdstport = strtok (NULL, ",");
|
||||
xtenabled = strtok (NULL, ",");
|
||||
xtdstip = strtok (NULL, ",");
|
||||
if (!(xtproto && xtsrcip && xtdstport && xtenabled)) continue;
|
||||
|
||||
if (xtdstip == NULL) xtdstip = strdup ("0.0.0.0");
|
||||
|
||||
if (strcmp (portproto, xtproto) == 0 &&
|
||||
strcmp (portsrcport, xtdstport) == 0 &&
|
||||
strcmp (portsrcip, xtdstip) == 0) {
|
||||
portremip = strdup (xtsrcip);
|
||||
if ((strcmp (portremip, "0.0.0.0/0") == 0) && (count2 == 0)) {
|
||||
sprintf (portdsttemp, "%d,%d,%s,%s,%s,%s,%s,%s,%s\n",
|
||||
count, count2, portproto, portsrcport, portdstip,
|
||||
portdstport, portenabled, portsrcip, portremip);
|
||||
fputs(portdsttemp, portfw2);
|
||||
} else {
|
||||
if (count2 == 0) {
|
||||
sprintf (portdsttemp, "%d,%d,%s,%s,%s,%s,%s,%s,%d\n",
|
||||
count,count2,portproto, portsrcport, portdstip,
|
||||
portdstport, portenabled, portsrcip, 0);
|
||||
fputs(portdsttemp, portfw2);
|
||||
count2++;
|
||||
}
|
||||
sprintf (portdsttemp, "%d,%d,%s,%d,%s,%s,%s,%d,%s\n",
|
||||
count,count2,portproto, 0, portdstip,
|
||||
portdstport, portenabled, 0, portremip);
|
||||
fputs(portdsttemp, portfw2);
|
||||
}
|
||||
count2++;
|
||||
} else {
|
||||
sprintf (xtdsttemp, "%s,%s,%s,%s,%s\n",
|
||||
xtproto, xtsrcip, xtdstport, xtenabled, xtdstip);
|
||||
fputs(xtdsttemp, xtaccess2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Close source and destination xtaccess files */
|
||||
fclose (xtaccess1);
|
||||
fclose (xtaccess2);
|
||||
|
||||
/* Move the new xtaccess file */
|
||||
rename ("/harddisk/var/ipcop/xtaccess/config.new",
|
||||
"/harddisk/var/ipcop/xtaccess/config");
|
||||
|
||||
/* If no external access line existed, add a no access line */
|
||||
if (count2 == 0) {
|
||||
if (portremip == NULL) portremip = strdup ("127.0.0.1/32");
|
||||
|
||||
/* Print new port forwarding line to file */
|
||||
sprintf (portdsttemp, "%d,%d,%s,%s,%s,%s,%s,%s,%s\n",
|
||||
count, count2, portproto, portsrcport, portdstip,
|
||||
portdstport, portenabled, portsrcip, portremip);
|
||||
fputs(portdsttemp, portfw2);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
/* Close source and destination portfw files */
|
||||
fclose (portfw1);
|
||||
fclose (portfw2);
|
||||
|
||||
/* Move the new portfw file */
|
||||
rename ("/harddisk/var/ipcop/portfw/config.new",
|
||||
"/harddisk/var/ipcop/portfw/config");
|
||||
chown ("/harddisk/var/ipcop/xtaccess/config", 99, 99);
|
||||
chown ("/harddisk/var/ipcop/portfw/config", 99, 99);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _convert_pulsardsl() {
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char filename[STRING_SIZE];
|
||||
FILE *settings, *pulsardsl;
|
||||
char line[STRING_SIZE];
|
||||
|
||||
if (!(pulsardsl = fopen ("/harddisk/var/ipcop/pciadsl/settings", "r"))) return 1;
|
||||
|
||||
dirp = opendir( "/harddisk/var/ipcop/ppp" );
|
||||
while ( (dp = readdir( dirp )) != NULL ) {
|
||||
if ( strstr( dp->d_name, "settings" ) == dp->d_name ) {
|
||||
snprintf (filename, STRING_SIZE-1, "%s/%s",
|
||||
"/harddisk/var/ipcop/ppp", dp->d_name);
|
||||
if (!(settings = fopen (filename, "r+"))) {
|
||||
closedir(dirp);
|
||||
fclose(pulsardsl);
|
||||
return 1;
|
||||
}
|
||||
while (fgets (line, STRING_SIZE, settings) != NULL) {
|
||||
if (strstr (line, "TYPE=pulsardsl") == line) {
|
||||
fseek(settings,0,SEEK_END);
|
||||
rewind(pulsardsl);
|
||||
while (fgets(line, STRING_SIZE, pulsardsl) != NULL) {
|
||||
fputs (line, settings);
|
||||
}
|
||||
fclose (settings);
|
||||
chown (filename, 99, 99);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(pulsardsl);
|
||||
(void) closedir( dirp );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _convert_pulsardsl_ethernet() {
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
FILE *ethernet, *settings;
|
||||
char line[STRING_SIZE];
|
||||
char type[STRING_SIZE];
|
||||
char ip[STRING_SIZE];
|
||||
char filename[STRING_SIZE];
|
||||
|
||||
if (!(ethernet = fopen ("/harddisk/var/ipcop/ethernet/settings", "r"))) return 1;
|
||||
|
||||
while (fgets (line, STRING_SIZE, ethernet) != NULL) {
|
||||
if (strstr (line, "RED_DRIVER=pciadsl") == line) {
|
||||
rewind (ethernet);
|
||||
while (fgets (line, STRING_SIZE, ethernet) != NULL) {
|
||||
if (strstr (line, "RED_TYPE") == line) {
|
||||
strcpy (type, line + 9*sizeof(char));
|
||||
if (type[strlen(type) - 1] == '\n')
|
||||
type[strlen(type) - 1] = '\0';
|
||||
}
|
||||
if (strstr (line, "RED_ADDRESS") == line) {
|
||||
strcpy (ip, line + 12*sizeof(char));
|
||||
if (ip[strlen(ip) - 1] == '\n')
|
||||
type[strlen(ip) - 1] = '\0';
|
||||
}
|
||||
fclose (ethernet);
|
||||
|
||||
replace ("/harddisk/var/ipcop/ethernet/settings", "RED_DEV=eth1", "RED_DEV=");
|
||||
replace ("/harddisk/var/ipcop/ethernet/settings", "CONFIG_TYPE=2", "CONFIG_TYPE=0");
|
||||
replace ("/harddisk/var/ipcop/ethernet/settings", "CONFIG_TYPE=3", "CONFIG_TYPE=1");
|
||||
replace ("/harddisk/var/ipcop/ethernet/settings", "RED_DEV=eth2", "RED_DEV=");
|
||||
chown ("/harddisk/var/ipcop/ethernet/settings", 99, 99);
|
||||
|
||||
dirp = opendir( "/harddisk/var/ipcop/ppp" );
|
||||
while ( (dp = readdir( dirp )) != NULL ) {
|
||||
if ( strstr( dp->d_name, "settings-" ) == dp->d_name ) {
|
||||
snprintf (filename, STRING_SIZE-1, "%s/%s",
|
||||
"/harddisk/var/ipcop/ppp", dp->d_name);
|
||||
if (!(settings = fopen (filename, "r+")))
|
||||
{
|
||||
closedir(dirp);
|
||||
return 1;
|
||||
}
|
||||
while (fgets (line, STRING_SIZE, settings) != NULL) {
|
||||
if (strstr (line, "TYPE=pulsardsl") == line) {
|
||||
fseek(settings,0,SEEK_END);
|
||||
fprintf (settings, "METHOD=%s\n", type);
|
||||
fprintf (settings, "IP=%s\n", ip);
|
||||
fclose (settings);
|
||||
chown (filename, 99, 99);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(void) closedir( dirp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int upgrade_v12_v13() {
|
||||
struct stat s;
|
||||
replace ("/harddisk/var/ipcop/ethernet/settings", "rtl8139", "8139too");
|
||||
replace ("/harddisk/var/ipcop/vpn/ipsec.conf", "auto=add", "auto=start");
|
||||
chown ("/harddisk/var/ipcop/vpn/ipsec.conf", 99, 99);
|
||||
chown ("/harddisk/var/ipcop/ethernet/settings", 99, 99);
|
||||
chown ("/harddisk/var/ipcop/main/settings", 99, 99);
|
||||
_convert_ppp_settings();
|
||||
_convert_xtaccess();
|
||||
_convert_pulsardsl();
|
||||
_convert_pulsardsl_ethernet();
|
||||
|
||||
/* Rename usbadsl directory */
|
||||
stat ("/harddisk/var/ipcop/usbadsl", &s);
|
||||
if (S_ISDIR(s.st_mode)) {
|
||||
remove ("/harddisk/var/ipcop/usbadsl/settings");
|
||||
if (! system("/bin/chroot /harddisk /bin/rm -rf /var/ipcop/alcatelusb"))
|
||||
rename ("/harddisk/var/ipcop/usbadsl", "/harddisk/var/ipcop/alcatelusb");
|
||||
}
|
||||
|
||||
/* Rename pciadsl module and directory */
|
||||
remove ("/harddisk/var/ipcop/pulsar/settings");
|
||||
rename ("/harddisk/var/ipcop/pciadsl/pciadsl.o", "/harddisk/var/ipcop/pciadsl/pulsar.o");
|
||||
stat ("/harddisk/var/ipcop/pciadsl", &s);
|
||||
if (S_ISDIR(s.st_mode)) {
|
||||
if (! system("/bin/chroot /harddisk /bin/rm -rf /var/ipcop/pulsardsl"))
|
||||
rename ("/harddisk/var/ipcop/pciadsl", "/harddisk/var/ipcop/pulsardsl");
|
||||
}
|
||||
|
||||
/* Change squid cache directory */
|
||||
replace ("/harddisk/var/ipcop/proxy/squid.conf", "/var/spool/squid", "/var/log/cache");
|
||||
chown ("/harddisk/var/ipcop/proxy/squid.conf", 99, 99);
|
||||
|
||||
/* Change setup user shell */
|
||||
replace ("/harddisk/etc/passwd", ":/usr/local/sbin/setup", ":/bin/bash -c /usr/local/sbin/setup");
|
||||
|
||||
return 0;
|
||||
}
|
||||
577
src/install+setup/install/upgrade-v130-v140.c
Normal file
577
src/install+setup/install/upgrade-v130-v140.c
Normal file
@@ -0,0 +1,577 @@
|
||||
/*
|
||||
* This file is part of the IPCop Firewall.
|
||||
*
|
||||
* IPCop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* IPCop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with IPCop; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Copyright 2002: Mark Wormgoor <mark@wormgoor.com>
|
||||
*
|
||||
* $Id: upgrade-v130-v140.c,v 1.12.2.35 2004/11/11 09:40:03 alanh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
int _handledomainname(void)
|
||||
{
|
||||
char domainname[STRING_SIZE] = "localdomain";
|
||||
struct keyvalue *kv = initkeyvalues();
|
||||
char *values[] = { domainname, NULL }; /* pointers for the values. */
|
||||
struct newtWinEntry entries[] =
|
||||
{ { "", &values[0], 0,}, { NULL, NULL, 0 } };
|
||||
int rc;
|
||||
int result;
|
||||
|
||||
if (!(readkeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings")))
|
||||
{
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
findkey(kv, "DOMAINNAME", domainname);
|
||||
|
||||
/* already have a domainname */
|
||||
if (strlen(domainname))
|
||||
return 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
rc = newtWinEntries(ctr[TR_DOMAINNAME], ctr[TR_ENTER_DOMAINNAME],
|
||||
50, 5, 5, 40, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
|
||||
|
||||
if (rc == 1)
|
||||
{
|
||||
strcpy(domainname, values[0]);
|
||||
if (strchr(domainname, ' '))
|
||||
errorbox(ctr[TR_DOMAINNAME_CANNOT_CONTAIN_SPACES]);
|
||||
else
|
||||
{
|
||||
replacekeyvalue(kv, "DOMAINNAME", domainname);
|
||||
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(values[0]);
|
||||
freekeyvalues(kv);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int _add_logwatch_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel logwatch");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel logwatch");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 102 logwatch");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 102 -g logwatch -d /var/log/logwatch -s /bin/false logwatch");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _fixsquid() {
|
||||
FILE *squidreadfile;
|
||||
FILE *squidwritefile;
|
||||
FILE *aclreadfile;
|
||||
char hostname[STRING_SIZE] = "";
|
||||
char domainname[STRING_SIZE] = "";
|
||||
char squidtemp[STRING_SIZE];
|
||||
struct keyvalue *kv = initkeyvalues();
|
||||
int already_upgraded = 0;
|
||||
int updated = 0;
|
||||
|
||||
if (!(squidreadfile = fopen ("/harddisk" CONFIG_ROOT "/proxy/squid.conf", "r"))) return 1;
|
||||
if (!(squidwritefile = fopen ("/harddisk" CONFIG_ROOT "/proxy/squid.conf.new", "w")))
|
||||
{
|
||||
fclose(squidreadfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(readkeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings")))
|
||||
{
|
||||
fclose (squidwritefile);
|
||||
fclose (squidreadfile);
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
findkey(kv, "HOSTNAME", hostname);
|
||||
findkey(kv, "DOMAINNAME", domainname);
|
||||
freekeyvalues(kv);
|
||||
|
||||
while (fgets (squidtemp, STRING_SIZE, squidreadfile) != NULL) {
|
||||
/* this will fail if we've already been upgraded, which is ok */
|
||||
if (!strncmp(squidtemp, "reply_body_max_size 0 KB", 24)) {
|
||||
sprintf(squidtemp, "reply_body_max_size 0 allow all\n");
|
||||
}
|
||||
if (!strncmp(squidtemp, "cache_store_log /var/log/squid/store.log", 40)) {
|
||||
sprintf(squidtemp, "cache_store_log none\n");
|
||||
}
|
||||
fputs(squidtemp, squidwritefile);
|
||||
|
||||
/* so for us developers we skip already upgraded squiddies */
|
||||
if (!strncmp(squidtemp, "visible_hostname", 16)) {
|
||||
already_upgraded = 1;
|
||||
}
|
||||
|
||||
/* Check for the new acl's */
|
||||
if (!strncmp(squidtemp, "__GREEN_IP__", 12)) {
|
||||
updated = 1;
|
||||
}
|
||||
}
|
||||
if (!already_upgraded) {
|
||||
sprintf(squidtemp, "visible_hostname %s.%s\n", hostname, domainname);
|
||||
fputs(squidtemp, squidwritefile);
|
||||
}
|
||||
|
||||
fclose (squidwritefile);
|
||||
fclose (squidreadfile);
|
||||
|
||||
rename ("/harddisk" CONFIG_ROOT "/proxy/squid.conf.new",
|
||||
"/harddisk" CONFIG_ROOT "/proxy/squid.conf");
|
||||
|
||||
replace("/harddisk" CONFIG_ROOT "/proxy/squid.conf", "cache_dir ufs", "cache_dir aufs");
|
||||
|
||||
if (!updated) {
|
||||
rename ("/harddisk" CONFIG_ROOT "/proxy/acl",
|
||||
"/harddisk" CONFIG_ROOT "/proxy/acl.old");
|
||||
rename ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4",
|
||||
"/harddisk" CONFIG_ROOT "/proxy/acl");
|
||||
} else {
|
||||
if (!(aclreadfile = fopen ("/harddisk" CONFIG_ROOT "/proxy/acl", "r"))) {
|
||||
rename ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4",
|
||||
"/harddisk" CONFIG_ROOT "/proxy/acl");
|
||||
} else {
|
||||
unlink ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4");
|
||||
fclose(aclreadfile);
|
||||
}
|
||||
}
|
||||
|
||||
chown ("/harddisk" CONFIG_ROOT "/proxy/squid.conf", 99, 99);
|
||||
chown ("/harddisk" CONFIG_ROOT "/proxy/acl", 99, 99);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _fixeagleusb() {
|
||||
FILE *eaglereadfile;
|
||||
FILE *eaglewritefile;
|
||||
char eagletemp[STRING_SIZE];
|
||||
int already_upgraded = 0;
|
||||
|
||||
if (!(eaglereadfile = fopen ("/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf", "r"))) return 1;
|
||||
if (!(eaglewritefile = fopen ("/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf.new", "w")))
|
||||
{
|
||||
fclose(eaglereadfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (fgets (eagletemp, STRING_SIZE, eaglereadfile) != NULL) {
|
||||
/* so for us developers we skip already upgraded configs */
|
||||
if (!strncmp(eagletemp, "<eaglectrl>", 11)) {
|
||||
already_upgraded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
rewind(eaglereadfile);
|
||||
if (!already_upgraded)
|
||||
fprintf(eaglewritefile, "<eaglectrl>\n");
|
||||
while (fgets (eagletemp, STRING_SIZE, eaglereadfile) != NULL)
|
||||
fputs(eagletemp, eaglewritefile);
|
||||
if (!already_upgraded)
|
||||
fprintf(eaglewritefile, "</eaglectrl>\n");
|
||||
|
||||
fclose (eaglewritefile);
|
||||
fclose (eaglereadfile);
|
||||
|
||||
rename ("/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf.new",
|
||||
"/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf");
|
||||
|
||||
replace("/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf", "Linetype=00000001", "Linetype=0A");
|
||||
|
||||
chown ("/harddisk" CONFIG_ROOT "/eagle-usb/eagle-usb.conf", 99, 99);
|
||||
unlink("/harddisk" CONFIG_ROOT "/eagle-usb/dsp_code_pots.bin");
|
||||
unlink("/harddisk" CONFIG_ROOT "/eagle-usb/dsp_code_isdn.bin");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _fixdhcp_30() {
|
||||
FILE *dhcpreadfile;
|
||||
FILE *dhcpwritefile;
|
||||
char dhcptemp[STRING_SIZE];
|
||||
|
||||
if (!(dhcpreadfile = fopen ("/harddisk" CONFIG_ROOT "/dhcp/dhcpd.conf", "r"))) return 1;
|
||||
if (!(dhcpwritefile = fopen ("/harddisk" CONFIG_ROOT "/dhcp/dhcpd.conf.new", "w")))
|
||||
{
|
||||
fclose(dhcpreadfile);
|
||||
return 1;
|
||||
}
|
||||
fprintf (dhcpwritefile, "authoritative;\n");
|
||||
fprintf (dhcpwritefile, "deny bootp;\n");
|
||||
fprintf (dhcpwritefile, "ddns-update-style none;\n");
|
||||
while (fgets (dhcptemp, STRING_SIZE, dhcpreadfile) != NULL) {
|
||||
int write = 1;
|
||||
|
||||
/* so for us developers we skip already upgraded dhcp files */
|
||||
if (!strncmp(dhcptemp, "authoritative", 13)) {
|
||||
write = 0;
|
||||
}
|
||||
/* so for us developers we skip already upgraded dhcp files */
|
||||
if (!strncmp(dhcptemp, "ddns-update-style", 17)) {
|
||||
write = 0;
|
||||
}
|
||||
/* so for us developers we skip already upgraded dhcp files */
|
||||
if (!strncmp(dhcptemp, "deny bootp", 10)) {
|
||||
write = 0;
|
||||
}
|
||||
|
||||
if (write)
|
||||
fputs(dhcptemp, dhcpwritefile);
|
||||
}
|
||||
|
||||
fclose(dhcpreadfile);
|
||||
fclose(dhcpwritefile);
|
||||
|
||||
rename ("/harddisk" CONFIG_ROOT "/dhcp/dhcpd.conf.new",
|
||||
"/harddisk" CONFIG_ROOT "/dhcp/dhcpd.conf");
|
||||
chown ("/harddisk" CONFIG_ROOT "/dhcp/dhcpd.conf", 99, 99);
|
||||
|
||||
/* This one will get converted again furthur down */
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "WINS=", "WINS1=");
|
||||
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "START_ADDR=", "START_ADDR_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "END_ADDR=", "END_ADDR_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "DOMAIN_NAME=", "DOMAIN_NAME_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "DEFAULT_LEASE_TIME=", "DEFAULT_LEASE_TIME_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "MAX_LEASE_TIME=", "MAX_LEASE_TIME_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "DNS1=", "DNS1_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "DNS2=", "DNS2_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "WINS1=", "WINS1_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "WINS2=", "WINS2_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "ENABLE=", "ENABLE_GREEN=");
|
||||
replace("/harddisk" CONFIG_ROOT "/dhcp/settings", "range dynamic-bootp", "range");
|
||||
chown ("/harddisk" CONFIG_ROOT "/dhcp/settings", 99, 99);
|
||||
|
||||
if ((dhcpreadfile = fopen ("/harddisk" CONFIG_ROOT "/dhcp/enable", "r")))
|
||||
{
|
||||
fclose(dhcpreadfile);
|
||||
rename ("/harddisk" CONFIG_ROOT "/dhcp/enable",
|
||||
"/harddisk" CONFIG_ROOT "/dhcp/enable_green");
|
||||
chown ("/harddisk" CONFIG_ROOT "/dhcp/enable_green", 99, 99);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _add_sshd_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel sshd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel sshd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 74 sshd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 74 -g sshd -d /var/empty/sshd -s /bin/false -M sshd");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _add_dnsmasq_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel dnsmasq");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel dnsmasq");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 103 dnsmasq");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 103 -g dnsmasq -d / -s /bin/false -M dnsmasq");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _add_cron_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel cron");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel cron");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 104 cron");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 104 -g cron -d / -s /bin/false -M cron");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _add_sysklogd_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel syslogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel syslogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 105 syslogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 105 -g syslogd -d / -s /bin/false -M syslogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel klogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel klogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupadd -g 106 klogd");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/useradd -u 106 -g klogd -d / -s /bin/false -M klogd");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _del_setup_user() {
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel setup");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _create_nobody_dir(){
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/usermod -d /home/nobody nobody");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _del_useless_user_group()
|
||||
{
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel games");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel games");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel news");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel news");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel ftp");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel gopher");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel lp");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel uucp");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel adm");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel adm");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel operator");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel sync");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel shutdown");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/userdel halt");
|
||||
mysystem("/bin/chroot /harddisk /usr/sbin/groupdel man");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _del_pulsardsl_dir()
|
||||
{
|
||||
mysystem("/bin/chroot /harddisk /bin/rm -rf " CONFIG_ROOT "/pulsardsl");
|
||||
}
|
||||
|
||||
void _del_fritzdsl_dir()
|
||||
{
|
||||
mysystem("/bin/chroot /harddisk /bin/rm -rf " CONFIG_ROOT "/fritzdsl");
|
||||
}
|
||||
|
||||
int _convert_vpn() {
|
||||
int count=1;
|
||||
FILE *vpn1, *vpn2;
|
||||
char vpnip[STRING_SIZE] = "";
|
||||
char greennetaddr[STRING_SIZE] = "";
|
||||
struct keyvalue *kv = initkeyvalues();
|
||||
char vpnsrctemp[STRING_SIZE], vpndsttemp[STRING_SIZE];
|
||||
char *name, *left, *left_nexthop, *left_subnet, *right, *right_nexthop, *right_subnet, *secret, *enabled, *compression;
|
||||
|
||||
if (!(vpn1 = fopen ("/harddisk" CONFIG_ROOT "/vpn/config", "r"))) return 1;
|
||||
if (!(vpn2 = fopen ("/harddisk" CONFIG_ROOT "/vpn/config.new", "w")))
|
||||
{
|
||||
fclose(vpn1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(readkeyvalues(kv, "/harddisk" CONFIG_ROOT "/ethernet/settings")))
|
||||
{
|
||||
fclose (vpn1);
|
||||
fclose (vpn2);
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
findkey(kv, "GREEN_NETADDRESS", greennetaddr);
|
||||
freekeyvalues(kv);
|
||||
|
||||
kv = initkeyvalues();
|
||||
if (!(readkeyvalues(kv, "/harddisk" CONFIG_ROOT "/vpn/settings")))
|
||||
{
|
||||
fclose (vpn1);
|
||||
fclose (vpn2);
|
||||
freekeyvalues(kv);
|
||||
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if no VPN_IP is defined, we must turn it off to force the user
|
||||
* to enter a value once upgraded */
|
||||
findkey(kv, "VPN_IP", vpnip);
|
||||
if (strlen(vpnip) == 0) {
|
||||
replacekeyvalue(kv, "ENABLED", "off");
|
||||
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/vpn/settings");
|
||||
}
|
||||
freekeyvalues(kv);
|
||||
|
||||
while (fgets (vpnsrctemp, STRING_SIZE, vpn1) != NULL) {
|
||||
if (isdigit (vpnsrctemp[0])) {
|
||||
/* Already converted to new format */
|
||||
fputs(vpnsrctemp, vpn2);
|
||||
continue;
|
||||
}
|
||||
|
||||
name = NULL;
|
||||
left = NULL;
|
||||
left_nexthop = NULL;
|
||||
left_subnet = NULL;
|
||||
right = NULL;
|
||||
right_nexthop = NULL;
|
||||
right_subnet = NULL;
|
||||
secret = NULL;
|
||||
enabled = NULL;
|
||||
compression = NULL;
|
||||
|
||||
if (vpnsrctemp[strlen(vpnsrctemp) - 1] == '\n')
|
||||
vpnsrctemp[strlen(vpnsrctemp) - 1] = '\0';
|
||||
name = strtok (vpnsrctemp, ",");
|
||||
left = strtok (NULL, ",");
|
||||
left_nexthop = strtok (NULL, ",");
|
||||
left_subnet = strtok (NULL, ",");
|
||||
right = strtok (NULL, ",");
|
||||
right_nexthop = strtok (NULL, ",");
|
||||
right_subnet = strtok (NULL, ",");
|
||||
secret = strtok (NULL, ",");
|
||||
enabled = strtok (NULL, ",");
|
||||
compression = strtok (NULL, ",");
|
||||
if (!(name && left && left_subnet &&
|
||||
right && right_subnet &&
|
||||
secret && enabled && compression ))
|
||||
continue;
|
||||
|
||||
/* Try and guess what side IPCop is on; defaults to left */
|
||||
if (strstr(greennetaddr, right_subnet)) {
|
||||
sprintf (vpndsttemp, "%d,%s,%s,,net,psk,%s,right,,%s,,%s,%s,,%s,,,,,,,,,,,,,RED\n",
|
||||
count, enabled, name, secret, right_subnet,
|
||||
left, left_subnet, compression);
|
||||
} else {
|
||||
sprintf (vpndsttemp, "%d,%s,%s,,net,psk,%s,left,,%s,,%s,%s,,%s,,,,,,,,,,,,,RED\n",
|
||||
count, enabled, name, secret, left_subnet,
|
||||
right, right_subnet, compression);
|
||||
}
|
||||
fputs(vpndsttemp, vpn2);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
/* Close source and destination vpn files */
|
||||
fclose (vpn1);
|
||||
fclose (vpn2);
|
||||
|
||||
/* Move the new vpn file */
|
||||
rename ("/harddisk" CONFIG_ROOT "/vpn/config.new",
|
||||
"/harddisk" CONFIG_ROOT "/vpn/config");
|
||||
chown ("/harddisk" CONFIG_ROOT "/vpn/config", 99, 99);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _convert_ppp_settings_V140() {
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char filename[STRING_SIZE];
|
||||
|
||||
dirp = opendir( "/harddisk" CONFIG_ROOT "/ppp" );
|
||||
while ( (dp = readdir( dirp )) != NULL ) {
|
||||
if ( strstr( dp->d_name, "settings" ) == dp->d_name ) {
|
||||
snprintf (filename, STRING_SIZE-1, "%s/%s",
|
||||
"/harddisk" CONFIG_ROOT "/ppp", dp->d_name);
|
||||
replace (filename, "PERSISTENT=on", "RECONNECTION=persistent");
|
||||
replace (filename, "DIALONDEMAND=on", "RECONNECTION=dialondemand");
|
||||
replace (filename, "MODULATION=GDTM", "MODULATION=GDMT");
|
||||
chown (filename, 99, 99);
|
||||
}
|
||||
}
|
||||
(void) closedir( dirp );
|
||||
}
|
||||
|
||||
void _convert_net_settings_V140(){
|
||||
replace ("/harddisk" CONFIG_ROOT "/ethernet/settings", "eepro100", "e100");
|
||||
chown ("/harddisk" CONFIG_ROOT "/ethernet/settings", 99, 99);
|
||||
}
|
||||
|
||||
void _convert_keymap() {
|
||||
replace("/harddisk" CONFIG_ROOT "/main/settings", "KEYMAP=/lib/kbd", "KEYMAP=/usr/share/kbd");
|
||||
replace("/harddisk" CONFIG_ROOT "/main/settings", ".kmap.gz", ".map.gz");
|
||||
chown ("/harddisk" CONFIG_ROOT "/main/settings", 99, 99);
|
||||
}
|
||||
|
||||
void _convert_speedtouch() {
|
||||
FILE *speedtchbootfile;
|
||||
FILE *speedtchfirmfile;
|
||||
|
||||
if (( speedtchfirmfile = fopen ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v4.bin", "r")))
|
||||
{
|
||||
fclose (speedtchfirmfile);
|
||||
if ((speedtchbootfile = fopen ("/harddisk" CONFIG_ROOT "/alcatelusb/boot.v4.bin", "r"))) {
|
||||
fclose (speedtchbootfile);
|
||||
system("/bin/cat /harddisk" CONFIG_ROOT "/alcatelusb/boot.v4.bin "
|
||||
"/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v4.bin"
|
||||
"> /harddisk" CONFIG_ROOT "/alcatelusb/firmware.v4_b.bin");
|
||||
remove ("/harddisk" CONFIG_ROOT "/alcatelusb/boot.v4.bin");
|
||||
remove ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v4.bin");
|
||||
chown ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v4_b.bin", 99, 99);
|
||||
}
|
||||
}
|
||||
|
||||
if (( speedtchfirmfile = fopen ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v123.bin", "r"))) {
|
||||
fclose (speedtchfirmfile);
|
||||
system("/bin/cat /harddisk" CONFIG_ROOT "/alcatelusb/boot.v123.bin "
|
||||
"/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v123.bin"
|
||||
"> /harddisk" CONFIG_ROOT "/alcatelusb/firmware.v0123.bin");
|
||||
remove ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v123.bin");
|
||||
}
|
||||
|
||||
remove ("/harddisk" CONFIG_ROOT "/alcatelusb/boot.v123.bin");
|
||||
|
||||
rename ("/harddisk" CONFIG_ROOT "/alcatelusb/mgmt.o", "/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v0123.bin");
|
||||
chown ("/harddisk" CONFIG_ROOT "/alcatelusb/firmware.v0123.bin", 99, 99);
|
||||
}
|
||||
|
||||
void _convert_isapnp() {
|
||||
FILE *isapnpfile;
|
||||
|
||||
mkdir ("/harddisk" CONFIG_ROOT "/isapnp", S_IRWXU|S_IRWXG|S_IRWXO );
|
||||
if (( isapnpfile = fopen ("/harddisk/etc/isapnp.conf", "r"))) {
|
||||
fclose (isapnpfile);
|
||||
rename ("/harddisk/etc/isapnp.conf", "/harddisk" CONFIG_ROOT "/isapnp/isapnp.conf");
|
||||
} else {
|
||||
if (( isapnpfile = fopen ("/harddisk" CONFIG_ROOT "/isapnp/isapnp.conf", "r"))) {
|
||||
fclose(isapnpfile);
|
||||
} else {
|
||||
isapnpfile = fopen ("/harddisk" CONFIG_ROOT "/isapnp/isapnp.conf", "w");
|
||||
fclose(isapnpfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int upgrade_v130_v140() {
|
||||
_del_setup_user();
|
||||
_del_useless_user_group();
|
||||
_add_logwatch_user();
|
||||
_add_sshd_user();
|
||||
_add_dnsmasq_user();
|
||||
_add_cron_user();
|
||||
_add_sysklogd_user();
|
||||
_del_pulsardsl_dir();
|
||||
_del_fritzdsl_dir();
|
||||
_convert_vpn();
|
||||
_handledomainname();
|
||||
_fixsquid();
|
||||
_fixeagleusb();
|
||||
_create_nobody_dir();
|
||||
_convert_ppp_settings_V140();
|
||||
_convert_net_settings_V140();
|
||||
_fixdhcp_30();
|
||||
_convert_keymap();
|
||||
_convert_speedtouch();
|
||||
_convert_isapnp();
|
||||
|
||||
return 0;
|
||||
}
|
||||
141
src/install+setup/install/usb.c
Normal file
141
src/install+setup/install/usb.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of the IPCop Firewall.
|
||||
*
|
||||
* IPCop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* IPCop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with IPCop; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Copyright 2002: Mark Wormgoor <mark@wormgoor.com>
|
||||
*
|
||||
* $Id: usb.c,v 1.9.2.8 2005/12/10 00:18:23 franck78 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
|
||||
int usbuhci = 0;
|
||||
int usbohci = 0;
|
||||
int ehcihcd = 0;
|
||||
|
||||
int initialize_usb() {
|
||||
modprobe("sd_mod");
|
||||
modprobe("sr_mod");
|
||||
modprobe("usb-storage");
|
||||
|
||||
if (ehcihcd) {
|
||||
rmmod("ehci-hcd");
|
||||
ehcihcd = 0;
|
||||
}
|
||||
if (usbohci) {
|
||||
rmmod("usb-ohci");
|
||||
usbohci = 0;
|
||||
}
|
||||
if (usbuhci) {
|
||||
rmmod("usb-uhci");
|
||||
usbuhci = 0;
|
||||
}
|
||||
|
||||
if (modprobe("ehci-hcd") == 0) ehcihcd = 1;
|
||||
if (modprobe("usb-ohci") == 0) usbohci = 1;
|
||||
if (modprobe("usb-uhci") == 0) usbuhci = 1;
|
||||
|
||||
modprobe("hid");
|
||||
modprobe("keybdev");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_usb_modules_conf() {
|
||||
int index = 0;
|
||||
FILE *handle;
|
||||
|
||||
if (!(handle = fopen("/harddisk/etc/modules.conf", "a")))
|
||||
return 0;
|
||||
|
||||
#if 0 /* we don't do this yet, because one of the drivers has a problem
|
||||
* with it */
|
||||
if (ehcihcd) {
|
||||
fprintf(handle,"alias usb-controller");
|
||||
if (index)
|
||||
fprintf(handle,"%d",index);
|
||||
fprintf(handle," ehci-hcd\n");
|
||||
index++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (usbohci) {
|
||||
fprintf(handle,"alias usb-controller");
|
||||
if (index)
|
||||
fprintf(handle,"%d",index);
|
||||
fprintf(handle," usb-ohci\n");
|
||||
index++;
|
||||
}
|
||||
|
||||
if (usbuhci) {
|
||||
fprintf(handle,"alias usb-controller");
|
||||
if (index)
|
||||
fprintf(handle,"%d",index);
|
||||
fprintf(handle," usb-uhci\n");
|
||||
index++;
|
||||
}
|
||||
fclose(handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* checkusb().
|
||||
Scans the named partitions and returns true if USB-removable.
|
||||
a bug? in "cat /proc/partitions" with superfloppy scheme device
|
||||
make them appearing always with four 'false' partitions:
|
||||
sda and sda1 sda2 sda3 sda4.
|
||||
No easy way to decide if /dev/sda1 exists or not.
|
||||
*/
|
||||
int checkusb(char *partition)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
char filename[STRING_SIZE];
|
||||
char buffer[STRING_SIZE];
|
||||
char *pchar = &buffer[0];
|
||||
if (!(f = fopen("/proc/partitions", "r")))
|
||||
return 0;
|
||||
|
||||
short int major = 0, minor = 0;
|
||||
while (fgets(buffer, STRING_SIZE, f)) {
|
||||
/* look for partition*/
|
||||
if (strstr (buffer, partition)) {
|
||||
major = atoi (buffer);
|
||||
if (major != 8) break ; /* not scsi */
|
||||
//get minor
|
||||
while (*pchar != '8') pchar++;
|
||||
minor = atoi (++pchar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
if (major != 8) return 0; /* nothing found */
|
||||
|
||||
//now check for usb-storage-MINOR
|
||||
minor >>= 4; // get index from minor
|
||||
sprintf (filename, "/proc/scsi/usb-storage-%d/%d", minor,minor);
|
||||
|
||||
if (!(f = fopen(filename, "r")))
|
||||
return 0;
|
||||
int count = 0;
|
||||
while (fgets(buffer, STRING_SIZE, f)) {
|
||||
if (strstr(buffer,"usb-storage")) count++;
|
||||
if (strstr(buffer,"SCSI")) count++;
|
||||
if (strstr(buffer,"Attached: Yes")) count++;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
return (count==3 ? 1 : 0);
|
||||
}
|
||||
Reference in New Issue
Block a user