~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to os_cmd/SunOS/ossdetect/ossdetect.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: OSS device autodetection utility for Solaris
 
3
 */
 
4
/*
 
5
 *
 
6
 * This file is part of Open Sound System.
 
7
 *
 
8
 * Copyright (C) 4Front Technologies 1996-2008.
 
9
 *
 
10
 * This this source file is released under GPL v2 license (no other versions).
 
11
 * See the COPYING file included in the main directory of this source
 
12
 * distribution for the license terms and conditions.
 
13
 *
 
14
 */
 
15
 
 
16
#include <stdio.h>
 
17
#include <stdlib.h>
 
18
#include <unistd.h>
 
19
#include <string.h>
 
20
#include <libdevinfo.h>
 
21
#include <sys/types.h>
 
22
#include <dirent.h>
 
23
#include <sys/stat.h>
 
24
#include <sys/utsname.h>
 
25
#include <ctype.h>
 
26
#include <sys/systeminfo.h>
 
27
 
 
28
static int use_force = 0;
 
29
static char arch[32] = "";
 
30
static int install_imux = 0;
 
31
static int install_userdev = 0;
 
32
static char *safe_mode="";
 
33
 
 
34
/* List of all modules installed in the system (OSS and non-oss) */
 
35
#define MAX_MODS 512
 
36
static char *installed_modules[MAX_MODS];
 
37
static int nmods = 0;
 
38
 
 
39
 
 
40
FILE *drivers_f = NULL;
 
41
 
 
42
static const char *ossdevs[] = {
 
43
  "sndstat",
 
44
  "mixer",
 
45
  "dsp",
 
46
/*      "audio", */
 
47
  "midi",
 
48
  "sequencer",
 
49
  "music",
 
50
  NULL
 
51
};
 
52
 
 
53
static void
 
54
scan_devdir (char *path)
 
55
{
 
56
  int i, ok;
 
57
  DIR *dir;
 
58
  struct dirent *de;
 
59
  struct stat st;
 
60
 
 
61
  char fullname[256], *devpart, devclass[256], *s;
 
62
  char devname[256];
 
63
 
 
64
  if ((dir = opendir (path)) == NULL)
 
65
    {
 
66
      perror (path);
 
67
      exit (-1);
 
68
    }
 
69
 
 
70
  while ((de = readdir (dir)) != NULL)
 
71
    {
 
72
      if (de->d_name[0] == '.')
 
73
        continue;
 
74
 
 
75
      sprintf (fullname, "%s/%s", path, de->d_name);
 
76
 
 
77
      if (stat (fullname, &st) == -1)
 
78
        {
 
79
          perror (fullname);
 
80
          continue;
 
81
        }
 
82
 
 
83
      if (S_ISDIR (st.st_mode))
 
84
        {
 
85
          scan_devdir (fullname);
 
86
          continue;
 
87
        }
 
88
 
 
89
#if 1
 
90
      if (!S_ISCHR (st.st_mode))
 
91
        continue;
 
92
#endif
 
93
 
 
94
/*
 
95
 * Find the device name part (after ":").
 
96
 */
 
97
      devpart = fullname;
 
98
      while (*devpart)
 
99
        {
 
100
          if (*devpart == ':')
 
101
            {
 
102
              devpart++;
 
103
              break;
 
104
            }
 
105
 
 
106
          devpart++;
 
107
        }
 
108
 
 
109
      strcpy (devclass, devpart);
 
110
      s = devclass;
 
111
      while (*s)
 
112
        {
 
113
          if (isdigit (*s))
 
114
            *s = 0;
 
115
          else
 
116
            s++;
 
117
        }
 
118
 
 
119
/*
 
120
 * Check if this kind of devices are known by OSS
 
121
 */
 
122
      ok = 0;
 
123
 
 
124
      for (i = 0; !ok && ossdevs[i] != NULL; i++)
 
125
        if (strcmp (devclass, ossdevs[i]) == 0)
 
126
          ok = 1;
 
127
 
 
128
      if (!ok)
 
129
        continue;
 
130
 
 
131
      sprintf (devname, "/dev/%s", devpart);
 
132
      unlink (devname);
 
133
 
 
134
      if (symlink (fullname, devname) == -1)
 
135
        {
 
136
          perror (devname);
 
137
        }
 
138
    }
 
139
 
 
140
  closedir (dir);
 
141
}
 
