* BaseDevice didn't initialize the fInitialized member, and thus causing bug
#2265. * Device::InitDevice()/UninitDevice() are called from outside of the device manager, so they better lock it. * Turned off debug output in devfs and the device manager. * Fixed debug output in devfs to print the actual vnode/cookie values, instead of the structures the VFS passes in now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25670 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
BaseDevice::BaseDevice()
|
BaseDevice::BaseDevice()
|
||||||
:
|
:
|
||||||
fNode(NULL),
|
fNode(NULL),
|
||||||
|
fInitialized(0),
|
||||||
fDeviceModule(NULL),
|
fDeviceModule(NULL),
|
||||||
fDeviceData(NULL)
|
fDeviceData(NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include "legacy_drivers.h"
|
#include "legacy_drivers.h"
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_DEVFS
|
//#define TRACE_DEVFS
|
||||||
#ifdef TRACE_DEVFS
|
#ifdef TRACE_DEVFS
|
||||||
# define TRACE(x) dprintf x
|
# define TRACE(x) dprintf x
|
||||||
#else
|
#else
|
||||||
@@ -1140,12 +1140,11 @@ devfs_open(fs_volume* _volume, fs_vnode* _vnode, int openMode,
|
|||||||
struct devfs_cookie* cookie;
|
struct devfs_cookie* cookie;
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
TRACE(("devfs_open: vnode %p, openMode 0x%x, fs_cookie %p \n", vnode, openMode, _cookie));
|
|
||||||
|
|
||||||
cookie = (struct devfs_cookie*)malloc(sizeof(struct devfs_cookie));
|
cookie = (struct devfs_cookie*)malloc(sizeof(struct devfs_cookie));
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
TRACE(("devfs_open: vnode %p, openMode 0x%x, cookie %p\n", vnode, openMode, cookie));
|
||||||
cookie->device_cookie = NULL;
|
cookie->device_cookie = NULL;
|
||||||
|
|
||||||
if (S_ISCHR(vnode->stream.type)) {
|
if (S_ISCHR(vnode->stream.type)) {
|
||||||
@@ -1484,7 +1483,7 @@ devfs_rewind_dir(fs_volume *_volume, fs_vnode *_vnode, void *_cookie)
|
|||||||
struct devfs_dir_cookie *cookie = (devfs_dir_cookie *)_cookie;
|
struct devfs_dir_cookie *cookie = (devfs_dir_cookie *)_cookie;
|
||||||
struct devfs *fs = (struct devfs *)_volume->private_volume;
|
struct devfs *fs = (struct devfs *)_volume->private_volume;
|
||||||
|
|
||||||
TRACE(("devfs_rewind_dir: vnode %p, cookie %p\n", _vnode, _cookie));
|
TRACE(("devfs_rewind_dir: vnode %p, cookie %p\n", vnode, cookie));
|
||||||
|
|
||||||
if (!S_ISDIR(vnode->stream.type))
|
if (!S_ISDIR(vnode->stream.type))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1510,7 +1509,7 @@ devfs_ioctl(fs_volume *_volume, fs_vnode *_vnode, void *_cookie, ulong op,
|
|||||||
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
||||||
|
|
||||||
TRACE(("devfs_ioctl: vnode %p, cookie %p, op %ld, buf %p, len %ld\n",
|
TRACE(("devfs_ioctl: vnode %p, cookie %p, op %ld, buf %p, len %ld\n",
|
||||||
_vnode, _cookie, op, buffer, length));
|
vnode, cookie, op, buffer, length));
|
||||||
|
|
||||||
// we are actually checking for a *device* here, we don't make the
|
// we are actually checking for a *device* here, we don't make the
|
||||||
// distinction between char and block devices
|
// distinction between char and block devices
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "io_resources.h"
|
#include "io_resources.h"
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_DEVICE_MANAGER
|
//#define TRACE_DEVICE_MANAGER
|
||||||
#ifdef TRACE_DEVICE_MANAGER
|
#ifdef TRACE_DEVICE_MANAGER
|
||||||
# define TRACE(a) dprintf a
|
# define TRACE(a) dprintf a
|
||||||
#else
|
#else
|
||||||
@@ -1000,6 +1000,8 @@ Device::InitCheck() const
|
|||||||
status_t
|
status_t
|
||||||
Device::InitDevice()
|
Device::InitDevice()
|
||||||
{
|
{
|
||||||
|
RecursiveLocker _(sLock);
|
||||||
|
|
||||||
if ((fNode->Flags() & NODE_FLAG_DEVICE_REMOVED) != 0) {
|
if ((fNode->Flags() & NODE_FLAG_DEVICE_REMOVED) != 0) {
|
||||||
// TODO: maybe the device should be unlinked in devfs, too
|
// TODO: maybe the device should be unlinked in devfs, too
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
@@ -1042,6 +1044,8 @@ Device::InitDevice()
|
|||||||
void
|
void
|
||||||
Device::UninitDevice()
|
Device::UninitDevice()
|
||||||
{
|
{
|
||||||
|
RecursiveLocker _(sLock);
|
||||||
|
|
||||||
if (fInitialized-- > 1) {
|
if (fInitialized-- > 1) {
|
||||||
fNode->UninitDriver();
|
fNode->UninitDriver();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user