* Got rid of devfs_cookie::stream. It was superfluous since one can
always also access it through the devfs_vnode. This also solves an issue in devfs_read() where an access of a cookie->stream would crash the kernel, since cookie->stream was not set in devfs_open(). * devfs_open() now doesn't fail for directories and symlinks anymore. That prevented BNode to work for devfs dirs and symlinks. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8897 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -91,7 +91,6 @@ struct devfs {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct devfs_cookie {
|
struct devfs_cookie {
|
||||||
struct devfs_stream *stream;
|
|
||||||
int oflags;
|
int oflags;
|
||||||
union {
|
union {
|
||||||
struct cookie_dir {
|
struct cookie_dir {
|
||||||
@@ -811,14 +810,16 @@ devfs_open(fs_volume _fs, fs_vnode _vnode, int openMode, fs_cookie *_cookie)
|
|||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (vnode->stream.type != STREAM_TYPE_DEVICE)
|
if (vnode->stream.type == STREAM_TYPE_DEVICE) {
|
||||||
return B_BAD_VALUE;
|
if (vnode->stream.u.dev.node != NULL) {
|
||||||
|
status = vnode->stream.u.dev.info->open(
|
||||||
if (vnode->stream.u.dev.node != NULL) {
|
vnode->stream.u.dev.node->parent->cookie, openMode,
|
||||||
status = vnode->stream.u.dev.info->open(vnode->stream.u.dev.node->parent->cookie,
|
&cookie->u.dev.dcookie);
|
||||||
openMode, &cookie->u.dev.dcookie);
|
} else {
|
||||||
} else
|
status = vnode->stream.u.dev.ops->open(vnode->name, openMode,
|
||||||
status = vnode->stream.u.dev.ops->open(vnode->name, openMode, &cookie->u.dev.dcookie);
|
&cookie->u.dev.dcookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
|
|
||||||
@@ -877,13 +878,8 @@ devfs_read(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, off_t pos,
|
|||||||
|
|
||||||
TRACE(("devfs_read: vnode %p, cookie %p, pos %Ld, len %p\n", vnode, cookie, pos, _length));
|
TRACE(("devfs_read: vnode %p, cookie %p, pos %Ld, len %p\n", vnode, cookie, pos, _length));
|
||||||
|
|
||||||
// Whoa! If the next to lines are uncommented, our kernel crashes at some point
|
if (vnode->stream.type != STREAM_TYPE_DEVICE)
|
||||||
// I haven't yet found the time to investigate, but I'll doubtlessly have to do
|
return B_BAD_VALUE;
|
||||||
// that at some point -- axeld.
|
|
||||||
//if (cookie->stream->type != STREAM_TYPE_DEVICE)
|
|
||||||
// return EINVAL;
|
|
||||||
//if (vnode->stream.type != STREAM_TYPE_DEVICE)
|
|
||||||
// return B_BAD_VALUE;
|
|
||||||
|
|
||||||
if (vnode->stream.u.dev.part_map)
|
if (vnode->stream.u.dev.part_map)
|
||||||
translate_partition_access(vnode->stream.u.dev.part_map, pos, *_length);
|
translate_partition_access(vnode->stream.u.dev.part_map, pos, *_length);
|
||||||
@@ -964,7 +960,6 @@ devfs_open_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie *_cookie)
|
|||||||
|
|
||||||
mutex_lock(&fs->lock);
|
mutex_lock(&fs->lock);
|
||||||
|
|
||||||
cookie->stream = &vnode->stream;
|
|
||||||
cookie->u.dir.ptr = vnode->stream.u.dir.dir_head;
|
cookie->u.dir.ptr = vnode->stream.u.dir.dir_head;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
|
|
||||||
@@ -976,13 +971,14 @@ devfs_open_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie *_cookie)
|
|||||||
static status_t
|
static status_t
|
||||||
devfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent *dirent, size_t bufferSize, uint32 *_num)
|
devfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent *dirent, size_t bufferSize, uint32 *_num)
|
||||||
{
|
{
|
||||||
|
struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode;
|
||||||
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
||||||
struct devfs *fs = (struct devfs *)_fs;
|
struct devfs *fs = (struct devfs *)_fs;
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
TRACE(("devfs_read_dir: vnode %p, cookie %p, buffer %p, size %ld\n", _vnode, cookie, dirent, bufferSize));
|
TRACE(("devfs_read_dir: vnode %p, cookie %p, buffer %p, size %ld\n", _vnode, cookie, dirent, bufferSize));
|
||||||
|
|
||||||
if (cookie->stream->type != STREAM_TYPE_DIR)
|
if (vnode->stream.type != STREAM_TYPE_DIR)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
mutex_lock(&fs->lock);
|
mutex_lock(&fs->lock);
|
||||||
@@ -1018,17 +1014,18 @@ err:
|
|||||||
static status_t
|
static status_t
|
||||||
devfs_rewind_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie)
|
devfs_rewind_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie)
|
||||||
{
|
{
|
||||||
|
struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode;
|
||||||
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
struct devfs_cookie *cookie = (struct devfs_cookie *)_cookie;
|
||||||
struct devfs *fs = (struct devfs *)_fs;
|
struct devfs *fs = (struct devfs *)_fs;
|
||||||
|
|
||||||
TRACE(("devfs_rewind_dir: vnode %p, cookie %p\n", _vnode, _cookie));
|
TRACE(("devfs_rewind_dir: vnode %p, cookie %p\n", _vnode, _cookie));
|
||||||
|
|
||||||
if (cookie->stream->type != STREAM_TYPE_DIR)
|
if (vnode->stream.type != STREAM_TYPE_DIR)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
mutex_lock(&fs->lock);
|
mutex_lock(&fs->lock);
|
||||||
|
|
||||||
cookie->u.dir.ptr = cookie->stream->u.dir.dir_head;
|
cookie->u.dir.ptr = vnode->stream.u.dir.dir_head;
|
||||||
|
|
||||||
mutex_unlock(&fs->lock);
|
mutex_unlock(&fs->lock);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user