summaryrefslogtreecommitdiff
path: root/os_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'os_cmd')
-rw-r--r--os_cmd/.config1
-rw-r--r--os_cmd/FreeBSD/.config3
-rw-r--r--os_cmd/FreeBSD/ossdetect/ossdetect.c528
-rw-r--r--os_cmd/FreeBSD/ossdetect/ossdetect.man32
-rw-r--r--os_cmd/Linux/.config2
-rw-r--r--os_cmd/Linux/ossdetect/ossdetect.c695
-rw-r--r--os_cmd/Linux/ossdetect/ossdetect.man32
-rw-r--r--os_cmd/Linux/ossvermagic/ossvermagic.c325
-rw-r--r--os_cmd/SCO_SV/.config1
-rw-r--r--os_cmd/SCO_SV/ossdetect/.config2
-rw-r--r--os_cmd/SCO_SV/ossdetect/ossdetect.c497
-rw-r--r--os_cmd/SCO_SV/ossdetect/ossdetect.man32
-rw-r--r--os_cmd/SunOS/.config1
-rw-r--r--os_cmd/SunOS/ossdetect/.config3
-rw-r--r--os_cmd/SunOS/ossdetect/ossdetect.c799
-rw-r--r--os_cmd/SunOS/ossdetect/ossdetect.man23
16 files changed, 2976 insertions, 0 deletions
diff --git a/os_cmd/.config b/os_cmd/.config
new file mode 100644
index 0000000..1beec7c
--- /dev/null
+++ b/os_cmd/.config
@@ -0,0 +1 @@
+mode=user
diff --git a/os_cmd/FreeBSD/.config b/os_cmd/FreeBSD/.config
new file mode 100644
index 0000000..99cac14
--- /dev/null
+++ b/os_cmd/FreeBSD/.config
@@ -0,0 +1,3 @@
+targetos=FreeBSD
+mode=sbin
+cflags=-I/sys
diff --git a/os_cmd/FreeBSD/ossdetect/ossdetect.c b/os_cmd/FreeBSD/ossdetect/ossdetect.c
new file mode 100644
index 0000000..678244b
--- /dev/null
+++ b/os_cmd/FreeBSD/ossdetect/ossdetect.c
@@ -0,0 +1,528 @@
+/*
+ * Purpose: OSS device autodetection utility for FreeBSD
+ *
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2008.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution for the license terms and conditions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/pciio.h>
+#include <dev/pci/pcireg.h>
+
+#define PCI_PASS 0
+#define USB_PASS 1
+#define PSEUDO_PASS 2
+#define MAX_PASS 3
+
+#define OSSLIBDIRLEN 512
+static char *osslibdir = NULL;
+
+static int verbose = 0;
+
+typedef struct
+{
+ char *key, *driver, *name;
+ int is_3rdparty;
+ int detected;
+ int pass;
+} driver_def_t;
+
+typedef struct drv_slist
+{
+ const char * drv_name;
+ struct drv_slist * next;
+} drvlist_t;
+static drvlist_t * drvl = NULL;
+
+#define MAX_DRIVERS 1000
+static driver_def_t drivers[MAX_DRIVERS];
+static int ndrivers = 0;
+
+static int add_drv (const char *, int);
+static void create_devlinks (mode_t);
+#if 0
+static int remove_devlinks (const char *);
+#endif
+static drvlist_t * prepend_drvlist (const char *);
+static char * get_mapname (void);
+static void load_license (const char *);
+static void load_devlist (const char *, int);
+static void pci_detect (void);
+
+static char *
+get_mapname (void)
+{
+ FILE *f;
+ static char name[OSSLIBDIRLEN], tmp[OSSLIBDIRLEN+11];
+ struct stat st;
+
+ if ((f = fopen ("/etc/oss.conf", "r")) == NULL)
+ {
+ perror ("/etc/oss.conf");
+ goto oexit2;
+ }
+
+ while (fgets (tmp, sizeof (tmp), f) != NULL)
+ {
+ int l = strlen (tmp);
+ if (l > 0 && tmp[l - 1] == '\n')
+ tmp[l - 1] = '\0';
+
+ if (strncmp (tmp, "OSSLIBDIR=", 10) == 0)
+ {
+ l = snprintf (name, sizeof (name), "%s", &tmp[10]);
+ if ((l >= OSSLIBDIRLEN) || (l < 0))
+ {
+ fprintf (stderr, "String in /etc/oss.conf is too long!\n");
+ goto oexit;
+ }
+ if ((stat (name, &st) == -1) || !S_ISDIR(st.st_mode))
+ {
+ fprintf (stderr, "Directory %s from /etc/oss.conf cannot "
+ "be used!\n", name);
+ goto oexit;
+ }
+ fclose (f);
+ return name;
+ }
+ }
+
+ fprintf (stderr, "OSSLIBDIR not set in /etc/oss.conf, using default "
+ "/usr/lib/oss\n");
+oexit:
+ fclose (f);
+oexit2:
+ snprintf (name, sizeof (name), "/usr/lib/oss");
+ return name;
+}
+
+static void
+load_license (const char *fname)
+{
+ struct stat st;
+ char cmd[2*OSSLIBDIRLEN];
+ int n;
+
+ if (stat (fname, &st) == -1)
+ return; /* Doesn't exist */
+
+ if (stat ("/usr/sbin/osslic", &st) == -1)
+ return; /* No osslic utility in the system. No need to install license. */
+
+ n = snprintf (cmd, sizeof (cmd), "/usr/sbin/osslic -q %s/%s", osslibdir,
+ fname);
+ if (n >= sizeof (cmd) || n < 0) return;
+ if (((n = system (cmd)) == -1))
+ fprintf (stderr, "Cannot run osslic!\n");
+}
+
+static void
+load_devlist (const char *fname, int is_3rdparty)
+{
+ FILE *f;
+ char line[256], *p, rfname[2*OSSLIBDIRLEN];
+ char *driver, *key, *name;
+
+ snprintf (rfname, sizeof (rfname), "%s/%s", osslibdir, fname);
+
+ if ((f = fopen (rfname, "r")) == NULL)
+ {
+ perror (rfname);
+ exit (-1);
+ }
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ p = line;
+ while (*p)
+ {
+ if (*p == '#' || *p == '\n')
+ *p = 0;
+ p++;
+ }
+
+ /* Drivers with upper case names are unsupported ones */
+ if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
+ continue;
+
+ driver = line;
+ p = line;
+
+ while (*p && *p != '\t' && *p != ' ')
+ p++;
+ if (*p)
+ *p++ = 0;
+ key = p;
+
+ while (*p && *p != '\t')
+ p++;
+ if (*p)
+ *p++ = 0;
+ name = p;
+
+ if (verbose > 1)
+ printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
+
+ if (ndrivers >= MAX_DRIVERS)
+ {
+ printf ("Too many drivers defined in drivers.list\n");
+ exit (-1);
+ }
+
+ drivers[ndrivers].key = strdup (key);
+ drivers[ndrivers].driver = strdup (driver);
+ drivers[ndrivers].name = strdup (name);
+ drivers[ndrivers].is_3rdparty = is_3rdparty;
+ drivers[ndrivers].detected = 0;
+
+ ndrivers++;
+ }
+
+ fclose (f);
+}
+
+static int
+add_drv (const char * id, int pass)
+{
+ int i;
+
+ for (i = 0; i < ndrivers; i++)
+ {
+ if (strcmp (id, drivers[i].key) == 0)
+ {
+ if (verbose > 0)
+ printf ("Detected %s\n", drivers[i].name);
+ drivers[i].detected = 1;
+ drivers[i].pass = pass;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#if 0
+static int
+remove_devlinks (const char * dirname)
+{
+ char path[PATH_MAX];
+ DIR * dr;
+ struct dirent * de;
+ struct stat st;
+
+ if ((dr = opendir (dirname)) == NULL)
+ {
+ if (errno == ENONET) return 0;
+ perror ("opendir");
+ return -1;
+ }
+
+ while ((de = readdir (dr)) != NULL)
+ {
+ if ((!strcmp (de->d_name, ".")) || (!strcmp (de->d_name, ".."))) continue;
+
+ snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
+
+ if ((stat (path, &st) != -1) && (S_ISDIR (st.st_mode))) remove_devlinks (path);
+ else
+ {
+ if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
+ unlink (path);
+ }
+ }
+
+ closedir (dr);
+ if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
+ if (rmdir (dirname) == -1)
+ {
+ fprintf (stderr, "Couldn't remove %s\n", path);
+ return -1;
+ }
+ return 0;
+}
+#endif
+
+static void
+create_devlinks (mode_t node_m)
+{
+/* Doesn't work, since /proc isn't mounted by default on FreeBSD */
+ FILE *f;
+ char line[256], tmp[300], *p, *s;
+ mode_t perm;
+ int minor, major;
+
+ if ((f = fopen ("/proc/opensound/devfiles", "r")) == NULL)
+ {
+ perror ("/proc/opensound/devfiles");
+ fprintf (stderr, "Cannot connect to the OSS kernel module.\n");
+ fprintf (stderr, "Perhaps you need to execute 'soundon' to load OSS\n");
+ exit (-1);
+ }
+
+/* remove_devlinks("/dev/oss"); */
+ perm = umask (0);
+ mkdir ("/dev/oss", 0755);
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ char dev[64] = "/dev/";
+
+ s = strchr (line, '\n');
+ if (s) *s = '\0';
+
+ if (sscanf (line, "%s %d %d", dev + 5, &major, &minor) != 3)
+ {
+ fprintf (stderr, "Syntax error in /proc/opensound/devfiles\n");
+ fprintf (stderr, "%s\n", line);
+ exit (-1);
+ }
+
+/*
+ * Check if the device is located in a subdirectory (say /dev/oss/sblive0/pcm0).
+ */
+ strcpy (tmp, dev);
+
+ s = tmp + 5;
+ p = s;
+ while (*s)
+ {
+ if (*s == '/')
+ p = s;
+ s++;
+ }
+
+ if (*p == '/')
+ {
+ *p = 0; /* Extract the directory name part */
+ mkdir (tmp, 0755);
+ }
+
+ unlink (dev);
+ if (verbose)
+ printf ("mknod %s c %d %d -m %o\n", dev, major, minor, node_m);
+ if (mknod (dev, node_m, makedev (major, minor)) == -1)
+ perror (dev);
+ }
+
+ umask (perm);
+ fclose (f);
+}
+
+static void
+pci_detect (void)
+{
+ int fd;
+ struct pci_conf_io pc;
+ struct pci_conf conf[255], *p;
+
+ if ((fd = open ("/dev/pci", O_RDONLY, 0)) == -1)
+ {
+ perror ("/dev/pci");
+ exit (-1);
+ }
+
+ bzero (&pc, sizeof (struct pci_conf_io));
+ pc.match_buf_len = sizeof (conf);
+ pc.matches = conf;
+
+ do
+ {
+ if (ioctl (fd, PCIOCGETCONF, &pc) == -1)
+ {
+ perror ("ioctl(PCIOCGETCONF)");
+ exit (1);
+ }
+
+ /*
+ * 255 entries should be more than enough for most people,
+ * but if someone has more devices, and then changes things
+ * around between ioctls, we'll do the cheezy thing and
+ * just bail. The alternative would be to go back to the
+ * beginning of the list, and print things twice, which may
+ * not be desireable.
+ */
+ if (pc.status == PCI_GETCONF_LIST_CHANGED)
+ {
+ fprintf (stderr, "PCI device list changed, please try again");
+ exit (1);
+ close (fd);
+ return;
+ }
+ else if (pc.status == PCI_GETCONF_ERROR)
+ {
+ fprintf (stderr, "error returned from PCIOCGETCONF ioctl");
+ exit (1);
+ close (fd);
+ return;
+ }
+ for (p = conf; p < &conf[pc.num_matches]; p++)
+ {
+
+ char name[32];
+
+ if (verbose > 2)
+ printf ("%s%d@pci%d:%d:%d:\tclass=0x%06x card=0x%08x "
+ "chip=0x%08x rev=0x%02x hdr=0x%02x\n",
+ (p->pd_name && *p->pd_name) ? p->pd_name :
+ "none",
+ (p->pd_name && *p->pd_name) ? (int) p->pd_unit :
+ p->pc_sel.pc_bus, p->pc_sel.pc_dev,
+ p->pc_sel.pc_func, (p->pc_class << 16) |
+ (p->pc_subclass << 8) | p->pc_progif,
+ (p->pc_subdevice << 16) | p->pc_subvendor,
+ (p->pc_device << 16) | p->pc_vendor,
+ p->pc_revid, p->pc_hdr);
+
+ sprintf (name, "pcs%x,%x", p->pc_subvendor, p->pc_subdevice);
+ if (add_drv (name, PCI_PASS))
+ continue;
+
+ sprintf (name, "pci%x,%x", p->pc_vendor, p->pc_device);
+ if (add_drv (name, PCI_PASS))
+ continue;
+ }
+ }
+ while (pc.status == PCI_GETCONF_MORE_DEVS);
+
+ close (fd);
+}
+
+static drvlist_t *
+prepend_drvlist (const char * name)
+{
+ drvlist_t * dp;
+
+ dp = malloc (sizeof (drvlist_t));
+ if (dp == NULL)
+ {
+ fprintf (stderr, "Can't allocate memory!\n");
+ exit (-1);
+ }
+
+ dp->drv_name = name;
+ dp->next = drvl;
+ return dp;
+}
+
+int
+main (int argc, char *argv[])
+{
+ char instfname[2*OSSLIBDIRLEN], *p;
+ int i, do_license = 0, make_devs = 0, pass;
+ mode_t node_m = S_IFCHR | 0666;
+ struct stat st;
+ FILE *f;
+
+ while ((i = getopt(argc, argv, "L:a:dilm:uv")) != EOF)
+ switch (i)
+ {
+ case 'v':
+ verbose++;
+ break;
+
+ case 'd':
+ make_devs = 1;
+ break;
+
+ case 'i':
+ drvl = prepend_drvlist ("oss_imux");
+ break;
+
+ case 'u':
+ drvl = prepend_drvlist ("oss_userdev");
+ break;
+
+ case 'a':
+ drvl = prepend_drvlist (optarg);
+ break;
+
+ case 'l':
+ do_license = 1;
+ break;
+
+ case 'L':
+ osslibdir = optarg;
+ break;
+
+ case 'm':
+ p = optarg;
+ node_m = 0;
+ while ((*p >= '0') && (*p <= '7')) node_m = node_m * 8 + *p++ - '0';
+ if ((*p) || (node_m & ~(S_IRWXU|S_IRWXG|S_IRWXO)))
+ {
+ fprintf (stderr, "Invalid permissions: %s\n", optarg);
+ exit(1);
+ }
+ node_m |= S_IFCHR;
+ break;
+
+ default:
+ fprintf (stderr, "%s: bad usage\n", argv[0]);
+ exit (-1);
+ }
+
+ if (osslibdir == NULL) osslibdir = get_mapname ();
+
+ if (make_devs == 1)
+ {
+ create_devlinks (node_m);
+ exit (0);
+ }
+
+ if (do_license == 1)
+ {
+ load_license ("etc/license.asc");
+ exit (0);
+ }
+
+ load_devlist ("etc/devices.list", 0);
+
+ if (stat ("/etc/oss_3rdparty", &st) != -1)
+ load_devlist ("/etc/oss_3rdparty", 1);
+
+ pci_detect ();
+
+ while (drvl != NULL)
+ {
+ drvlist_t * d = drvl;
+ add_drv (drvl->drv_name, PSEUDO_PASS);
+ drvl = drvl->next;
+ free (d);
+ }
+
+ snprintf (instfname, sizeof (instfname), "%s/%s", osslibdir,
+ "etc/installed_drivers");
+
+ if ((f = fopen (instfname, "w")) == NULL)
+ {
+ perror (instfname);
+ exit (-1);
+ }
+
+ for (pass = 0; pass < MAX_PASS; pass++)
+ for (i = 0; i < ndrivers; i++)
+ if (drivers[i].pass == pass && drivers[i].detected)
+ {
+ fprintf (f, "%s #%s\n", drivers[i].driver, drivers[i].name);
+ }
+
+ fclose (f);
+
+ exit (0);
+}
diff --git a/os_cmd/FreeBSD/ossdetect/ossdetect.man b/os_cmd/FreeBSD/ossdetect/ossdetect.man
new file mode 100644
index 0000000..a05cca5
--- /dev/null
+++ b/os_cmd/FreeBSD/ossdetect/ossdetect.man
@@ -0,0 +1,32 @@
+NAME
+ossdetect - Open Sound System audio device detection program.
+
+SYNOPSIS
+ossdetect [-diuv] [-m<mode>] [-L<path>]
+
+DESCRIPTION
+The ossdetect application performs automatic detection of soundcards.
+The application looks at the /usr/lib/oss/etc/device.list and performs
+automatic detection. It will create a file with the list of the configured
+drivers in /usr/lib/oss/etc/installed_drivers.
+
+The Input Multiplexer driver (IMUX) is not configured by default and
+can be added to the OSS configuration using the -i option.
+
+OPTIONS
+-d Create device file links.
+-i Adds the oss_imux driver.
+-m<mode> Create nodes with permissions set to octal <mode>.
+-u Adds the oss_userdev driver.
+-v Verbose output.
+-L<path> Use <path> as root directory for OSS files.
+ Default: Path from /etc/oss.conf, followed by /usr/lib/oss.
+
+SEE ALSO
+ossdevlinks(1), ossinfo(1)
+
+FILES
+/usr/sbin/ossdetect
+
+AUTHOR
+4Front Technologies
diff --git a/os_cmd/Linux/.config b/os_cmd/Linux/.config
new file mode 100644
index 0000000..05895d6
--- /dev/null
+++ b/os_cmd/Linux/.config
@@ -0,0 +1,2 @@
+targetos=Linux
+mode=sbin
diff --git a/os_cmd/Linux/ossdetect/ossdetect.c b/os_cmd/Linux/ossdetect/ossdetect.c
new file mode 100644
index 0000000..43a7c10
--- /dev/null
+++ b/os_cmd/Linux/ossdetect/ossdetect.c
@@ -0,0 +1,695 @@
+/*
+ * Purpose: OSS device autodetection utility for Linux
+ *
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2008.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution for the license terms and conditions.
+ *
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+
+#define PCI_PASS 0
+#define USB_PASS 1
+#define PSEUDO_PASS 2
+#define MAX_PASS 3
+
+#define OSSLIBDIRLEN 512
+static char *osslibdir = NULL;
+
+static int usb_ok = 0;
+
+static int verbose = 0;
+
+typedef struct
+{
+ char *key, *driver, *name;
+ int is_3rdparty;
+ int detected;
+ int pass;
+} driver_def_t;
+
+typedef struct drv_slist
+{
+ const char * drv_name;
+ struct drv_slist * next;
+} drvlist_t;
+static drvlist_t * drvl = NULL;
+
+#define MAX_DRIVERS 1000
+static driver_def_t drivers[MAX_DRIVERS];
+static int ndrivers = 0;
+
+static int add_drv (const char *, int);
+static int decode_descriptor (unsigned char *, int);
+static void create_devlinks (mode_t);
+static char * get_mapname (void);
+static unsigned short get_uint16 (unsigned char *);
+static int is_audio (unsigned char *, int);
+static void load_license (const char *);
+static void load_devlist (const char *, int);
+static void pci_checkdevice (char *);
+static void pci_detect (char *);
+static drvlist_t * prepend_drvlist (const char *);
+static int remove_devlinks (const char *);
+static void usb_checkdevice (char *);
+static void usb_scandir (char *);
+static void usb_detect (void);
+
+static char *
+get_mapname (void)
+{
+ FILE *f;
+ static char name[OSSLIBDIRLEN], tmp[OSSLIBDIRLEN+11];
+ struct stat st;
+
+ if ((f = fopen ("/etc/oss.conf", "r")) == NULL)
+ {
+ perror ("/etc/oss.conf");
+ goto oexit2;
+ }
+
+ while (fgets (tmp, sizeof (tmp), f) != NULL)
+ {
+ int l = strlen (tmp);
+ if (l > 0 && tmp[l - 1] == '\n')
+ tmp[l - 1] = '\0';
+
+ if (strncmp (tmp, "OSSLIBDIR=", 10) == 0)
+ {
+ l = snprintf (name, sizeof (name), "%s", &tmp[10]);
+ if ((l >= OSSLIBDIRLEN) || (l < 0))
+ {
+ fprintf (stderr, "String in /etc/oss.conf is too long!\n");
+ goto oexit;
+ }
+ if ((stat (name, &st) == -1) || !S_ISDIR(st.st_mode))
+ {
+ fprintf (stderr, "Directory %s from /etc/oss.conf cannot "
+ "be used!\n", name);
+ goto oexit;
+ }
+ fclose (f);
+ return name;
+ }
+ }
+
+ fprintf (stderr, "OSSLIBDIR not set in /etc/oss.conf, using default "
+ "/usr/lib/oss\n");
+oexit:
+ fclose (f);
+oexit2:
+ snprintf (name, sizeof (name), "/usr/lib/oss");
+ return name;
+}
+
+static void
+load_license (const char *fname)
+{
+ struct stat st;
+ char cmd[2*OSSLIBDIRLEN];
+ int n;
+
+ if (stat (fname, &st) == -1)
+ return; /* Doesn't exist */
+
+ if (stat ("/usr/sbin/osslic", &st) == -1)
+ return; /* No osslic utility in the system. No need to install license. */
+
+ n = snprintf (cmd, sizeof (cmd), "/usr/sbin/osslic -q %s/%s", osslibdir,
+ fname);
+ if (n >= sizeof (cmd) || n < 0) return;
+ if (((n = system (cmd)) == -1))
+ fprintf (stderr, "Cannot run osslic!\n");
+}
+
+static void
+load_devlist (const char *fname, int is_3rdparty)
+{
+ FILE *f;
+ char line[256], *p, rfname[2*OSSLIBDIRLEN];
+ char *driver, *key, *name;
+
+ snprintf (rfname, sizeof (rfname), "%s/%s", osslibdir, fname);
+
+ if ((f = fopen (rfname, "r")) == NULL)
+ {
+ perror (rfname);
+ exit (-1);
+ }
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ p = line;
+ while (*p)
+ {
+ if (*p == '#' || *p == '\n')
+ *p = '\0';
+ p++;
+ }
+
+ /* Drivers with upper case names are unsupported ones */
+ if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
+ continue;
+
+ driver = line;
+ p = line;
+
+ while (*p && *p != '\t' && *p != ' ')
+ p++;
+ if (*p)
+ *p++ = 0;
+ key = p;
+
+ while (*p && *p != '\t')
+ p++;
+ if (*p)
+ *p++ = 0;
+ name = p;
+
+ if (verbose > 1)
+ printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
+
+ if (ndrivers >= MAX_DRIVERS)
+ {
+ printf ("Too many drivers defined in drivers.list\n");
+ exit (-1);
+ }
+
+ drivers[ndrivers].key = strdup (key);
+ drivers[ndrivers].driver = strdup (driver);
+ drivers[ndrivers].name = strdup (name);
+ drivers[ndrivers].is_3rdparty = is_3rdparty;
+ drivers[ndrivers].detected = 0;
+
+ ndrivers++;
+ }
+
+ fclose (f);
+}
+
+static int
+add_drv (const char * id, int pass)
+{
+ int i;
+
+ for (i = 0; i < ndrivers; i++)
+ {
+ if (strcmp (id, drivers[i].key) == 0)
+ {
+ if (verbose > 0)
+ printf ("Detected %s\n", drivers[i].name);
+ drivers[i].detected = 1;
+ drivers[i].pass = pass;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static unsigned short
+get_uint16 (unsigned char *p)
+{
+ return *p + (p[1] << 8);
+}
+
+static int
+decode_descriptor (unsigned char *d, int desclen)
+{
+ switch (d[1])
+ {
+ case 0x04:
+ if (d[5] == 1) // Audio
+ return 1;
+ break;
+ }
+
+ return 0;
+}
+
+static int
+is_audio (unsigned char *desc, int datalen)
+{
+ int l, pos, desclen;
+
+ if (desc[0] == 9 && desc[1] == 2) /* Config descriptor */
+ {
+ l = get_uint16 (desc + 2);
+
+ if (datalen > l)
+ datalen = l;
+ }
+
+ pos = 0;
+
+ while (pos < datalen)
+ {
+ unsigned char *d;
+ desclen = desc[pos];
+
+ if (desclen < 2 || desclen > (datalen - pos))
+ {
+ return 0;
+ }
+
+ d = &desc[pos];
+ if (decode_descriptor (d, desclen))
+ return 1;
+ pos += desclen;
+ }
+
+ return 0;
+}
+
+static void
+usb_checkdevice (char *fname)
+{
+ int fd, l;
+ unsigned char buf[4096];
+ char tmp[64];
+ int vendor, device;
+
+ if ((fd = open (fname, O_RDONLY, 0)) == -1)
+ {
+ perror (fname);
+ return;
+ }
+
+ if ((l = read (fd, buf, sizeof (buf))) == -1)
+ {
+ perror (fname);
+ return;
+ }
+
+ close (fd);
+
+ if (l < 12 || buf[1] != 1)
+ return;
+
+ vendor = buf[8] | (buf[9] << 8);
+ device = buf[10] | (buf[11] << 8);
+
+ sprintf (tmp, "usb%x,%x", vendor, device);
+ if (add_drv (tmp, USB_PASS))
+ return;
+
+ sprintf (tmp, "usbif%x,%x", vendor, device);
+ if (add_drv (tmp, USB_PASS))
+ return;
+
+ if (is_audio (buf, l)) /* USB audio class */
+ {
+ if (add_drv ("usbif,class1", USB_PASS))
+ return;
+ }
+}
+
+static void
+usb_scandir (char *dirname)
+{
+ char path[PATH_MAX];
+ DIR *dr;
+ struct dirent *de;
+ struct stat st;
+
+ if ((dr = opendir (dirname)) == NULL)
+ {
+ return;
+ }
+
+ while ((de = readdir (dr)) != NULL)
+ {
+ if (de->d_name[0] < '0' || de->d_name[0] > '9') /* Ignore non-numeric names */
+ continue;
+
+ snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
+
+ if (stat (path, &st) == -1)
+ continue;
+
+ if (S_ISDIR (st.st_mode))
+ {
+ usb_scandir (path);
+ continue;
+ }
+
+ usb_checkdevice (path);
+ }
+
+ closedir (dr);
+}
+
+static void
+usb_detect (void)
+{
+ struct stat st;
+#if 0
+ char path[OSSLIBDIRLEN + 25];
+
+ sprintf (path, "%s/modules/oss_usb.o", osslibdir);
+
+ if (stat (path, &st) == -1) /* USB module not available */
+ {
+ fprintf (stderr, "USB module not available, aborting USB detect\n");
+ return;
+ }
+#endif
+
+ if (stat ("/dev/bus/usb", &st) != -1)
+ {
+ usb_ok = 1;
+ usb_scandir ("/dev/bus/usb");
+ }
+ else if (stat ("/proc/bus/usb", &st) != -1)
+ {
+ usb_ok = 1;
+ usb_scandir ("/proc/bus/usb");
+ }
+}
+
+static void
+pci_checkdevice (char *path)
+{
+ unsigned char buf[256];
+ char id[32];
+ int fd;
+ int vendor, device;
+ int subvendor, subdevice;
+
+ if ((fd = open (path, O_RDONLY, 0)) == -1)
+ {
+ perror (path);
+ return;
+ }
+
+ if (read (fd, buf, sizeof (buf)) != sizeof (buf))
+ {
+ perror (path);
+ close (fd);
+ return;
+ }
+ close (fd);
+ vendor = buf[0] | (buf[1] << 8);
+ device = buf[2] | (buf[3] << 8);
+ subvendor = buf[0x2c] | (buf[0x2d] << 8);
+ subdevice = buf[0x2e] | (buf[0x2f] << 8);
+ sprintf (id, "pcs%x,%x", subvendor, subdevice);
+ if (add_drv (id, PCI_PASS))
+ return;
+ sprintf (id, "pci%x,%x", vendor, device);
+ add_drv (id, PCI_PASS);
+}
+
+static void
+pci_detect (char *dirname)
+{
+ char path[PATH_MAX];
+ DIR *dr;
+ struct dirent *de;
+ struct stat st;
+
+ if (dirname == NULL)
+ {
+ dirname = "/proc/bus/pci";
+ }
+
+ if ((dr = opendir (dirname)) == NULL)
+ {
+ return;
+ }
+
+ while ((de = readdir (dr)) != NULL)
+ {
+ if (de->d_name[0] < '0' || de->d_name[0] > '9') /* Ignore non-numeric names */
+ continue;
+
+ snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
+
+ if (stat (path, &st) == -1)
+ continue;
+
+ if (S_ISDIR (st.st_mode))
+ {
+ pci_detect (path);
+ continue;
+ }
+
+ pci_checkdevice (path);
+ }
+
+ closedir (dr);
+}
+
+static int
+remove_devlinks (const char * dirname)
+{
+ char path[PATH_MAX];
+ DIR * dr;
+ struct dirent * de;
+ struct stat st;
+
+ if ((dr = opendir (dirname)) == NULL)
+ {
+ if (errno == ENONET) return 0;
+ perror ("opendir");
+ return -1;
+ }
+
+ while ((de = readdir (dr)) != NULL)
+ {
+ if ((!strcmp (de->d_name, ".")) || (!strcmp (de->d_name, ".."))) continue;
+
+ snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
+
+ if ((stat (path, &st) != -1) && (S_ISDIR (st.st_mode))) remove_devlinks (path);
+ else
+ {
+ if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
+ unlink (path);
+ }
+ }
+
+ closedir (dr);
+ if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
+ if (rmdir (dirname) == -1)
+ {
+ fprintf (stderr, "Couldn't remove %s\n", path);
+ return -1;
+ }
+ return 0;
+}
+
+static void
+create_devlinks (mode_t node_m)
+{
+ FILE *f;
+ char line[256], tmp[300], *p, *s;
+ mode_t perm;
+ int minor, major;
+
+ if ((f = fopen ("/proc/opensound/devfiles", "r")) == NULL)
+ {
+ perror ("/proc/opensound/devfiles");
+ fprintf (stderr, "Cannot connect to the OSS kernel module.\n");
+ fprintf (stderr, "Perhaps you need to execute 'soundon' to load OSS\n");
+ exit (-1);
+ }
+
+ remove_devlinks ("/dev/oss");
+ perm = umask (0);
+ mkdir ("/dev/oss", 0755);
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ char dev[64] = "/dev/";
+
+ s = strchr (line, '\n');
+ if (s) *s = '\0';
+
+ if (sscanf (line, "%s %d %d", dev + 5, &major, &minor) != 3)
+ {
+ fprintf (stderr, "Syntax error in /proc/opensound/devfiles\n");
+ fprintf (stderr, "%s\n", line);
+ exit (-1);
+ }
+
+/*
+ * Check if the device is located in a subdirectory (say /dev/oss/sblive0/pcm0).
+ */
+ strcpy (tmp, dev);
+
+ s = tmp + 5;
+ p = s;
+ while (*s)
+ {
+ if (*s == '/')
+ p = s;
+ s++;
+ }
+
+ if (*p == '/')
+ {
+ *p = 0; /* Extract the directory name part */
+ mkdir (tmp, 0755);
+ }
+
+ unlink (dev);
+ if (verbose)
+ printf ("mknod %s c %d %d -m %o\n", dev, major, minor, node_m);
+ if (mknod (dev, node_m, makedev (major, minor)) == -1)
+ perror (dev);
+ }
+
+ umask (perm);
+ fclose (f);
+}
+
+static drvlist_t *
+prepend_drvlist (const char * name)
+{
+ drvlist_t * dp;
+
+ dp = malloc (sizeof (drvlist_t));
+ if (dp == NULL)
+ {
+ fprintf (stderr, "Can't allocate memory!\n");
+ exit (-1);
+ }
+
+ dp->drv_name = name;
+ dp->next = drvl;
+ return dp;
+}
+
+int
+main (int argc, char *argv[])
+{
+ char instfname[2*OSSLIBDIRLEN], *p;
+ int i, do_license = 0, make_devs = 0, pass;
+ mode_t node_m = S_IFCHR | 0666;
+ struct stat st;
+ FILE *f;
+
+ while ((i = getopt(argc, argv, "L:a:dilm:uv")) != EOF)
+ switch (i)
+ {
+ case 'v':
+ verbose++;
+ break;
+
+ case 'd':
+ make_devs = 1;
+ break;
+
+ case 'i':
+ drvl = prepend_drvlist ("oss_imux");
+ break;
+
+ case 'u':
+ drvl = prepend_drvlist ("oss_userdev");
+ break;
+
+ case 'a':
+ drvl = prepend_drvlist (optarg);
+ break;
+
+ case 'l':
+ do_license = 1;
+ break;
+
+ case 'L':
+ osslibdir = optarg;
+ break;
+
+ case 'm':
+ p = optarg;
+ node_m = 0;
+ while ((*p >= '0') && (*p <= '7')) node_m = node_m * 8 + *p++ - '0';
+ if ((*p) || (node_m & ~(S_IRWXU|S_IRWXG|S_IRWXO)))
+ {
+ fprintf (stderr, "Invalid permissions: %s\n", optarg);
+ exit(1);
+ }
+ node_m |= S_IFCHR;
+ break;
+
+ default:
+ fprintf (stderr, "%s: bad usage\n", argv[0]);
+ exit (-1);
+ }
+
+ if (osslibdir == NULL) osslibdir = get_mapname ();
+
+ if (make_devs == 1)
+ {
+ create_devlinks (node_m);
+ exit (0);
+ }
+
+ if (do_license == 1)
+ {
+ load_license ("etc/license.asc");
+ exit (0);
+ }
+
+ load_devlist ("etc/devices.list", 0);
+
+ if (stat ("/etc/oss_3rdparty", &st) != -1)
+ load_devlist ("/etc/oss_3rdparty", 1);
+
+ pci_detect (NULL);
+ usb_detect ();
+
+ if (usb_ok)
+ {
+ if (verbose)
+ printf ("USB support available in the system, adding USB driver\n");
+ add_drv ("usbif,class1", USB_PASS);
+ }
+ else if (verbose)
+ printf ("No USB support detected in the system - skipping USB\n");
+
+ while (drvl != NULL)
+ {
+ drvlist_t * d = drvl;
+ add_drv (drvl->drv_name, PSEUDO_PASS);
+ drvl = drvl->next;
+ free (d);
+ }
+
+ snprintf (instfname, sizeof (instfname), "%s/%s", osslibdir,
+ "etc/installed_drivers");
+
+ if ((f = fopen (instfname, "w")) == NULL)
+ {
+ perror (instfname);
+ exit (-1);
+ }
+
+ for (pass = 0; pass < MAX_PASS; pass++)
+ for (i = 0; i < ndrivers; i++)
+ if (drivers[i].pass == pass && drivers[i].detected)
+ {
+ fprintf (f, "%s #%s\n", drivers[i].driver, drivers[i].name);
+ }
+
+ fclose (f);
+
+ exit (0);
+}
diff --git a/os_cmd/Linux/ossdetect/ossdetect.man b/os_cmd/Linux/ossdetect/ossdetect.man
new file mode 100644
index 0000000..a05cca5
--- /dev/null
+++ b/os_cmd/Linux/ossdetect/ossdetect.man
@@ -0,0 +1,32 @@
+NAME
+ossdetect - Open Sound System audio device detection program.
+
+SYNOPSIS
+ossdetect [-diuv] [-m<mode>] [-L<path>]
+
+DESCRIPTION
+The ossdetect application performs automatic detection of soundcards.
+The application looks at the /usr/lib/oss/etc/device.list and performs
+automatic detection. It will create a file with the list of the configured
+drivers in /usr/lib/oss/etc/installed_drivers.
+
+The Input Multiplexer driver (IMUX) is not configured by default and
+can be added to the OSS configuration using the -i option.
+
+OPTIONS
+-d Create device file links.
+-i Adds the oss_imux driver.
+-m<mode> Create nodes with permissions set to octal <mode>.
+-u Adds the oss_userdev driver.
+-v Verbose output.
+-L<path> Use <path> as root directory for OSS files.
+ Default: Path from /etc/oss.conf, followed by /usr/lib/oss.
+
+SEE ALSO
+ossdevlinks(1), ossinfo(1)
+
+FILES
+/usr/sbin/ossdetect
+
+AUTHOR
+4Front Technologies
diff --git a/os_cmd/Linux/ossvermagic/ossvermagic.c b/os_cmd/Linux/ossvermagic/ossvermagic.c
new file mode 100644
index 0000000..7af4666
--- /dev/null
+++ b/os_cmd/Linux/ossvermagic/ossvermagic.c
@@ -0,0 +1,325 @@
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2008.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution for the license terms and conditions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+#include <elf.h>
+#define CONFIGURE_C
+#include "oss_config.h"
+
+int elf_verbose = 0;
+
+#ifdef __x86_64__
+#define ELF64
+#define ELF_LOAD_SYMTAB elf_load_symtab
+#else
+#define ELF32
+#define ELF_LOAD_SYMTAB elf_load_symtab
+#endif
+#include "../../../setup/elflib.inc"
+
+char *fname;
+int ok;
+int quiet = 0;
+int verbose = 0;
+int once = 0;
+int exit_status = -1;
+int check_compile_vermagic = 0;
+
+static void
+sym_callback (char *buffer, int blen, Elf_Sym * sym, char *name, int addr)
+{
+
+ char tmp[256], *vermagic = tmp;
+
+ ok = 1;
+ exit_status = 0;
+
+ if (verbose)
+ printf ("Vermagic buffer at %x\n", addr);
+
+ elf_read_datasym (buffer, blen, sym, addr, tmp, sizeof (tmp));
+
+ if (strncmp (vermagic, "vermagic=", 9) == 0)
+ vermagic += 9;
+
+ if (quiet)
+ printf ("%s\n", vermagic);
+ else
+ printf ("%s: '%s'\n", fname, vermagic);
+
+ if (once)
+ exit (0);
+}
+
+static void
+find_vermagic (char *fname)
+{
+ ok = 0;
+
+ if (verbose)
+ printf ("ELF scan %s\n", fname);
+
+ ok = ELF_LOAD_SYMTAB (fname, "vermagic", sym_callback);
+ if (!ok)
+ ok = ELF_LOAD_SYMTAB (fname, "__mod_vermagic", sym_callback);
+ if (!ok)
+ ELF_LOAD_SYMTAB (fname, "__oss_compile_vermagic", sym_callback);
+}
+
+static void
+find_link_vermagic (char *fname)
+{
+ if (verbose)
+ printf ("ELF scan %s\n", fname);
+
+ ELF_LOAD_SYMTAB (fname, "__oss_compile_vermagic", sym_callback);
+}
+
+static void
+check_gzipped_module (char *fname)
+{
+ char tmp[1024];
+
+ sprintf (tmp, "gunzip -c %s > /tmp/oss.tmpmodule", fname);
+ unlink ("/tmp/oss.tmpmodule");
+
+ if (system (tmp) != 0)
+ {
+ unlink ("/tmp/oss.tmpmodule");
+ return;
+ }
+
+ find_vermagic ("/tmp/oss.tmpmodule");
+ unlink ("/tmp/oss.tmpmodule");
+}
+
+static void
+check_bzipped_module (char *fname)
+{
+ char tmp[1024];
+
+ sprintf (tmp, "bunzip2 -c %s > /tmp/oss.tmpmodule", fname);
+ unlink ("/tmp/oss.tmpmodule");
+
+ if (system (tmp) != 0)
+ {
+ unlink ("/tmp/oss.tmpmodule");
+ return;
+ }
+
+ find_vermagic ("/tmp/oss.tmpmodule");
+ unlink ("/tmp/oss.tmpmodule");
+}
+
+static void
+scan_dir (char *dirname)
+{
+ char tmp[1024];
+ DIR *dir;
+ struct dirent *de;
+
+ if ((dir = opendir (dirname)) == NULL)
+ return;
+
+ while ((de = readdir (dir)))
+ {
+ struct stat st;
+
+ if (de->d_name[0] == '.')
+ continue;
+
+ sprintf (tmp, "%s/%s", dirname, de->d_name);
+
+ if (stat (tmp, &st) == -1)
+ {
+ perror (tmp);
+ return;
+ }
+
+ if (S_ISDIR (st.st_mode))
+ scan_dir (tmp);
+ else
+ {
+ char *p;
+
+ if (verbose)
+ printf ("Checking %s\n", tmp);
+ p = tmp + strlen (tmp) - 3; // Seek the .gz suffix
+ if (strcmp (p, ".gz") == 0)
+ {
+ fname = tmp;
+ check_gzipped_module (tmp);
+ continue;
+ }
+
+ p = tmp + strlen (tmp) - 4; // Seek the .bz2 suffix
+ if (strcmp (p, ".bz2") == 0)
+ {
+ fname = tmp;
+ check_bzipped_module (tmp);
+ continue;
+ }
+
+ fname = tmp;
+ find_vermagic (tmp);
+ }
+ }
+
+ closedir (dir);
+}
+
+static void
+find_system_vermagic (void)
+{
+ struct utsname un;
+ char dirname[1024];
+
+ struct stat st;
+
+ if (uname (&un) == -1)
+ {
+ perror ("uname");
+ exit (-1);
+ }
+
+ sprintf (dirname, "/lib/modules/%s/kernel", un.release);
+
+ if (stat (dirname, &st) == -1)
+ {
+ perror (dirname);
+ fprintf (stderr, "Kernel modules not available\n");
+ exit (-1);
+ }
+
+ quiet = 1;
+ once = 1;
+ scan_dir (dirname);
+}
+
+int
+main (int argc, char *argv[])
+{
+ int i, ok;
+ int do_sys = 0;
+ int valid = 0;
+
+ if (argc < 2)
+ exit (-1);
+
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], "-r") == 0)
+ {
+ /*
+ * Check if the system is 2.6.20 or later which is
+ * always compiled with CONFIG_REGPARM.
+ */
+
+ struct utsname un;
+ int a, b, c;
+
+ if (uname (&un) == -1)
+ {
+ perror ("uname");
+ exit (-1);
+ }
+
+ if (sscanf (un.release, "%d.%d.%d", &a, &b, &c) != 3)
+ {
+ fprintf (stderr, "Unrecognized kernel release '%s'\n",
+ un.release);
+ exit (0); /* Assume it's some future kernel */
+ }
+
+ if (a > 2)
+ exit (0); /* Always REGPARM */
+ if (b > 6)
+ exit (0); /* Always REGPARM */
+ if (c >= 20)
+ exit (0); /* Always REGPARM */
+
+ exit (1); /* Don't know */
+ }
+
+ if (strcmp (argv[i], "-s") == 0)
+ do_sys = 1;
+ if (strcmp (argv[i], "-v") == 0)
+ verbose++;
+ if (strcmp (argv[i], "-z") == 0)
+ valid = 1;
+ if (strcmp (argv[i], "-u") == 0)
+ check_compile_vermagic = 1;
+ }
+
+ if (!valid)
+ {
+ fprintf (stderr,
+ "%s: This program is reserved for use by Open Sound System\n",
+ argv[0]);
+ exit (-1);
+ }
+
+ elf_verbose = verbose;
+
+ if (do_sys)
+ {
+ ok = 0;
+ if (fork () == 0)
+ find_system_vermagic ();
+ else
+ {
+ int status;
+ wait (&status);
+ unlink ("/tmp/oss.tmpmodule");
+ exit (WEXITSTATUS (status));
+ }
+
+ if (!ok)
+ exit (-1);
+ exit (0);
+ }
+
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], "-q") == 0)
+ {
+ quiet = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], "-1") == 0)
+ {
+ once = 1;
+ continue;
+ }
+
+ fname = argv[i];
+ ok = 0;
+
+ if (*fname != '-')
+ {
+ if (check_compile_vermagic == 0) find_vermagic (fname);
+ else find_link_vermagic (fname);
+ }
+ }
+
+ exit (exit_status);
+}
diff --git a/os_cmd/SCO_SV/.config b/os_cmd/SCO_SV/.config
new file mode 100644
index 0000000..1d16879
--- /dev/null
+++ b/os_cmd/SCO_SV/.config
@@ -0,0 +1 @@
+targetos=SCO_SV
diff --git a/os_cmd/SCO_SV/ossdetect/.config b/os_cmd/SCO_SV/ossdetect/.config
new file mode 100644
index 0000000..17f28bb
--- /dev/null
+++ b/os_cmd/SCO_SV/ossdetect/.config
@@ -0,0 +1,2 @@
+mode=sbin
+targetos=SCO_SV
diff --git a/os_cmd/SCO_SV/ossdetect/ossdetect.c b/os_cmd/SCO_SV/ossdetect/ossdetect.c
new file mode 100644
index 0000000..48cbc01
--- /dev/null
+++ b/os_cmd/SCO_SV/ossdetect/ossdetect.c
@@ -0,0 +1,497 @@
+/*
+ * Purpose: OSS device autodetection utility for SCO OpenServer
+ *
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2008.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution for the license terms and conditions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/mkdev.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+
+dev_t default_dev = 0;
+
+#define PCI_PASS 0
+#define USB_PASS 1
+#define PSEUDO_PASS 2
+#define MAX_PASS 3
+
+#define OSSLIBDIRLEN 512
+static char *osslibdir = NULL;
+
+static int verbose = 0;
+
+typedef struct
+{
+ char *key, *driver, *name;
+ int is_3rdparty;
+ int detected;
+ int pass;
+} driver_def_t;
+
+typedef struct drv_slist
+{
+ const char * drv_name;
+ struct drv_slist * next;
+} drvlist_t;
+static drvlist_t * drvl = NULL;
+
+#define MAX_DRIVERS 1000
+static driver_def_t drivers[MAX_DRIVERS];
+static int ndrivers = 0;
+
+static int add_drv (const char *, int);
+static void create_devlinks (mode_t);
+static void create_node (char *, char *, int, mode_t);
+static drvlist_t * prepend_drvlist (const char *);
+static char * get_mapname (void);
+static void load_license (const char *);
+static void load_devlist (const char *, int);
+static void pci_detect (void);
+
+static char *
+get_mapname (void)
+{
+ FILE *f;
+ static char name[OSSLIBDIRLEN], tmp[OSSLIBDIRLEN+11];
+ struct stat st;
+
+ if ((f = fopen ("/etc/oss.conf", "r")) == NULL)
+ {
+ perror ("/etc/oss.conf");
+ goto oexit2;
+ }
+
+ while (fgets (tmp, sizeof (tmp), f) != NULL)
+ {
+ int l = strlen (tmp);
+ if (l > 0 && tmp[l - 1] == '\n')
+ tmp[l - 1] = '\0';
+
+ if (strncmp (tmp, "OSSLIBDIR=", 10) == 0)
+ {
+ l = snprintf (name, sizeof (name), "%s", &tmp[10]);
+ if ((l >= OSSLIBDIRLEN) || (l < 0))
+ {
+ fprintf (stderr, "String in /etc/oss.conf is too long!\n");
+ goto oexit;
+ }
+ if ((stat (name, &st) == -1) || !S_ISDIR(st.st_mode))
+ {
+ fprintf (stderr, "Directory %s from /etc/oss.conf cannot "
+ "be used!\n", name);
+ goto oexit;
+ }
+ fclose (f);
+ return name;
+ }
+ }
+
+ fprintf (stderr, "OSSLIBDIR not set in /etc/oss.conf, using default "
+ "/usr/lib/oss\n");
+oexit:
+ fclose (f);
+oexit2:
+ snprintf (name, sizeof (name), "/usr/lib/oss");
+ return name;
+}
+
+static void
+load_license (const char *fname)
+{
+ struct stat st;
+ char cmd[2*OSSLIBDIRLEN];
+ int n;
+
+ if (stat (fname, &st) == -1)
+ return; /* Doesn't exist */
+
+ if (stat ("/usr/sbin/osslic", &st) == -1)
+ return; /* No osslic utility in the system. No need to install license. */
+
+ n = snprintf (cmd, sizeof (cmd), "/usr/sbin/osslic -q %s/%s", osslibdir,
+ fname);
+ if (n >= sizeof (cmd) || n < 0) return;
+ system (cmd);
+}
+
+static void
+load_devlist (const char *fname, int is_3rdparty)
+{
+ FILE *f;
+ char line[256], *p, rfname[2*OSSLIBDIRLEN];
+ char *driver, *key, *name;
+
+ snprintf (rfname, sizeof (rfname), "%s/%s", osslibdir, fname);
+
+ if ((f = fopen (rfname, "r")) == NULL)
+ {
+ perror (rfname);
+ exit (-1);
+ }
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ p = line;
+ while (*p)
+ {
+ if (*p == '#' || *p == '\n')
+ *p = 0;
+ p++;
+ }
+
+ /* Drivers with upper case names are unsupported ones */
+ if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
+ continue;
+
+ driver = line;
+ p = line;
+
+ while (*p && *p != '\t' && *p != ' ')
+ p++;
+ if (*p)
+ *p++ = 0;
+ key = p;
+
+ while (*p && *p != '\t')
+ p++;
+ if (*p)
+ *p++ = 0;
+ name = p;
+
+ if (verbose > 1)
+ printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
+
+ if (ndrivers >= MAX_DRIVERS)
+ {
+ printf ("Too many drivers defined in drivers.list\n");
+ exit (-1);
+ }
+
+ drivers[ndrivers].key = strdup (key);
+ drivers[ndrivers].driver = strdup (driver);
+ drivers[ndrivers].name = strdup (name);
+ drivers[ndrivers].is_3rdparty = is_3rdparty;
+ drivers[ndrivers].detected = 0;
+
+ ndrivers++;
+ }
+
+ fclose (f);
+}
+
+static int
+add_drv (const char * id, int pass)
+{
+ int i;
+
+ for (i = 0; i < ndrivers; i++)
+ {
+ if (strcmp (id, drivers[i].key) == 0)
+ {
+ if (verbose > 0)
+ printf ("Detected %s\n", drivers[i].name);
+ drivers[i].detected = 1;
+ drivers[i].pass = pass;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void
+create_node (char *drvname, char *name, int devno, mode_t node_m)
+{
+ struct stat st;
+ char tmp[64], *s, *p;
+ char cmd[128];
+ dev_t dev;
+
+ sprintf (tmp, "/dev/%s", drvname);
+
+ if (stat (tmp, &st) == -1)
+ dev = default_dev;
+ else
+ {
+ if (!S_ISCHR (st.st_mode))
+ return;
+ dev = st.st_rdev;
+ }
+
+ if (dev == 0)
+ return;
+
+/*
+ * Check if the device is located in a subdirectory (say /dev/oss/sblive0/pcm0).
+ */
+ sprintf (tmp, "/dev/%s", name);
+
+ s = tmp + 5;
+ p = s;
+ while (*s)
+ {
+ if (*s == '/')
+ p = s;
+ s++;
+ }
+
+ if (*p == '/')
+ {
+ *p = 0; /* Extract the directory name part */
+ mkdir (tmp, 0755);
+ }
+
+ sprintf (tmp, "/dev/%s", name);
+ dev += devno;
+ if (verbose)
+ printf ("mknod %s c %d %d -m %o\n", tmp, major, minor, node_m);
+ unlink (tmp);
+
+ if (mknod (tmp, node_m, dev) == -1)
+ perror (tmp);
+}
+
+static void
+create_devlinks (mode_t node_m)
+{
+ FILE *drvf, *f;
+ struct stat st;
+ char drvname[32], name[32], line[64], *s, tmp[256], instfname[2*OSSLIBDIRLEN];
+ mode_t perm;
+
+ snprintf (instfname, sizeof (instfname), "%s/%s", osslibdir,
+ "etc/installed_drivers");
+
+ if ((drvf = fopen (instfname, "r")) == NULL)
+ {
+ perror (instfname);
+ return;
+ }
+
+ perm = umask (0);
+ mkdir ("/dev/oss", 0755);
+
+ while (fgets (drvname, sizeof (drvname), drvf) != NULL)
+ {
+ s = strchr (drvname, '\n');
+ if (s) *s = '\0'; /* Remove the LF character */
+
+ /* Remove the device full name (comment) field from the line */
+ s = drvname;
+ while (*s && *s != ' ' && *s != '#')
+ s++;
+ *s = '\0';
+ if (*drvname == '\0') continue;
+
+ sprintf (name, "/dev/%s0", drvname);
+
+ if (stat (name, &st) == -1)
+ continue;
+ default_dev = st.st_rdev;
+
+ if ((f = fopen (name, "r")) == NULL)
+ {
+ perror (name);
+ continue;
+ }
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ int minor;
+
+ if (sscanf (line, "%s %s %d", name, drvname, &minor) != 3)
+ {
+ fprintf (stderr,
+ "ossdetect: Unexpected line in the drvinfo file %s\n",
+ name);
+ fprintf (stderr, "'%s'\n", line);
+ exit (-1);
+ }
+
+ create_node (drvname, name, minor, node_m);
+ }
+
+ fclose (f);
+ break;
+ }
+
+ umask (perm);
+ fclose (drvf);
+}
+
+static void
+pci_detect (void)
+{
+ FILE *f;
+ char line[256];
+
+ if ((f = popen ("echo pcishort|/usr/sbin/ndcfg -q", "r")) == NULL)
+ {
+ perror ("pcishort|/usr/sbin/ndcfg -q");
+ fprintf (stderr, "Scanning PCI devices failed\n");
+ exit (-1);
+ }
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ int dummy;
+ int vendor, device;
+ char name[32];
+
+ if (sscanf (line, "%d %x %x %d %d %x %x",
+ &dummy, &dummy, &dummy, &dummy, &dummy,
+ &vendor, &device) != 7)
+ {
+ fprintf (stderr, "Bad line returned by ndcfg\n");
+ fprintf (stderr, "%s", line);
+ exit (-1);
+ }
+
+ sprintf (name, "pci%x,%x", vendor, device);
+
+ add_drv (name, PCI_PASS);
+ }
+
+ pclose (f);
+}
+
+static drvlist_t *
+prepend_drvlist (const char * name)
+{
+ drvlist_t * dp;
+
+ dp = malloc (sizeof (drvlist_t));
+ if (dp == NULL)
+ {
+ fprintf (stderr, "Can't allocate memory!\n");
+ exit (-1);
+ }
+
+ dp->drv_name = name;
+ dp->next = drvl;
+ return dp;
+}
+
+int
+main (int argc, char *argv[])
+{
+ char instfname[2*OSSLIBDIRLEN], *p;
+ int i, pass, do_license = 0, make_devs = 0;
+ mode_t node_m = S_IFCHR | 0666;
+ struct stat st;
+ FILE *f;
+
+ while ((i = getopt(argc, argv, "L:a:dilm:uv")) != EOF)
+ switch (i)
+ {
+ case 'v':
+ verbose++;
+ break;
+
+ case 'd':
+ make_devs = 1;
+ break;
+
+ case 'i':
+ drvl = prepend_drvlist ("oss_imux");
+ break;
+
+ case 'u':
+ drvl = prepend_drvlist ("oss_userdev");
+ break;
+
+ case 'a':
+ drvl = prepend_drvlist (optarg);
+ break;
+
+ case 'l':
+ do_license = 1;
+ break;
+
+ case 'L':
+ osslibdir = optarg;
+ break;
+
+ case 'm':
+ p = optarg;
+ node_m = 0;
+ while ((*p >= '0') && (*p <= '7')) node_m = node_m * 8 + *p++ - '0';
+ if ((*p) || (node_m & ~(S_IRWXU|S_IRWXG|S_IRWXO)))
+ {
+ fprintf (stderr, "Invalid permissions: %s\n", optarg);
+ exit(1);
+ }
+ node_m |= S_IFCHR;
+ break;
+
+ default:
+ fprintf (stderr, "%s: bad usage\n", argv[0]);
+ exit (-1);
+ }
+
+ if (osslibdir == NULL) osslibdir = get_mapname ();
+
+ if (make_devs == 1)
+ {
+ create_devlinks (node_m);
+ exit (0);
+ }
+
+ if (do_license == 1)
+ {
+ load_license ("etc/license.asc");
+ exit (0);
+ }
+
+ load_devlist ("etc/devices.list", 0);
+
+ if (stat ("/etc/oss_3rdparty", &st) != -1)
+ load_devlist ("/etc/oss_3rdparty", 1);
+
+ pci_detect ();
+
+ while (drvl != NULL)
+ {
+ drvlist_t * d = drvl;
+ add_drv (drvl->drv_name, PSEUDO_PASS);
+ drvl = drvl->next;
+ free (d);
+ }
+
+ snprintf (instfname, sizeof (instfname), "%s/%s", osslibdir,
+ "etc/installed_drivers");
+
+ if ((f = fopen (instfname, "w")) == NULL)
+ {
+ perror (instfname);
+ exit (-1);
+ }
+
+ for (pass = 0; pass < MAX_PASS; pass++)
+ for (i = 0; i < ndrivers; i++)
+ if (drivers[i].pass == pass && drivers[i].detected)
+ {
+ /* fprintf (f, "%s #%s\n", drivers[i].driver, drivers[i].name); */
+ fprintf (f, "%s\n", drivers[i].driver);
+ }
+
+ fclose (f);
+
+ exit (0);
+}
diff --git a/os_cmd/SCO_SV/ossdetect/ossdetect.man b/os_cmd/SCO_SV/ossdetect/ossdetect.man
new file mode 100644
index 0000000..a05cca5
--- /dev/null
+++ b/os_cmd/SCO_SV/ossdetect/ossdetect.man
@@ -0,0 +1,32 @@
+NAME
+ossdetect - Open Sound System audio device detection program.
+
+SYNOPSIS
+ossdetect [-diuv] [-m<mode>] [-L<path>]
+
+DESCRIPTION
+The ossdetect application performs automatic detection of soundcards.
+The application looks at the /usr/lib/oss/etc/device.list and performs
+automatic detection. It will create a file with the list of the configured
+drivers in /usr/lib/oss/etc/installed_drivers.
+
+The Input Multiplexer driver (IMUX) is not configured by default and
+can be added to the OSS configuration using the -i option.
+
+OPTIONS
+-d Create device file links.
+-i Adds the oss_imux driver.
+-m<mode> Create nodes with permissions set to octal <mode>.
+-u Adds the oss_userdev driver.
+-v Verbose output.
+-L<path> Use <path> as root directory for OSS files.
+ Default: Path from /etc/oss.conf, followed by /usr/lib/oss.
+
+SEE ALSO
+ossdevlinks(1), ossinfo(1)
+
+FILES
+/usr/sbin/ossdetect
+
+AUTHOR
+4Front Technologies
diff --git a/os_cmd/SunOS/.config b/os_cmd/SunOS/.config
new file mode 100644
index 0000000..4e5675a
--- /dev/null
+++ b/os_cmd/SunOS/.config
@@ -0,0 +1 @@
+targetos=SunOS
diff --git a/os_cmd/SunOS/ossdetect/.config b/os_cmd/SunOS/ossdetect/.config
new file mode 100644
index 0000000..27ac804
--- /dev/null
+++ b/os_cmd/SunOS/ossdetect/.config
@@ -0,0 +1,3 @@
+cflags=-ldevinfo
+mode=sbin
+targetos=SunOS
diff --git a/os_cmd/SunOS/ossdetect/ossdetect.c b/os_cmd/SunOS/ossdetect/ossdetect.c
new file mode 100644
index 0000000..e856482
--- /dev/null
+++ b/os_cmd/SunOS/ossdetect/ossdetect.c
@@ -0,0 +1,799 @@
+/*
+ * Purpose: OSS device autodetection utility for Solaris
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2008.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution for the license terms and conditions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <libdevinfo.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/utsname.h>
+#include <ctype.h>
+#include <sys/systeminfo.h>
+
+static int use_force = 0;
+static char arch[32] = "";
+static int install_imux = 0;
+static int install_userdev = 0;
+static char *safe_mode="";
+
+/* List of all modules installed in the system (OSS and non-oss) */
+#define MAX_MODS 512
+static char *installed_modules[MAX_MODS];
+static int nmods = 0;
+
+
+FILE *drivers_f = NULL;
+
+static const char *ossdevs[] = {
+ "sndstat",
+ "mixer",
+ "dsp",
+/* "audio", */
+ "midi",
+ "sequencer",
+ "music",
+ NULL
+};
+
+static void
+scan_devdir (char *path)
+{
+ int i, ok;
+ DIR *dir;
+ struct dirent *de;
+ struct stat st;
+
+ char fullname[256], *devpart, devclass[256], *s;
+ char devname[256];
+
+ if ((dir = opendir (path)) == NULL)
+ {
+ perror (path);
+ exit (-1);
+ }
+
+ while ((de = readdir (dir)) != NULL)
+ {
+ if (de->d_name[0] == '.')
+ continue;
+
+ sprintf (fullname, "%s/%s", path, de->d_name);
+
+ if (stat (fullname, &st) == -1)
+ {
+ perror (fullname);
+ continue;
+ }
+
+ if (S_ISDIR (st.st_mode))
+ {
+ scan_devdir (fullname);
+ continue;
+ }
+
+#if 1
+ if (!S_ISCHR (st.st_mode))
+ continue;
+#endif
+
+/*
+ * Find the device name part (after ":").
+ */
+ devpart = fullname;
+ while (*devpart)
+ {
+ if (*devpart == ':')
+ {
+ devpart++;
+ break;
+ }
+
+ devpart++;
+ }
+
+ strcpy (devclass, devpart);
+ s = devclass;
+ while (*s)
+ {
+ if (isdigit (*s))
+ *s = 0;
+ else
+ s++;
+ }
+
+/*
+ * Check if this kind of devices are known by OSS
+ */
+ ok = 0;
+
+ for (i = 0; !ok && ossdevs[i] != NULL; i++)
+ if (strcmp (devclass, ossdevs[i]) == 0)
+ ok = 1;
+
+ if (!ok)
+ continue;
+
+ sprintf (devname, "/dev/%s", devpart);
+ unlink (devname);
+
+ if (symlink (fullname, devname) == -1)
+ {
+ perror (devname);
+ }
+ }
+
+ closedir (dir);
+}
+
+typedef struct
+{
+ char *driver;
+ char *name;
+ char idlist[128];
+ int nids;
+ char *ids[32];
+ int pass;
+} module_def_t;
+
+typedef struct
+{
+ char *key, *driver, *name;
+ int is_3rdparty, reload;
+} driver_def_t;
+
+#define MAX_DRIVERS 1000
+static driver_def_t drivers[MAX_DRIVERS];
+static int ndrivers = 0;
+
+#define MAX_MODULES 32
+static module_def_t modules[MAX_MODULES];
+static int nmodules = 0;
+
+static int verbose = 0;
+
+static void
+install_driver (driver_def_t * drv, char *drv_id)
+{
+ int i, j;
+
+ if (verbose > 0)
+ printf ("Install module '%s' (%s)\n", drv->driver, drv_id);
+
+ for (i = 0; i < nmodules; i++)
+ if (strcmp (drv->driver, modules[i].driver) == 0)
+ {
+ for (j = 0; j < modules[i].nids; j++)
+ {
+ if (strcmp (drv_id, modules[i].ids[j]) == 0)
+ return;
+ }
+
+ strcat (modules[i].idlist, " \"");
+ strcat (modules[i].idlist, drv_id);
+ strcat (modules[i].idlist, "\"");
+
+ if (modules[i].nids < 32)
+ {
+ int n = modules[i].nids++;
+ modules[i].ids[n] = strdup (drv_id);
+ }
+ return;
+ }
+
+ if (nmodules >= MAX_MODULES)
+ {
+ fprintf (stderr, "Too many OSS modules\n");
+ exit (-1);
+ }
+
+ modules[nmodules].name = drv->name;
+ modules[nmodules].driver = drv->driver;
+ sprintf (modules[nmodules].idlist, "\"%s\"", drv_id);
+ modules[nmodules].nids = 1;
+ modules[nmodules].ids[0] = strdup (drv_id);
+ modules[nmodules].pass = 0;
+
+/*
+ * Hot-pluggable modules should be loaded after other modules.
+ */
+ if (strcmp (drv->driver, "oss_usb") == 0)
+ modules[nmodules].pass = 1;
+
+ nmodules++;
+}
+
+static void
+find_and_install_driver (char *key)
+{
+
+ int i;
+
+ for (i = 0; i < ndrivers; i++)
+ if (strcmp (drivers[i].key, key) == 0)
+ {
+ if (verbose > 0)
+ printf ("\nDetected %s: %s (driver=%s)\n",
+ key, drivers[i].name, drivers[i].driver);
+ install_driver (&drivers[i], key);
+ return;
+ }
+}
+
+static int
+check_name (char *key, char *realname)
+{
+ int i;
+
+ if (realname == NULL)
+ realname = key;
+
+ for (i = 0; i < ndrivers; i++)
+ if (strcmp (drivers[i].key, key) == 0)
+ {
+ if (verbose > 0)
+ printf ("\nDetected %s: %s (driver=%s)\n",
+ realname, drivers[i].name, drivers[i].driver);
+ /* install_driver(&drivers[i], realname); */
+ install_driver (&drivers[i], key);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+check_node (di_node_t node, int level, char *realname)
+{
+ int j, ok = 0;
+
+ while (node != DI_NODE_NIL)
+ {
+ char *name = di_node_name (node), *p;
+ char *cnames;
+ int n, i;
+
+ cnames = "?";
+
+ if (verbose > 1)
+ {
+ for (j = 1; j < level; j++)
+ printf ("\t");
+ printf ("%s ", name);
+ }
+
+ /* if (realname==NULL) */
+ {
+ realname = name;
+ }
+
+ if (check_name (name, realname))
+ {
+ if (verbose > 1)
+ {
+ char *drv = di_driver_name (node);
+ char *bnd = di_binding_name (node);
+ if (drv == NULL)
+ drv = "";
+ if (bnd == NULL)
+ bnd = "";
+ printf ("*match (driver=%s, binding=%s, instance=%d)*", drv,
+ bnd, di_instance (node));
+ }
+ ok = 1;
+ }
+
+ if (verbose > 1)
+ printf ("\n");
+
+ n = di_compatible_names (node, &cnames);
+ p = cnames;
+ for (i = 0; i < n; i++)
+ if (!ok)
+ {
+ if (verbose > 1)
+ {
+ for (j = 1; j < level; j++)
+ printf ("\t");
+ printf (" = %s ", p);
+ }
+
+ if (check_name (p, realname))
+ {
+ if (verbose > 1)
+ {
+ char *drv = di_driver_name (node);
+ char *bnd = di_binding_name (node);
+ if (drv == NULL)
+ drv = "";
+ if (bnd == NULL)
+ bnd = "";
+ printf ("*match (driver=%s, binding=%s, instance=%d)*",
+ drv, bnd, di_instance (node));
+ }
+ ok = 1;
+ }
+
+ if (verbose > 1)
+ printf ("\n");
+ p = p + strlen (p) + 1;
+ }
+
+ if (ok)
+ { /* Handle properties */
+ di_prop_t prop = DI_PROP_NIL;
+
+ while ((prop = di_prop_next (node, prop)) != DI_PROP_NIL)
+ {
+ printf ("\tProp '%s'}n", di_prop_name (prop));
+ }
+ }
+
+ /* if (!ok) */
+ check_node (di_child_node (node), level + 1, realname);
+
+ node = di_sibling_node (node);
+ }
+
+ return ok;
+}
+
+static void
+load_devlist (const char *fname, int is_3rdparty)
+{
+ FILE *f;
+ char line[256], *p;
+ char *driver, *key, *name;
+
+ if ((f = fopen (fname, "r")) == NULL)
+ {
+ perror (fname);
+ exit (-1);
+ }
+
+ while (fgets (line, sizeof (line) - 1, f) != NULL)
+ {
+ p = line;
+ while (*p)
+ {
+ if (*p == '#' || *p == '\n')
+ *p = 0;
+ p++;
+ }
+
+ /* Drivers with upper case names are unsupported ones */
+ if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
+ continue;
+
+ driver = line;
+ p = line;
+
+ while (*p && *p != '\t' && *p != ' ')
+ p++;
+ if (*p)
+ *p++ = 0;
+ key = p;
+
+/*
+ * PCI subvendor ID's are marked as pcsNN,MM in devices.list. Convert them
+ * to pciNN,MM for Solaris
+ */
+ if (strncmp (key, "pcs", 3) == 0)
+ key[2] = 'i';
+
+ while (*p && *p != '\t')
+ p++;
+ if (*p)
+ *p++ = 0;
+ name = p;
+
+ if (verbose > 1)
+ printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
+
+ if (ndrivers >= MAX_DRIVERS)
+ {
+ printf ("Too many drivers defined in drivers.list\n");
+ exit (-1);
+ }
+
+ drivers[ndrivers].key = strdup (key);
+ drivers[ndrivers].driver = strdup (driver);
+ drivers[ndrivers].name = strdup (name);
+ drivers[ndrivers].is_3rdparty = is_3rdparty;
+ drivers[ndrivers].reload = 0;
+
+ ndrivers++;
+ }
+
+ fclose (f);
+}
+
+static void
+check_conf (char *modname, int is_virtual, char *options)
+{
+ char fname[256], drivername[256];
+ struct stat st;
+ FILE *f;
+
+#ifdef sparc
+ sprintf (fname, "/kernel/drv/%s.conf", modname);
+ sprintf (drivername, "/kernel/drv/%s%s", arch, modname);
+#else
+ sprintf (fname, "/kernel/drv/%s.conf", modname);
+ sprintf (drivername, "/kernel/drv/%s%s", arch, modname);
+#endif
+
+ /* fprintf(start_script, "/usr/sbin/modload %s\n", drivername); */
+
+ if (!use_force)
+ if (stat (fname, &st) != -1) /* File already exists */
+ return;
+ else
+ fprintf (stderr, "\n\nWarning! Config file %s was missing!\n\n", fname);
+
+ if ((f = fopen (fname, "w")) == NULL)
+ {
+ perror (fname);
+ exit (-1);
+ }
+ fprintf (f, "# Open Sound System configuration file\n");
+
+ if (is_virtual)
+ fprintf (f, "name=\"%s\" parent=\"pseudo\" instance=0%s;\n", modname,
+ options);
+ else
+ fprintf (f, "interrupt-priorities=9%s;\n", options);
+
+ fclose (f);
+}
+
+static void
+load_name_to_major (void)
+{
+ FILE *f;
+ char line[256], *p;
+
+ if ((f = fopen ("/etc/name_to_major", "r")) == NULL)
+ return;
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ p = line;
+
+ while (*p && *p != ' ')
+ p++;
+ *p = '\0';
+
+ if (*line == '\0') continue;
+
+ if (nmods < MAX_MODS)
+ {
+ installed_modules[nmods++] = strdup (line);
+ }
+
+/*
+ * Force reinstall of imux if it is currently installed in the system
+ */
+ if (strcmp (line, "oss_imux") == 0)
+ install_imux = 1;
+ if (strcmp (line, "oss_userdev") == 0)
+ install_userdev = 1;
+ }
+
+ fclose (f);
+}
+
+static int
+add_drv (char *name, char *drv, char *parms)
+{
+ char tmp[512];
+ int ret;
+
+ printf ("add_drv %s%s %s\n", safe_mode, parms, drv);
+ sprintf (tmp, "add_drv %s%s %s", safe_mode, parms, drv);
+
+ ret = system (tmp);
+
+ if (ret != 0)
+ fprintf (stderr, "%s\n", tmp);
+
+ /* save the driver and name info in installed_drivers file except osscore */
+ if (name != NULL)
+ fprintf (drivers_f, "%s #%s\n", drv, name);
+
+ return ret;
+}
+
+static void
+load_license (char *fname)
+{
+ struct stat st;
+ char cmd[256];
+
+ if (stat (fname, &st) == -1)
+ return; /* Doesn't exist */
+
+ if (stat ("/usr/sbin/osslic", &st) == -1)
+ return; /* No osslic utility in the system. No need to install license. */
+
+ sprintf (cmd, "/usr/sbin/osslic -q %s", fname);
+ system (cmd);
+}
+
+static void
+forceload_drivers (char *fname)
+{
+ FILE *f;
+ char line[256], *p;
+
+ if ((f = fopen (fname, "r")) == NULL)
+ return;
+
+ while (fgets (line, sizeof (line), f) != NULL)
+ {
+ p = strchr (line, '\n');
+ if (p) *p = '\0';
+ find_and_install_driver (line);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ int i, pass, c;
+ di_node_t root_node;
+ char tmp[256];
+ struct stat st;
+ FILE *ptr;
+ int pid;
+ char *cmd = "/usr/sbin/modinfo | grep osscommon";
+
+#if 0
+ if (sysinfo (SI_ARCHITECTURE_K, tmp, sizeof (tmp)) == -1)
+ {
+ perror ("sysinfo SI_ARCHITECTURE_K");
+ exit (-1);
+ }
+#else
+ if (sysinfo (SI_ARCHITECTURE, tmp, sizeof (tmp)) == -1)
+ {
+ perror ("sysinfo SI_ARCHITECTURE");
+ exit (-1);
+ }
+#endif
+
+ load_name_to_major ();
+
+#ifdef sparc
+ if (strcmp (tmp, "sparc") == 0)
+ sprintf (arch, "sparcv9/", tmp);
+#else
+ if (strcmp (tmp, "amd64") == 0)
+ sprintf (arch, "%s/", tmp);
+#endif
+
+ while ((c = getopt (argc, argv, "vfiudlVS")) != EOF)
+ switch (c)
+ {
+ case 'v':
+ verbose++;
+ break;
+ case 'f':
+ use_force = 1;
+ break;
+ case 'S': /* Safe mode */
+ safe_mode="-n ";
+ break;
+ case 'i':
+ install_imux = 1;
+ break;
+ case 'u':
+ install_userdev = 1;
+ break;
+ case 'd': /* Obolete under Solaris. */
+ exit (0);
+ break;
+ case 'l':
+ load_license ("/etc/oss/license.asc");
+ exit (0);
+ break;
+ }
+
+ load_license ("/etc/oss/license.asc");
+
+ load_devlist ("/etc/oss/devices.list", 0);
+
+ if ((drivers_f = fopen ("/etc/oss/installed_drivers", "w")) == NULL)
+ {
+ perror ("/etc/oss/installed_drivers");
+ exit (-1);
+ }
+
+ if (stat ("/etc/oss_3rdparty", &st) != -1)
+ load_devlist ("/etc/oss_3rdparty", 1);
+
+ if ((root_node = di_init ("/", DINFOSUBTREE)) == DI_NODE_NIL)
+ {
+ printf ("di_init() failed\n");
+ }
+
+ check_node (root_node, 0, NULL);
+
+ di_fini (root_node);
+
+ /*
+ * Force unconditional loading of the USB driver and few others to make
+ * hotplugging possible.
+ */
+ forceload_drivers ("/etc/oss/forceload.conf");
+
+ if (verbose > 3)
+ {
+ for (i = 0; i < nmodules; i++)
+ {
+ printf ("Would add %s -i '%s'\n", modules[i].driver,
+ modules[i].idlist);
+ }
+ printf ("Skipping actual device installation\n");
+ exit (0);
+ }
+
+ sync ();
+
+/*
+ * Unload drivers that appear to be loaded
+ */
+ for (i = 0; i < nmods; i++)
+ {
+ int j, ok = 0;
+
+ for (j = 0; j < ndrivers && !ok; j++)
+ {
+ if (strcmp (installed_modules[i], drivers[j].driver) == 0)
+ {
+ ok = 1;
+ if (strcmp (drivers[j].key, "$PSEUDO") == 0 ||
+ drivers[j].is_3rdparty)
+ {
+ if (drivers[j].is_3rdparty)
+ printf ("Removed 3rd party driver %s\n",
+ drivers[j].driver);
+ drivers[j].reload = 1;
+ }
+ }
+ }
+
+ if (!ok)
+ continue;
+
+ sprintf (tmp, "rem_drv %s\n", installed_modules[i]);
+ printf ("rem_drv %s\n", installed_modules[i]);
+ system (tmp);
+ sync ();
+ }
+
+#if 0
+/*
+ * Tell the osscore module to go away by writing something to /dev/sndstat
+ * (at this moment it doesn't matter what is written).
+ */
+
+ system ("rem_drv osscore");
+ sync ();
+#endif
+
+ /* Find the osscommon module's PID and pass it to moduload to unload it */
+ if ((ptr = popen (cmd, "r")) != NULL)
+ {
+ if (fscanf (ptr, "%d", &pid) == 1 && pid > 0)
+ {
+ sprintf (tmp, "modunload -i %d", pid);
+ fprintf (stderr, "unloaded osscommon\n");
+ system (tmp);
+ }
+ pclose (ptr);
+ }
+
+
+/* Now start loading all the modules */
+ check_conf ("osscore", 1, "");
+
+ if (add_drv ("OSS Core Devices", "osscore", "-m '* 0666 root sys'") != 0)
+ {
+ fprintf (stderr, "Installing OSS (osscore) failed\n");
+ exit (256);
+ }
+
+ for (pass = 0; pass < 2; pass++)
+ for (i = 0; i < nmodules; i++)
+ if (modules[i].pass == pass)
+ {
+ check_conf (modules[i].driver, 0, "");
+ sprintf (tmp, "-m '* 0666 root sys' -i '%s'", modules[i].idlist);
+ if (add_drv (modules[i].name, modules[i].driver, tmp) != 0)
+ {
+ fprintf (stderr, "Installing OSS (%s) failed\n",
+ modules[i].driver);
+ exit (256);
+ }
+ }
+
+ if (install_imux)
+ {
+ check_conf ("oss_imux", 1, "");
+ add_drv ("OSS Input Multiplexer", "oss_imux", "-m '* 0666 root sys'");
+ }
+
+ if (install_userdev)
+ {
+ check_conf ("oss_userdev", 1, "");
+ add_drv ("OSS User space device driver", "oss_userdev", "-m '* 0666 root sys'");
+ }
+
+#ifdef sparc
+ if (stat("/kernel/drv/sparcv9/oss_sadasupport", &st) != -1)
+ if (stat("/kernel/misc/sparcv9/audiosup", &st) != -1)
+#else
+ if (stat("/kernel/drv/oss_sadasupport", &st) != -1)
+ if (stat("/kernel/misc/audiosup", &st) != -1)
+#endif
+ {
+ check_conf ("oss_sadasupport", 1, "");
+ add_drv ("SADA emulation layer", "oss_sadasupport", "-m '* 0666 root sys'");
+ }
+
+ for (i = 0; i < ndrivers; i++)
+ if (drivers[i].reload)
+ if (!drivers[i].is_3rdparty)
+ {
+ check_conf (drivers[i].driver, 1, "");
+ add_drv (drivers[i].name, drivers[i].driver,
+ "-m '* 0666 root sys'");
+ }
+ else
+ {
+ char parms[1024];
+
+ if (strcmp (drivers[i].key, "$PSEUDO") == 0)
+ {
+ add_drv (drivers[i].name, drivers[i].driver,
+ "-m '* 0666 root sys'");
+ continue;
+ }
+
+ sprintf (parms, "-i '%s' -m '* 0666 root sys'", drivers[i].key);
+ printf ("Attempting to reload %s\n", drivers[i].driver);
+ add_drv (drivers[i].name, drivers[i].driver, parms);
+ }
+
+/*
+ * Reload the previous default settings if they were ever saved.
+ */
+ if (stat ("/etc/oss/mixer.save", &st) != -1 ||
+ stat ("/etc/oss/dspdevs.map", &st) != -1)
+ system ("savemixer -L");
+
+ fclose (drivers_f);
+#if 0
+ sync ();
+ printf ("Restarting OSS - Please wait\r");
+ fflush (stdout);
+ system ("soundoff");
+ system ("soundon");
+ printf ("\n");
+#endif
+ return 0;
+}
diff --git a/os_cmd/SunOS/ossdetect/ossdetect.man b/os_cmd/SunOS/ossdetect/ossdetect.man
new file mode 100644
index 0000000..7322aaf
--- /dev/null
+++ b/os_cmd/SunOS/ossdetect/ossdetect.man
@@ -0,0 +1,23 @@
+NAME
+ossdetect - Open Sound System audio device detection applet.
+
+DESCRIPTION
+The ossdetect application performs automatic detection of soundcards
+under solaris. The application looks at the /usr/lib/oss/etc/device.list
+and performs automatic detection. It will create a file with the
+list of the configured drivers in /usr/lib/oss/etc/installed_drivers.
+
+The Input Multiplexer driver (IMUX) is not configured by default and
+can be added to the OSS configuration using the -i option.
+OPTIONS
+-v Verbose output
+-f Forces the creation of driver.conf files.
+-i Adds the IMUX driver.
+-u Adds the oss_userdev driver.
+-d Scans /devices and creates device file links
+
+FILES
+/usr/sbin/ossdetect
+
+AUTHOR
+4Front Technologies