Renamed "calls" to "ops" (yeah, I know, that doesn't make really much sense :).
Completed load_file_system(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
14d32cf634
commit
dd36c5aa04
|
@ -1006,7 +1006,7 @@ bootfs_write_stat(fs_volume _fs, fs_vnode _v, const struct stat *stat, int stat_
|
|||
// #pragma mark -
|
||||
|
||||
|
||||
static struct fs_calls bootfs_calls = {
|
||||
static struct fs_ops bootfs_ops = {
|
||||
&bootfs_mount,
|
||||
&bootfs_unmount,
|
||||
NULL,
|
||||
|
@ -1082,6 +1082,6 @@ bootstrap_bootfs(void)
|
|||
|
||||
dprintf("bootstrap_bootfs: found bootdir at %p\n", bootdir);
|
||||
|
||||
return vfs_register_filesystem("bootfs", &bootfs_calls);
|
||||
return vfs_register_filesystem("bootfs", &bootfs_ops);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ struct devfs_stream {
|
|||
} dir;
|
||||
struct stream_dev {
|
||||
void *ident;
|
||||
device_hooks *calls;
|
||||
device_hooks *ops;
|
||||
struct devfs_part_map *part_map;
|
||||
} dev;
|
||||
struct stream_symlink {
|
||||
|
@ -368,13 +368,13 @@ devfs_set_partition( struct devfs *fs, struct devfs_vnode *v,
|
|||
part_node = devfs_create_vnode(fs, part_name);
|
||||
|
||||
if (part_node == NULL) {
|
||||
res = ENOMEM;
|
||||
res = B_NO_MEMORY;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
part_node->stream.type = STREAM_TYPE_DEVICE;
|
||||
part_node->stream.u.dev.ident = v->stream.u.dev.ident;
|
||||
part_node->stream.u.dev.calls = v->stream.u.dev.calls;
|
||||
part_node->stream.u.dev.ops = v->stream.u.dev.ops;
|
||||
part_node->stream.u.dev.part_map = part_map;
|
||||
|
||||
hash_insert(fs->vnode_list_hash, part_node);
|
||||
|
@ -645,7 +645,7 @@ devfs_open(fs_volume _fs, fs_vnode _v, int oflags, fs_cookie *_cookie)
|
|||
if (vnode->stream.type != STREAM_TYPE_DEVICE)
|
||||
return EINVAL;
|
||||
|
||||
status = vnode->stream.u.dev.calls->open(vnode->name, oflags, &cookie->u.dev.dcookie);
|
||||
status = vnode->stream.u.dev.ops->open(vnode->name, oflags, &cookie->u.dev.dcookie);
|
||||
*_cookie = cookie;
|
||||
|
||||
return status;
|
||||
|
@ -662,7 +662,7 @@ devfs_close(fs_volume _fs, fs_vnode _v, fs_cookie _cookie)
|
|||
|
||||
if (vnode->stream.type == STREAM_TYPE_DEVICE) {
|
||||
// pass the call through to the underlying device
|
||||
return vnode->stream.u.dev.calls->close(cookie->u.dev.dcookie);
|
||||
return vnode->stream.u.dev.ops->close(cookie->u.dev.dcookie);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
|
@ -679,7 +679,7 @@ devfs_free_cookie(fs_volume _fs, fs_vnode _v, fs_cookie _cookie)
|
|||
|
||||
if (vnode->stream.type == STREAM_TYPE_DEVICE) {
|
||||
// pass the call through to the underlying device
|
||||
vnode->stream.u.dev.calls->free(cookie->u.dev.dcookie);
|
||||
vnode->stream.u.dev.ops->free(cookie->u.dev.dcookie);
|
||||
}
|
||||
|
||||
if (cookie)
|
||||
|
@ -725,7 +725,7 @@ devfs_read(fs_volume _fs, fs_vnode _v, fs_cookie _cookie, off_t pos, void *buffe
|
|||
}
|
||||
|
||||
// pass the call through to the device
|
||||
return vnode->stream.u.dev.calls->read(cookie->u.dev.dcookie, pos, buffer, length);
|
||||
return vnode->stream.u.dev.ops->read(cookie->u.dev.dcookie, pos, buffer, length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -752,7 +752,7 @@ devfs_write(fs_volume _fs, fs_vnode _v, fs_cookie _cookie, off_t pos, const void
|
|||
pos += part_map->offset;
|
||||
}
|
||||
|
||||
written = vnode->stream.u.dev.calls->write(cookie->u.dev.dcookie, pos, buf, len);
|
||||
written = vnode->stream.u.dev.ops->write(cookie->u.dev.dcookie, pos, buf, len);
|
||||
return written;
|
||||
}
|
||||
return EINVAL;
|
||||
|
@ -888,7 +888,7 @@ devfs_ioctl(fs_volume _fs, fs_vnode _v, fs_cookie _cookie, ulong op, void *buf,
|
|||
return devfs_set_partition(fs, v, cookie, buf, len);
|
||||
}
|
||||
|
||||
return v->stream.u.dev.calls->control(cookie->u.dev.dcookie, op, buf, len);
|
||||
return v->stream.u.dev.ops->control(cookie->u.dev.dcookie, op, buf, len);
|
||||
}
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -902,9 +902,9 @@ static int devfs_canpage(fs_volume _fs, fs_vnode _v)
|
|||
TRACE(("devfs_canpage: vnode 0x%x\n", v));
|
||||
|
||||
if(v->stream.type == STREAM_TYPE_DEVICE) {
|
||||
if(!v->stream.u.dev.calls->dev_canpage)
|
||||
if(!v->stream.u.dev.ops->dev_canpage)
|
||||
return 0;
|
||||
return v->stream.u.dev.calls->dev_canpage(v->stream.u.dev.ident);
|
||||
return v->stream.u.dev.ops->dev_canpage(v->stream.u.dev.ident);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ static ssize_t devfs_readpage(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t po
|
|||
if(v->stream.type == STREAM_TYPE_DEVICE) {
|
||||
struct devfs_part_map *part_map = v->stream.u.dev.part_map;
|
||||
|
||||
if(!v->stream.u.dev.calls->dev_readpage)
|
||||
if(!v->stream.u.dev.ops->dev_readpage)
|
||||
return ERR_NOT_ALLOWED;
|
||||
|
||||
if( part_map ) {
|
||||
|
@ -934,7 +934,7 @@ static ssize_t devfs_readpage(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t po
|
|||
pos += part_map->offset;
|
||||
}
|
||||
|
||||
return v->stream.u.dev.calls->dev_readpage(v->stream.u.dev.ident, vecs, pos);
|
||||
return v->stream.u.dev.ops->dev_readpage(v->stream.u.dev.ident, vecs, pos);
|
||||
} else {
|
||||
return ERR_NOT_ALLOWED;
|
||||
}
|
||||
|
@ -949,7 +949,7 @@ static ssize_t devfs_writepage(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t p
|
|||
if(v->stream.type == STREAM_TYPE_DEVICE) {
|
||||
struct devfs_part_map *part_map = v->stream.u.dev.part_map;
|
||||
|
||||
if(!v->stream.u.dev.calls->dev_writepage)
|
||||
if(!v->stream.u.dev.ops->dev_writepage)
|
||||
return ERR_NOT_ALLOWED;
|
||||
|
||||
if( part_map ) {
|
||||
|
@ -964,7 +964,7 @@ static ssize_t devfs_writepage(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t p
|
|||
pos += part_map->offset;
|
||||
}
|
||||
|
||||
return v->stream.u.dev.calls->dev_writepage(v->stream.u.dev.ident, vecs, pos);
|
||||
return v->stream.u.dev.ops->dev_writepage(v->stream.u.dev.ident, vecs, pos);
|
||||
} else {
|
||||
return ERR_NOT_ALLOWED;
|
||||
}
|
||||
|
@ -1045,7 +1045,7 @@ devfs_write_stat(fs_volume _fs, fs_vnode _v, const struct stat *stat, int stat_m
|
|||
// #pragma mark -
|
||||
|
||||
|
||||
static struct fs_calls devfs_calls = {
|
||||
static struct fs_ops devfs_ops = {
|
||||
&devfs_mount,
|
||||
&devfs_unmount,
|
||||
NULL,
|
||||
|
@ -1107,12 +1107,12 @@ bootstrap_devfs(void)
|
|||
|
||||
TRACE(("bootstrap_devfs: entry\n"));
|
||||
|
||||
return vfs_register_filesystem("devfs", &devfs_calls);
|
||||
return vfs_register_filesystem("devfs", &devfs_ops);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
devfs_publish_device(const char *path, void *ident, device_hooks *calls)
|
||||
devfs_publish_device(const char *path, void *ident, device_hooks *ops)
|
||||
{
|
||||
int err = 0;
|
||||
int i, last;
|
||||
|
@ -1121,9 +1121,9 @@ devfs_publish_device(const char *path, void *ident, device_hooks *calls)
|
|||
struct devfs_vnode *v;
|
||||
bool at_leaf;
|
||||
|
||||
TRACE(("devfs_publish_device: entry path '%s', ident %p, hooks %p\n", path, ident, calls));
|
||||
TRACE(("devfs_publish_device: entry path '%s', ident %p, hooks %p\n", path, ident, ops));
|
||||
|
||||
if (calls == NULL || path == NULL) {
|
||||
if (ops == NULL || path == NULL) {
|
||||
panic("devfs_publish_device called with NULL pointer!\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ devfs_publish_device(const char *path, void *ident, device_hooks *calls)
|
|||
// this is the last component
|
||||
v->stream.type = STREAM_TYPE_DEVICE;
|
||||
v->stream.u.dev.ident = ident;
|
||||
v->stream.u.dev.calls = calls;
|
||||
v->stream.u.dev.ops = ops;
|
||||
} else {
|
||||
// this is a dir
|
||||
v->stream.type = STREAM_TYPE_DIR;
|
||||
|
|
|
@ -922,7 +922,7 @@ rootfs_write_stat(fs_volume _fs, fs_vnode _v, const struct stat *stat, int stat_
|
|||
// #pragma mark -
|
||||
|
||||
|
||||
static struct fs_calls rootfs_calls = {
|
||||
static struct fs_ops rootfs_ops = {
|
||||
&rootfs_mount,
|
||||
&rootfs_unmount,
|
||||
NULL,
|
||||
|
@ -983,5 +983,5 @@ bootstrap_rootfs(void)
|
|||
{
|
||||
dprintf("bootstrap_rootfs: entry\n");
|
||||
|
||||
return vfs_register_filesystem("rootfs", &rootfs_calls);
|
||||
return vfs_register_filesystem("rootfs", &rootfs_ops);
|
||||
}
|
||||
|
|
|
@ -85,18 +85,18 @@ struct vnode_hash_key {
|
|||
|
||||
typedef struct file_system {
|
||||
struct file_system *next;
|
||||
struct fs_calls *calls;
|
||||
struct fs_ops *ops;
|
||||
const char *name;
|
||||
image_id image;
|
||||
int32 ref_count;
|
||||
} file_system;
|
||||
|
||||
#define FS_CALL(vnode,call) (vnode->mount->fs->calls->call)
|
||||
#define FS_CALL(vnode, op) (vnode->mount->fs->ops->op)
|
||||
|
||||
struct fs_mount {
|
||||
struct fs_mount *next;
|
||||
file_system *fs;
|
||||
mount_id id;
|
||||
mount_id id;
|
||||
void *cookie;
|
||||
char *mount_point;
|
||||
recursive_lock rlock;
|
||||
|
@ -233,7 +233,7 @@ mount_hash(void *_m, const void *_key, unsigned int range)
|
|||
*/
|
||||
|
||||
static file_system *
|
||||
new_file_system(const char *name, struct fs_calls *calls)
|
||||
new_file_system(const char *name, struct fs_ops *ops)
|
||||
{
|
||||
file_system *fs;
|
||||
|
||||
|
@ -244,7 +244,7 @@ new_file_system(const char *name, struct fs_calls *calls)
|
|||
return NULL;
|
||||
|
||||
fs->name = name;
|
||||
fs->calls = calls;
|
||||
fs->ops = ops;
|
||||
fs->image = -1;
|
||||
fs->ref_count = 0;
|
||||
|
||||
|
@ -281,8 +281,9 @@ static file_system *
|
|||
load_file_system(const char *name)
|
||||
{
|
||||
char path[SYS_MAX_PATH_LEN];
|
||||
struct fs_calls **calls;
|
||||
uint32 *version;
|
||||
file_system *fs;
|
||||
struct fs_ops **ops;
|
||||
int32 *version;
|
||||
void (*init)();
|
||||
image_id image;
|
||||
|
||||
|
@ -299,11 +300,29 @@ load_file_system(const char *name)
|
|||
return NULL;
|
||||
|
||||
init = (void *)elf_lookup_symbol(image, "init_file_system");
|
||||
if (!init)
|
||||
version = (int32 *)elf_lookup_symbol(image, "api_version");
|
||||
ops = (fs_ops **)elf_lookup_symbol(image, "fs_entry");
|
||||
if (init == NULL || version == NULL || ops == NULL) {
|
||||
dprintf("vfs: add-on \"%s\" doesn't export all necessary symbols.\n", name);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (*version != B_CURRENT_FS_API_VERSION) {
|
||||
dprintf("vfs: add-on \"%s\" supports unknown API version %ld\n", name, *version);
|
||||
goto err;
|
||||
}
|
||||
|
||||
fs = new_file_system(name, *ops);
|
||||
if (fs == NULL)
|
||||
goto err;
|
||||
|
||||
fs->image = image;
|
||||
|
||||
// initialize file system add-on
|
||||
init();
|
||||
|
||||
return fs;
|
||||
|
||||
err:
|
||||
elf_unload_kspace(path);
|
||||
return NULL;
|
||||
|
@ -1625,17 +1644,17 @@ vfs_bootstrap_all_filesystems(void)
|
|||
|
||||
|
||||
int
|
||||
vfs_register_filesystem(const char *name, struct fs_calls *calls)
|
||||
vfs_register_filesystem(const char *name, struct fs_ops *ops)
|
||||
{
|
||||
status_t status = B_OK;
|
||||
file_system *fs;
|
||||
|
||||
if (name == NULL || *name == '\0' || calls == NULL)
|
||||
if (name == NULL || *name == '\0' || ops == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
mutex_lock(&gFileSystemsMutex);
|
||||
|
||||
fs = new_file_system(name, calls);
|
||||
fs = new_file_system(name, ops);
|
||||
if (fs == NULL)
|
||||
status = B_NO_MEMORY;
|
||||
|
||||
|
@ -2660,7 +2679,7 @@ fs_mount(char *path, const char *device, const char *fsName, void *args, bool ke
|
|||
goto err3;
|
||||
}
|
||||
|
||||
err = mount->fs->calls->mount(mount->id, device, NULL, &mount->cookie, &root_id);
|
||||
err = mount->fs->ops->mount(mount->id, device, NULL, &mount->cookie, &root_id);
|
||||
if (err < 0) {
|
||||
err = ERR_VFS_GENERAL;
|
||||
goto err3;
|
||||
|
@ -2688,7 +2707,7 @@ fs_mount(char *path, const char *device, const char *fsName, void *args, bool ke
|
|||
mount->covers_vnode = covered_vnode;
|
||||
|
||||
// mount it
|
||||
err = mount->fs->calls->mount(mount->id, device, NULL, &mount->cookie, &root_id);
|
||||
err = mount->fs->ops->mount(mount->id, device, NULL, &mount->cookie, &root_id);
|
||||
if (err < 0)
|
||||
goto err4;
|
||||
}
|
||||
|
@ -2716,7 +2735,7 @@ fs_mount(char *path, const char *device, const char *fsName, void *args, bool ke
|
|||
return 0;
|
||||
|
||||
err5:
|
||||
mount->fs->calls->unmount(mount->cookie);
|
||||
mount->fs->ops->unmount(mount->cookie);
|
||||
err4:
|
||||
if (mount->covers_vnode)
|
||||
put_vnode(mount->covers_vnode);
|
||||
|
@ -2807,7 +2826,7 @@ fs_unmount(char *path, bool kernel)
|
|||
|
||||
mutex_unlock(&gMountOpMutex);
|
||||
|
||||
mount->fs->calls->unmount(mount->cookie);
|
||||
mount->fs->ops->unmount(mount->cookie);
|
||||
|
||||
// release the file system
|
||||
put_file_system(mount->fs);
|
||||
|
@ -2837,7 +2856,7 @@ fs_sync(void)
|
|||
|
||||
hash_open(gMountsTable, &iter);
|
||||
while ((mount = hash_next(gMountsTable, &iter))) {
|
||||
mount->fs->calls->sync(mount->cookie);
|
||||
mount->fs->ops->sync(mount->cookie);
|
||||
}
|
||||
hash_close(gMountsTable, &iter, false);
|
||||
|
||||
|
@ -2862,8 +2881,8 @@ fs_read_info(dev_t device, struct fs_info *info)
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (mount->fs->calls->read_fs_info)
|
||||
status = mount->fs->calls->read_fs_info(mount->cookie, info);
|
||||
if (mount->fs->ops->read_fs_info)
|
||||
status = mount->fs->ops->read_fs_info(mount->cookie, info);
|
||||
else
|
||||
status = EOPNOTSUPP;
|
||||
|
||||
|
@ -2891,8 +2910,8 @@ fs_write_info(dev_t device, const struct fs_info *info, int mask)
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (mount->fs->calls->write_fs_info)
|
||||
status = mount->fs->calls->write_fs_info(mount->cookie, info, mask);
|
||||
if (mount->fs->ops->write_fs_info)
|
||||
status = mount->fs->ops->write_fs_info(mount->cookie, info, mask);
|
||||
else
|
||||
status = EROFS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue