1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/***************************************************************************
*
* osspec.c : NetBSD HAL backend entry points
*
* Copyright 2008 Jared D. McNeill <jmcneill@NetBSD.org>
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/statvfs.h>
#include "../osspec.h"
#include "../logger.h"
#include "../hald.h"
#include "../hald_dbus.h"
#include "../device_info.h"
#include "../util.h"
#include "../ids.h"
#include "osspec_netbsd.h"
#include "hotplug.h"
#include "drvctl.h"
#include "devinfo.h"
#include "devinfo_storage.h"
static void mntinfo_event_init ();
static gboolean mntinfo_timeout (gpointer user_data);
HalFileMonitor *
osspec_get_file_monitor (void)
{
#warning Please implement
return NULL;
}
void
osspec_init (void)
{
ids_init ();
mntinfo_event_init ();
}
void
osspec_privileged_init (void)
{
drvctl_init ();
}
void
hotplug_queue_now_empty (void)
{
if (hald_is_initialising) {
osspec_probe_done ();
}
}
void
osspec_probe (void)
{
/* add entire device tree */
devinfo_add (NULL, "mainbus0");
/* start processing events */
hotplug_event_process_queue ();
}
gboolean
osspec_device_rescan (HalDevice *d)
{
return (devinfo_device_rescan (d));
}
gboolean
osspec_device_reprobe (HalDevice *d)
{
return FALSE;
}
DBusHandlerResult
osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
/**
* hal_util_find_closest_ancestor:
* @devfs_path: Path into devfs, e.g. /pci@0,0/pci1025,57@10,2/storage@1
*
* Returns: Parent Hal Device Object or #NULL if there is none
*
* Find the closest ancestor by looking at devfs paths
*/
HalDevice *
hal_util_find_closest_ancestor (const gchar *devfs_path, gchar **ancestor_devfs_path, gchar **hotplug_devfs_path)
{
gchar buf[512];
gchar c;
HalDevice *parent;
parent = NULL;
if (drvctl_find_parent (devfs_path, buf) == FALSE)
return NULL;
HAL_INFO (("hal_util_find_closest_ancestor: devnode=%s parent=%s\n", devfs_path, buf));
parent = hal_device_store_match_key_value_string (hald_get_gdl (),
"netbsd.device",
buf);
if (parent != NULL) {
if (ancestor_devfs_path != NULL) {
*ancestor_devfs_path = g_strdup (buf);
}
if (hotplug_devfs_path != NULL) {
*hotplug_devfs_path = g_strdup (buf);
}
}
return parent;
}
char *
dsk_to_rdsk(char *dsk)
{
int len, pos;
char *p;
char *rdsk;
if ((len = strlen (dsk)) < sizeof ("/dev/AANA") - 1) {
return (strdup(""));
}
p = strstr (dsk, "/dev/");
if (p == NULL) {
return (strdup(""));
}
pos = (uintptr_t)p - (uintptr_t)dsk;
if ((rdsk = (char *)calloc (len + 2, 1)) != NULL) {
strncpy (rdsk, dsk, pos + 1);
rdsk[pos + 1] = 'r';
strcpy (rdsk + pos + 2, dsk + pos + 1);
}
return (rdsk);
}
/*
* Setup to watch mntinfo changes
*/
static void
mntinfo_event_init ()
{
#if notyet
g_timeout_add(1000, mntinfo_timeout, NULL);
#endif
}
static gboolean
mntinfo_timeout (gpointer user_data)
{
#if notyet
struct statvfs *statvfs;
HAL_INFO (("mntinfo timeout"));
if (!hald_is_initialising) {
devinfo_storage_mnttab_event (NULL);
}
#endif
return TRUE;
}
void
osspec_refresh_mount_state_for_block_device (HalDevice *d)
{
#warning osspec_refresh_mount_state_for_block_device TODO
#if notyet
devinfo_storage_mnttab_event (d);
#endif
}
|