142
 
 
143
typedef struct
 
144
{
 
145
  char *driver;
 
146
  char *name;
 
147
  char idlist[128];
 
148
  int nids;
 
149
  char *ids[32];
 
150
  int pass;
 
151
} module_def_t;
 
152
 
 
153
typedef struct
 
154
{
 
155
  char *key, *driver, *name;
 
156
  int is_3rdparty, reload;
 
157
} driver_def_t;
 
158
 
 
159
#define MAX_DRIVERS     1000
 
160
static driver_def_t drivers[MAX_DRIVERS];
 
161
static int ndrivers = 0;
 
162
 
 
163
#define MAX_MODULES     32
 
164
static module_def_t modules[MAX_MODULES];
 
165
static int nmodules = 0;
 
166
 
 
167
static int verbose = 0;
 
168
 
 
169
static void
 
170
install_driver (driver_def_t * drv, char *drv_id)
 
171
{
 
172
  int i, j;
 
173
 
 
174
  if (verbose > 0)
 
175
    printf ("Install module '%s' (%s)\n", drv->driver, drv_id);
 
176
 
 
177
  for (i = 0; i < nmodules; i++)
 
178
    if (strcmp (drv->driver, modules[i].driver) == 0)
 
179
      {
 
180
        for (j = 0; j < modules[i].nids; j++)
 
181
          {
 
182
            if (strcmp (drv_id, modules[i].ids[j]) == 0)
 
183
              return;
 
184
          }
 
185
 
 
186
        strcat (modules[i].idlist, " \"");
 
187
        strcat (modules[i].idlist, drv_id);
 
188
        strcat (modules[i].idlist, "\"");
 
189
 
 
190
        if (modules[i].nids < 32)
 
191
          {
 
192
            int n = modules[i].nids++;
 
193
            modules[i].ids[n] = strdup (drv_id);
 
194
          }
 
195
        return;
 
196
      }
 
197
 
 
198
  if (nmodules >= MAX_MODULES)
 
199
    {
 
200
      fprintf (stderr, "Too many OSS modules\n");
 
201
      exit (-1);
 
202
    }
 
203
 
 
204
  modules[nmodules].name = drv->name;
 
205
  modules[nmodules].driver = drv->driver;
 
206
  sprintf (modules[nmodules].idlist, "\"%s\"", drv_id);
 
207
  modules[nmodules].nids = 1;
 
208
  modules[nmodules].ids[0] = strdup (drv_id);
 
209
  modules[nmodules].pass = 0;
 
210
 
 
211
/*
 
212
 * Hot-pluggable modules should be loaded after other modules.
 
213
 */
 
214
  if (strcmp (drv->driver, "oss_usb") == 0)
 
215
    modules[nmodules].pass = 1;
 
216
 
 
217
  nmodules++;
 
218
}
 
219
 
 
220
static void
 
221
find_and_install_driver (char *key)
 
222
{
 
223
 
 
224
  int i;
 
225
 
 
226
  for (i = 0; i < ndrivers; i++)
 
227
    if (strcmp (drivers[i].key, key) == 0)
 
228
      {
 
229
        if (verbose > 0)
 
230
          printf ("\nDetected %s: %s (driver=%s)\n",
 
231
                  key, drivers[i].name, drivers[i].driver);
 
232
        install_driver (&drivers[i], key);
 
233
        return;
 
234
      }
 
235
}
 
236
 
 
237
static int
 
238
check_name (char *key, char *realname)
 
239
{
 
240
  int i;
 
241
 
 
242
  if (realname == NULL)
 
243
    realname = key;
 
244
 
 
245
  for (i = 0; i < ndrivers; i++)
 
246
    if (strcmp (drivers[i].key, key) == 0)
 
247
      {
 
248
        if (verbose > 0)
 
249
          printf ("\nDetected %s: %s (driver=%s)\n",
 
250
                  realname, drivers[i].name, drivers[i].driver);
 
251
        /*      install_driver(&drivers[i], realname); */
 
252
        install_driver (&drivers[i], key);
 
253
        return 1;
 
254
      }
 
255
  return 0;
 
256
}
 
257
 
 
258
static int
 
259
check_node (di_node_t node, int level, char *realname)
 
260
{
 
261
  int j, ok = 0;
 
262
 
 
263
  while (node != DI_NODE_NIL)
 
264
    {
 
265
      char *name = di_node_name (node), *p;
 
266
      char *cnames;
 
267
      int n, i;
 
268
 
 
269
      cnames = "?";
 
270
 
 
271
      if (verbose > 1)
 
272
        {
 
273
          for (j = 1; j < level; j++)
 
274
            printf ("\t");
 
275
          printf ("%s ", name);
 
276
        }
 
277
 
 
278
      /* if (realname==NULL) */
 
279
      {
 
280
        realname = name;
 
281
      }
 
282
 
 
283
      if (check_name (name, realname))
 
284
        {
 
285
          if (verbose > 1)
 
286
            {
 
287
              char *drv = di_driver_name (node);
 
288
              char *bnd = di_binding_name (node);
 
289
              if (drv == NULL)
 
290
                drv = "";
 
291
              if (bnd == NULL)
 
292
                bnd = "";
 
293
              printf ("*match (driver=%s, binding=%s, instance=%d)*", drv,
 
294
                      bnd, di_instance (node));
 
295
            }
 
296
          ok = 1;
 
297
        }
 
298
 
 
299
      if (verbose > 1)
 
300
        printf ("\n");
 
301
 
 
302
      n = di_compatible_names (node, &cnames);
 
303
      p = cnames;
 
304
      for (i = 0; i < n; i++)
 
305
        if (!ok)
 
306
          {
 
307
            if (verbose > 1)
 
308
              {
 
309
                for (j = 1; j < level; j++)
 
310
                  printf ("\t");
 
311
                printf (" = %s ", p);
 
312
              }
 
313
 
 
314
            if (check_name (p, realname))
 
315
              {
 
316
                if (verbose > 1)
 
317
                  {
 
318
                    char *drv = di_driver_name (node);
 
319
                    char *bnd = di_binding_name (node);
 
320
                    if (drv == NULL)
 
321
                      drv = "";
 
322
                    if (bnd == NULL)
 
323
                      bnd = "";
 
324
                    printf ("*match (driver=%s, binding=%s, instance=%d)*",
 
325
                            drv, bnd, di_instance (node));
 
326
                  }
 
327
                ok = 1;
 
328
              }
 
329
 
 
330
            if (verbose > 1)
 
331
              printf ("\n");
 
332
            p = p + strlen (p) + 1;
 
333
          }
 
334
 
 
335
      if (ok)
 
336
        {                       /* Handle properties */
 
337
          di_prop_t prop = DI_PROP_NIL;
 
338
 
 
339
          while ((prop = di_prop_next (node, prop)) != DI_PROP_NIL)
 
340
            {
 
341
              printf ("\tProp '%s'}n", di_prop_name (prop));
 
342
            }
 
343
        }
 
344
 
 
345
      /* if (!ok) */
 
346
      check_node (di_child_node (node), level + 1, realname);
 
347
 
 
348
      node = di_sibling_node (node);
 
349
    }
 
350
 
 
351
  return ok;
 
352
}
 
353
 
 
354
static void
 
355
load_devlist (const char *fname, int is_3rdparty)
 
356
{
 
357
  FILE *f;
 
358
  char line[256], *p;
 
359
  char *driver, *key, *name;
 
360
 
 
361
  if ((f = fopen (fname, "r")) == NULL)
 
362
    {
 
363
      perror (fname);
 
364
      exit (-1);
 
365
    }
 
366
 
 
367
  while (fgets (line, sizeof (line) - 1, f) != NULL)
 
368
    {
 
369
      p = line;
 
370
      while (*p)
 
371
        {
 
372
          if (*p == '#' || *p == '\n')
 
373
            *p = 0;
 
374
          p++;
 
375
        }
 
376
 
 
377
      /* Drivers with upper case names are unsupported ones */
 
378
      if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
 
379
        continue;
 
380
 
 
381
      driver = line;
 
382
      p = line;
 
383
 
 
384
      while (*p && *p != '\t' && *p != ' ')
 
385
        p++;
 
386
      if (*p)
 
387
        *p++ = 0;
 
388
      key = p;
 
389
 
 
390
/*
 
391
 * PCI subvendor ID's are marked as pcsNN,MM in devices.list. Convert them
 
392
 * to pciNN,MM for Solaris
 
393
 */
 
394
      if (strncmp (key, "pcs", 3) == 0)
 
395
        key[2] = 'i';
 
396
 
 
397
      while (*p && *p != '\t')
 
398
        p++;
 
399
      if (*p)
 
400
        *p++ = 0;
 
401
      name = p;
 
402
 
 
403
      if (verbose > 1)
 
404
        printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
 
405
 
 
406
      if (ndrivers >= MAX_DRIVERS)
 
407
        {
 
408
          printf ("Too many drivers defined in drivers.list\n");
 
409
          exit (-1);
 
410
        }
 
411
 
 
412
      drivers[ndrivers].key = strdup (key);
 
413
      drivers[ndrivers].driver = strdup (driver);
 
414
      drivers[ndrivers].name = strdup (name);
 
415
      drivers[ndrivers].is_3rdparty = is_3rdparty;
 
416
      drivers[ndrivers].reload = 0;
 
417
 
 
418
      ndrivers++;
 
419
    }
 
420
 
 
421
  fclose (f);
 
422
}
 
423
 
 
424
static void
 
425
check_conf (char *modname, int is_virtual, char *options)
 
426
{
 
427
  char fname[256], drivername[256];
 
428
  struct stat st;
 
429
  FILE *f;
 
430
 
 
431
#ifdef sparc
 
432
  sprintf (fname, "/kernel/drv/%s.conf", modname);
 
433
  sprintf (drivername, "/kernel/drv/%s%s", arch, modname);
 
434
#else
 
435
  sprintf (fname, "/kernel/drv/%s.conf", modname);
 
436
  sprintf (drivername, "/kernel/drv/%s%s", arch, modname);
 
437
#endif
 
438
 
 
439
  /* fprintf(start_script, "/usr/sbin/modload %s\n", drivername); */
 
440
 
 
441
  if (!use_force)
 
442
    if (stat (fname, &st) != -1)        /* File already exists */
 
443
      return;
 
444
    else
 
445
      fprintf (stderr, "\n\nWarning! Config file %s was missing!\n\n", fname);
 
446
 
 
447
  if ((f = fopen (fname, "w")) == NULL)
 
448
    {
 
449
      perror (fname);
 
450
      exit (-1);
 
451
    }
 
452
  fprintf (f, "# Open Sound System configuration file\n");
 
453
 
 
454
  if (is_virtual)
 
455
    fprintf (f, "name=\"%s\" parent=\"pseudo\" instance=0%s;\n", modname,
 
456
             options);
 
457
  else
 
458
    fprintf (f, "interrupt-priorities=9%s;\n", options);
 
459
 
 
460
  fclose (f);
 
461
}
 
462
 
 
463
static void
 
464
load_name_to_major (void)
 
465
{
 
466
  FILE *f;
 
467
  char line[256], *p;
 
468
 
 
469
  if ((f = fopen ("/etc/name_to_major", "r")) == NULL)
 
470
    return;
 
471
 
 
472
  while (fgets (line, sizeof (line), f) != NULL)
 
473
    {
 
474
      p = line;
 
475
 
 
476
      while (*p && *p != ' ')
 
477
        p++;
 
478
      *p = '\0';
 
479
 
 
480
      if (*line == '\0') continue;
 
481
 
 
482
      if (nmods < MAX_MODS)
 
483
        {
 
484
          installed_modules[nmods++] = strdup (line);
 
485
        }
 
486
 
 
487
/*
 
488
 * Force reinstall of imux if it is currently installed in the system
 
489
 */
 
490
      if (strcmp (line, "oss_imux") == 0)
 
491
        install_imux = 1;
 
492
      if (strcmp (line, "oss_userdev") == 0)
 
493
        install_userdev = 1;
 
494
    }
 
495
 
 
496
  fclose (f);
 
497
}
 
