* Since the device hooks can actually change when the driver is
republished, we now update them. * This fixes occasional crashes with reloaded/repulished drivers. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24237 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -159,6 +159,8 @@ class DriverWatcher : public NotificationListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static status_t get_node_for_path(struct devfs *fs, const char *path,
|
||||||
|
struct devfs_vnode **_node);
|
||||||
static void get_device_name(struct devfs_vnode *vnode, char *buffer,
|
static void get_device_name(struct devfs_vnode *vnode, char *buffer,
|
||||||
size_t size);
|
size_t size);
|
||||||
static status_t unpublish_node(struct devfs *fs, devfs_vnode *node,
|
static status_t unpublish_node(struct devfs *fs, devfs_vnode *node,
|
||||||
@@ -267,14 +269,23 @@ republish_driver(driver_entry *driver)
|
|||||||
entry = currentNodes.GetNext(entry);
|
entry = currentNodes.GetNext(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (present)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// the device was not present before -> publish it now
|
|
||||||
device_hooks *hooks = driver->find_device(devicePaths[0]);
|
device_hooks *hooks = driver->find_device(devicePaths[0]);
|
||||||
if (hooks == NULL)
|
if (hooks == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (present) {
|
||||||
|
// update hooks
|
||||||
|
devfs_vnode *vnode;
|
||||||
|
status_t status = get_node_for_path(sDeviceFileSystem,
|
||||||
|
devicePaths[0], &vnode);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
vnode->stream.u.dev.ops = hooks;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the device was not present before -> publish it now
|
||||||
TRACE(("devfs: publishing new device \"%s\"\n", devicePaths[0]));
|
TRACE(("devfs: publishing new device \"%s\"\n", devicePaths[0]));
|
||||||
if (publish_device(sDeviceFileSystem, devicePaths[0], NULL, NULL,
|
if (publish_device(sDeviceFileSystem, devicePaths[0], NULL, NULL,
|
||||||
driver, hooks, driver->api_version) == B_OK)
|
driver, hooks, driver->api_version) == B_OK)
|
||||||
@@ -1334,7 +1345,8 @@ get_device_name(struct devfs_vnode *vnode, char *buffer, size_t size)
|
|||||||
|
|
||||||
// construct full path name
|
// construct full path name
|
||||||
|
|
||||||
for (vnode = leaf; vnode->parent && vnode->parent != vnode; vnode = vnode->parent) {
|
for (vnode = leaf; vnode->parent && vnode->parent != vnode;
|
||||||
|
vnode = vnode->parent) {
|
||||||
size_t length = strlen(vnode->name);
|
size_t length = strlen(vnode->name);
|
||||||
size_t start = offset - length - 1;
|
size_t start = offset - length - 1;
|
||||||
|
|
||||||
@@ -1357,18 +1369,38 @@ dump_node(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct devfs_vnode *vnode = (struct devfs_vnode *)strtoul(argv[1], NULL, 0);
|
struct devfs_vnode *vnode = (struct devfs_vnode *)parse_expression(argv[1]);
|
||||||
if (vnode == NULL) {
|
if (vnode == NULL) {
|
||||||
kprintf("invalid node address\n");
|
kprintf("invalid node address\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("DEVFS NODE: %p\n", vnode);
|
kprintf("DEVFS NODE: %p\n", vnode);
|
||||||
kprintf(" id: %Ld\n", vnode->id);
|
kprintf(" id: %Ld\n", vnode->id);
|
||||||
kprintf(" name: %s\n", vnode->name);
|
kprintf(" name: \"%s\"\n", vnode->name);
|
||||||
kprintf(" type: %x\n", vnode->stream.type);
|
kprintf(" type: %x\n", vnode->stream.type);
|
||||||
kprintf(" parent: %p\n", vnode->parent);
|
kprintf(" parent: %p\n", vnode->parent);
|
||||||
kprintf(" dir_next: %p\n", vnode->dir_next);
|
kprintf(" dir next: %p\n", vnode->dir_next);
|
||||||
|
|
||||||
|
if (S_ISDIR(vnode->stream.type)) {
|
||||||
|
kprintf(" dir scanned: %ld\n", vnode->stream.u.dir.scanned);
|
||||||
|
kprintf(" contents:\n");
|
||||||
|
|
||||||
|
devfs_vnode *children = vnode->stream.u.dir.dir_head;
|
||||||
|
while (children != NULL) {
|
||||||
|
kprintf(" %p, id %Ld\n", children, children->id);
|
||||||
|
children = children->dir_next;
|
||||||
|
}
|
||||||
|
} else if (S_ISLNK(vnode->stream.type)) {
|
||||||
|
kprintf(" symlink to: %s\n", vnode->stream.u.symlink.path);
|
||||||
|
} else {
|
||||||
|
kprintf(" device node: %p\n", vnode->stream.u.dev.node);
|
||||||
|
kprintf(" driver info: %p\n", vnode->stream.u.dev.info);
|
||||||
|
kprintf(" hooks: %p\n", vnode->stream.u.dev.ops);
|
||||||
|
kprintf(" partition: %p\n", vnode->stream.u.dev.partition);
|
||||||
|
kprintf(" scheduler: %p\n", vnode->stream.u.dev.scheduler);
|
||||||
|
kprintf(" driver: %p\n", vnode->stream.u.dev.driver);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user