Page MenuHomeFreeBSD

D53621.1789684681.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D53621.1789684681.diff

diff --git a/usr.sbin/virtual_oss/virtual_oss/main.c b/usr.sbin/virtual_oss/virtual_oss/main.c
--- a/usr.sbin/virtual_oss/virtual_oss/main.c
+++ b/usr.sbin/virtual_oss/virtual_oss/main.c
@@ -31,6 +31,7 @@
#include <sys/nv.h>
#include <sys/sndstat.h>
#include <sys/soundcard.h>
+#include <sys/sysctl.h>
#include <dlfcn.h>
#include <errno.h>
@@ -52,6 +53,8 @@
#include "int.h"
#include "virtual_oss.h"
+#define SYSCTL_BASECLONE "hw.snd.basename_clone"
+
pthread_mutex_t atomic_mtx;
pthread_cond_t atomic_cv;
@@ -1617,6 +1620,7 @@
static int voss_dsp_perm = 0666;
static int voss_do_background;
+static int voss_baseclone = 0;
static const char *voss_pid_path;
uint32_t voss_dsp_rx_refresh;
@@ -1883,8 +1887,16 @@
* Detect /dev/dsp creation and try to disable system
* basename cloning automatically:
*/
- if (strcmp(ptr->oss_name, "dsp") == 0)
- system("sysctl hw.snd.basename_clone=0");
+ if (strcmp(ptr->oss_name, "dsp") == 0) {
+ size_t size;
+
+ x = 0;
+ size = sizeof(int);
+ if (sysctlbyname(SYSCTL_BASECLONE, &voss_baseclone,
+ &size, &x, size) < 0)
+ return ("Could not disable " SYSCTL_BASECLONE);
+ printf(SYSCTL_BASECLONE ": %d -> 0\n", voss_baseclone);
+ }
/* create DSP character device */
pdev = cuse_dev_create(&vclient_oss_methods, ptr, NULL,
@@ -2494,6 +2506,20 @@
free(voss_tds);
}
+/*
+ * Restore hw.snd.basename_clone if it was disabled by us.
+ */
+static void
+restore_baseclone(void)
+{
+ if (voss_baseclone) {
+ if (sysctlbyname(SYSCTL_BASECLONE, NULL, NULL, &voss_baseclone,
+ sizeof(int)) < 0)
+ err(1, "Could not enable " SYSCTL_BASECLONE);
+ printf(SYSCTL_BASECLONE ": 0 -> %d\n", voss_baseclone);
+ }
+}
+
void
voss_add_options(char *str)
{
@@ -2557,6 +2583,9 @@
if (sigaction(SIGTERM, &sa, NULL) < 0)
err(1, "sigaction(SIGTERM)");
+ if (atexit(restore_baseclone) < 0)
+ err(1, "Could not set atexit callback");
+
ptrerr = parse_options(argc, argv, 1);
if (ptrerr != NULL)
errx(EX_USAGE, "%s", ptrerr);

File Metadata

Mime Type
text/plain
Expires
Thu, Sep 17, 10:38 PM (6 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29741311
Default Alt Text
D53621.1789684681.diff (1 KB)

Event Timeline