498
 
 
499
static int
 
500
add_drv (char *name, char *drv, char *parms)
 
501
{
 
502
  char tmp[512];
 
503
  int ret;
 
504
 
 
505
  printf ("add_drv %s%s %s\n", safe_mode, parms, drv);
 
506
  sprintf (tmp, "add_drv %s%s %s", safe_mode, parms, drv);
 
507
 
 
508
  ret = system (tmp);
 
509
 
 
510
  if (ret != 0)
 
511
    fprintf (stderr, "%s\n", tmp);
 
512
 
 
513
  /* save the driver and name info in installed_drivers file except osscore */
 
514
  if (name != NULL)
 
515
    fprintf (drivers_f, "%s #%s\n", drv, name);
 
516
 
 
517
  return ret;
 
518
}
 
519
 
 
520
static void
 
521
load_license (char *fname)
 
522
{
 
523
  struct stat st;
 
524
  char cmd[256];
 
525
 
 
526
  if (stat (fname, &st) == -1)
 
527
    return;                     /* Doesn't exist */
 
528
 
 
529
  if (stat ("/usr/sbin/osslic", &st) == -1)
 
530
    return;                     /* No osslic utility in the system. No need to install license. */
 
531
 
 
532
  sprintf (cmd, "/usr/sbin/osslic -q %s", fname);
 
533
  system (cmd);
 
534
}
 
535
 
 
536
static void
 
537
forceload_drivers (char *fname)
 
538
{
 
539
  FILE *f;
 
540
  char line[256], *p;
 
541
 
 
542
  if ((f = fopen (fname, "r")) == NULL)
 
543
    return;
 
544
 
 
545
  while (fgets (line, sizeof (line), f) != NULL)
 
546
    {
 
547
      p = strchr (line, '\n');
 
548
      if (p) *p = '\0';
 
549
      find_and_install_driver (line);
 
550
    }
 
551
}
 
552
 
 
553
int
 
554
main (int argc, char *argv[])
 
555
{
 
556
  int i, pass, c;
 
557
  di_node_t root_node;
 
558
  char tmp[256];
 
559
  struct stat st;
 
560
  FILE *ptr;
 
561
  int pid;
 
562
  char *cmd = "/usr/sbin/modinfo | grep osscommon";
 
563
 
 
564
#if 0
 
565
  if (sysinfo (SI_ARCHITECTURE_K, tmp, sizeof (tmp)) == -1)
 
566
    {
 
567
      perror ("sysinfo SI_ARCHITECTURE_K");
 
568
      exit (-1);
 
569
    }
 
570
#else
 
571
  if (sysinfo (SI_ARCHITECTURE, tmp, sizeof (tmp)) == -1)
 
572
    {
 
573
      perror ("sysinfo SI_ARCHITECTURE");
 
574
      exit (-1);
 
575
    }
 
576
#endif
 
577
 
 
578
  load_name_to_major ();
 
579
 
 
580
#ifdef sparc
 
581
  if (strcmp (tmp, "sparc") == 0)
 
582
    sprintf (arch, "sparcv9/", tmp);
 
583
#else
 
584
  if (strcmp (tmp, "amd64") == 0)
 
585
    sprintf (arch, "%s/", tmp);
 
586
#endif
 
587
 
 
588
  while ((c = getopt (argc, argv, "vfiudlVS")) != EOF)
 
589
      switch (c)
 
590
        {
 
591
        case 'v':
 
592
          verbose++;
 
593
          break;
 
594
        case 'f':
 
595
          use_force = 1;
 
596
          break;
 
597
        case 'S': /* Safe mode */
 
598
          safe_mode="-n ";
 
599
          break;
 
600
        case 'i':
 
601
          install_imux = 1;
 
602
          break;
 
603
        case 'u':
 
604
          install_userdev = 1;
 
605
          break;
 
606
        case 'd': /* Obolete under Solaris. */
 
607
          exit (0);
 
608
          break;
 
609
        case 'l':
 
610
          load_license ("/etc/oss/license.asc");
 
611
          exit (0);
 
612
          break;
 
613
        }
 
614
 
 
615
  load_license ("/etc/oss/license.asc");
 
616
 
 
617
  load_devlist ("/etc/oss/devices.list", 0);
 
618
 
 
619
  if ((drivers_f = fopen ("/etc/oss/installed_drivers", "w")) == NULL)
 
620
    {
 
621
      perror ("/etc/oss/installed_drivers");
 
622
      exit (-1);
 
623
    }
 
624
 
 
625
  if (stat ("/etc/oss_3rdparty", &st) != -1)
 
626
    load_devlist ("/etc/oss_3rdparty", 1);
 
627
 
 
628
  if ((root_node = di_init ("/", DINFOSUBTREE)) == DI_NODE_NIL)
 
629
    {
 
630
      printf ("di_init() failed\n");
 
631
    }
 
632
 
 
633
  check_node (root_node, 0, NULL);
 
634
 
 
635
  di_fini (root_node);
 
636
 
 
637
  /*
 
638
   * Force unconditional loading of the USB driver and few others to make
 
639
   * hotplugging possible.
 
640
   */
 
641
  forceload_drivers ("/etc/oss/forceload.conf");
 
642
 
 
643
  if (verbose > 3)
 
644
    {
 
645
      for (i = 0; i < nmodules; i++)
 
646
        {
 
647
          printf ("Would add %s -i '%s'\n", modules[i].driver,
 
648
                  modules[i].idlist);
 
649
        }
 
650
      printf ("Skipping actual device installation\n");
 
651
      exit (0);
 
652
    }
 
653
 
 
654
  sync ();
 
655
 
 
656
/*
 
657
 * Unload drivers that appear to be loaded
 
658
 */
 
659
  for (i = 0; i < nmods; i++)
 
660
    {
 
661
      int j, ok = 0;
 
662
 
 
663
      for (j = 0; j < ndrivers && !ok; j++)
 
664
        {
 
665
          if (strcmp (installed_modules[i], drivers[j].driver) == 0)
 
666
            {
 
667
              ok = 1;
 
668
              if (strcmp (drivers[j].key, "$PSEUDO") == 0 ||
 
669
                  drivers[j].is_3rdparty)
 
670
                {
 
671
                  if (drivers[j].is_3rdparty)
 
672
                    printf ("Removed 3rd party driver %s\n",
 
673
                            drivers[j].driver);
 
674
                  drivers[j].reload = 1;
 
675
                }
 
676
            }
 
677
        }
 
678
 
 
679
      if (!ok)
 
680
        continue;
 
681
 
 
682
      sprintf (tmp, "rem_drv %s\n", installed_modules[i]);
 
683
      printf ("rem_drv %s\n", installed_modules[i]);
 
684
      system (tmp);
 
685
      sync ();
 
686
    }
 
687
 
 
688
#if 0
 
689
/*
 
690
 * Tell the osscore module to go away by writing something to /dev/sndstat
 
691
 * (at this moment it doesn't matter what is written).
 
692
 */
 
693
 
 
694
  system ("rem_drv osscore");
 
695
  sync ();
 
696
#endif
 
697
 
 
698
  /* Find the osscommon module's PID and pass it to moduload to unload it */
 
699
  if ((ptr = popen (cmd, "r")) != NULL)
 
700
    {
 
701
      if (fscanf (ptr, "%d", &pid) == 1 && pid > 0)
 
702
        {
 
703
          sprintf (tmp, "modunload -i %d", pid);
 
704
          fprintf (stderr, "unloaded osscommon\n");
 
705
          system (tmp);
 
706
        }
 
707
      pclose (ptr);
 
708
    }
 
709
 
 
710
 
 
711
/* Now start loading all the modules */
 
712
  check_conf ("osscore", 1, "");
 
713
 
 
714
  if (add_drv ("OSS Core Devices", "osscore", "-m '* 0666 root sys'") != 0)
 
715
    {
 
716
      fprintf (stderr, "Installing OSS (osscore) failed\n");
 
717
      exit (256);
 
718
    }
 
719
 
 
720
  for (pass = 0; pass < 2; pass++)
 
721
    for (i = 0; i < nmodules; i++)
 
722
      if (modules[i].pass == pass)
 
723
        {
 
724
          check_conf (modules[i].driver, 0, "");
 
725
          sprintf (tmp, "-m '* 0666 root sys' -i '%s'", modules[i].idlist);
 
726
          if (add_drv (modules[i].name, modules[i].driver, tmp) != 0)
 
727
            {
 
728
              fprintf (stderr, "Installing OSS (%s) failed\n",
 
729
                       modules[i].driver);
 
730
              exit (256);
 
731
            }
 
732
        }
 
733
 
 
734
  if (install_imux)
 
735
    {
 
736
      check_conf ("oss_imux", 1, "");
 
737
      add_drv ("OSS Input Multiplexer", "oss_imux", "-m '* 0666 root sys'");
 
738
    }
 
739
 
 
740
  if (install_userdev)
 
741
    {
 
742
      check_conf ("oss_userdev", 1, "");
 
743
      add_drv ("OSS User space device driver", "oss_userdev", "-m '* 0666 root sys'");
 
744
    }
 
745
 
 
746
#ifdef sparc
 
747
  if (stat("/kernel/drv/sparcv9/oss_sadasupport", &st) != -1)
 
748
    if (stat("/kernel/misc/sparcv9/audiosup", &st) != -1)
 
749
#else
 
750
  if (stat("/kernel/drv/oss_sadasupport", &st) != -1)
 
751
    if (stat("/kernel/misc/audiosup", &st) != -1)
 
752
#endif
 
753
     {
 
754
        check_conf ("oss_sadasupport", 1, "");
 
755
        add_drv ("SADA emulation layer", "oss_sadasupport", "-m '* 0666 root sys'");
 
756
     }
 
757
 
 
758
  for (i = 0; i < ndrivers; i++)
 
759
    if (drivers[i].reload)
 
760
      if (!drivers[i].is_3rdparty)
 
761
        {
 
762
          check_conf (drivers[i].driver, 1, "");
 
763
          add_drv (drivers[i].name, drivers[i].driver,
 
764
                   "-m '* 0666 root sys'");
 
765
        }
 
766
      else
 
767
        {
 
768
          char parms[1024];
 
769
 
 
770
          if (strcmp (drivers[i].key, "$PSEUDO") == 0)
 
771
            {
 
772
              add_drv (drivers[i].name, drivers[i].driver,
 
773
                       "-m '* 0666 root sys'");
 
774
              continue;
 
775
            }
 
776
 
 
777
          sprintf (parms, "-i '%s' -m '* 0666 root sys'", drivers[i].key);
 
778
          printf ("Attempting to reload %s\n", drivers[i].driver);
 
779
          add_drv (drivers[i].name, drivers[i].driver, parms);
 
780
        }
 
781
 
 
782
/*
 
783
 * Reload the previous default settings if they were ever saved.
 
784
 */
 
785
  if (stat ("/etc/oss/mixer.save", &st) != -1 ||
 
786
      stat ("/etc/oss/dspdevs.map", &st) != -1)
 
787
    system ("savemixer -L");
 
788
 
 
789
  fclose (drivers_f);
 
790
#if 0
 
791
  sync ();
 
792
  printf ("Restarting OSS - Please wait\r");
 
793
  fflush (stdout);
 
794
  system ("soundoff");
 
795
  system ("soundon");
 
796
  printf ("\n");
 
797
#endif
 
798
  return 0;
 
799
}