Exemple #1
0
/*
 * net_buffer_init
 * This function will initialize the buffer file system for out networking
 * stack.
 */
void net_buffer_init()
{
    /* Clear the global structure. */
    memset(&net_buffers_fs, 0, sizeof(NET_BUFFER_FS));

    /* Initialize the buffer data. */
    net_buffers_fs.fs.name = "\\net\\buffers";
    net_buffers_fs.fs.get_lock = &net_buffer_lock;
    net_buffers_fs.fs.release_lock = &net_buffer_unlock;

    /* Read and write functions. */
    net_buffers_fs.fs.write = &net_buffer_write;
    net_buffers_fs.fs.read = &net_buffer_read;

    /* Initial file system configurations. */
    net_buffers_fs.fs.flags = (FS_SPACE_AVAILABLE);
    net_buffers_fs.fs.timeout = MAX_WAIT;

    /* Initialize file system condition. */
    fs_condition_init(&net_buffers_fs.fs);

#ifdef CONFIG_SEMAPHORE
    /* Create a semaphore to protect net buffer file descriptor. */
    semaphore_create(&net_buffers_fs.lock, 1, 1, SEMAPHORE_PRIORITY);
#endif

    /* Register net buffer file system. */
    fs_register((FS *)&net_buffers_fs);

    /* Set the global networking stack buffer descriptor. */
    net_buff_fd = (FD)&net_buffers_fs;

} /* net_buffer_init */
Exemple #2
0
int __kinit__ devfs_init(void)
{
    struct fs_superblock * sb;

    SUBSYS_DEP(ramfs_init);
    SUBSYS_INIT("devfs");

    FS_GIANT_INIT(&devfs_fs.fs_giant);

    /*
     * Inherit ramfs and override what's needed.
     */
    fs_inherit_vnops(&devfs_vnode_ops, &ramfs_vnode_ops);
    vn_devfs = fs_create_pseudofs_root(&devfs_fs, VDEV_MJNR_DEVFS);
    if (!vn_devfs)
        return -ENOMEM;

    /*
     * It's perfectly ok to set a new delete_vnode() function
     * as sb struct is always a fresh struct so altering it
     * doesn't really break functionality for anyone else than us.
     */
    sb = vn_devfs->sb;
    sb->delete_vnode = devfs_delete_vnode;
    sb->umount = devfs_umount;

    /*
     * Finally register our creation with fs subsystem.
     */
    fs_register(&devfs_fs);

    _devfs_create_specials();

    return 0;
}
Exemple #3
0
SQLITE_EXTENSION_INIT3

#include "example.h"
#include "fs.h"

int lib_init( sqlite3* db, 
              char **pzErrMsg, 
              const sqlite3_api_routines* pApi )
{
    SQLITE_EXTENSION_INIT2(pApi);

    if(example_register(db) != SQLITE_OK)
    {
        fprintf(stderr, "Failed to register example module\n");

        return SQLITE_ERROR;
    }

    if(fs_register(db) != SQLITE_OK)
    {
        fprintf(stderr, "Failed to register fs module\n");

        return SQLITE_ERROR;
    }

    return SQLITE_OK;
}
Exemple #4
0
int devfs_initialize(void)
{
    struct devfs *devfs;

    devfs = kmalloc(sizeof (struct devfs));
    if (!devfs)
        return -ENOMEM;

    devfs->mounted = 0;
    spinlock_init(&devfs->lock);

    return fs_register(FS_NAME, 0, &devfs_sup_ops, &devfs_ops, &devfs_f_ops,
                       devfs);
}
Exemple #5
0
int __kinit__ procfs_init(void)
{
    SUBSYS_DEP(ramfs_init);
    SUBSYS_INIT("procfs");

    /*
     * This must be static as it's referenced and used in the file system via
     * the fs object system.
     */
    static fs_t procfs_fs = {
        .fsname = PROCFS_FSNAME,
        .mount = procfs_mount,
        .sblist_head = SLIST_HEAD_INITIALIZER(),
    };

    specinfo_pool = mempool_init(MEMPOOL_TYPE_NONBLOCKING,
                                 sizeof(struct procfs_info),
                                 configMAXPROC);
    if (!specinfo_pool)
        return -ENOMEM;

    FS_GIANT_INIT(&procfs_fs.fs_giant);

    /*
     * Inherit unimplemented vnops from ramfs.
     */
    fs_inherit_vnops(&procfs_vnode_ops, &ramfs_vnode_ops);

    vn_procfs = fs_create_pseudofs_root(&procfs_fs, VDEV_MJNR_PROCFS);
    if (!vn_procfs)
        return -ENOMEM;

    struct fs_superblock * sb = vn_procfs->sb;
    sb->delete_vnode = procfs_delete_vnode;

    vn_procfs->sb->umount = procfs_umount;
    fs_register(&procfs_fs);

    int err = init_permanent_files();
    if (err)
        return err;

    procfs_updatedir(vn_procfs);

    return 0;
}
Exemple #6
0
int __kinit__ devfs_init(void)
{
    SUBSYS_DEP(ramfs_init);
    SUBSYS_INIT("devfs");

    /*
     * This must be static as it's referenced and used in the file system via
     * the fs object system.
     */
    static fs_t devfs_fs = {
        .fsname = DEVFS_FSNAME,
        .mount = devfs_mount,
        .sblist_head = SLIST_HEAD_INITIALIZER(),
    };

    FS_GIANT_INIT(&devfs_fs.fs_giant);

    /*
     * Inherit ramfs and override what's needed.
     */
    fs_inherit_vnops(&devfs_vnode_ops, &ramfs_vnode_ops);
    vn_devfs = fs_create_pseudofs_root(&devfs_fs, VDEV_MJNR_DEVFS);
    if (!vn_devfs)
        return -ENOMEM;

    /*
     * It's perfectly ok to set a new delete_vnode() function
     * as sb struct is always a fresh struct so altering it
     * doesn't really break functionality for anyone else than us.
     */
    struct fs_superblock * sb = vn_devfs->sb;
    sb->delete_vnode = devfs_delete_vnode;
    sb->umount = devfs_umount;

    /*
     * Finally register our creation with fs subsystem.
     */
    fs_register(&devfs_fs);

    _devfs_create_specials();

    return 0;
}
Exemple #7
0
/*
 * console_init
 * This function will initialize debug console.
 */
void console_init()
{
    /* Clear the console data. */
    memset(&console_data, 0, sizeof(CONSOLE_DATA));

#ifdef CONFIG_SEMAPHORE
    /* Create a semaphore to protect global console data. */
    semaphore_create(&console_data.lock, 1, 1, SEMAPHORE_PRIORITY);
#endif

    /* Register console with file system. */
    fs_register(&console_fs);

#ifdef DEBUG_CONSOLE_INIT
    /* Initialize DEBUG console. */
    DEBUG_CONSOLE_INIT();
#endif

} /* console_init */
Exemple #8
0
int main(int argc, char *argv[])
{
	log_init(NAME);
	log_msg(LOG_DEFAULT, LVL_NOTE, "HelenOS UDF 1.02 file system server");
	
	if (argc == 3) {
		if (!str_cmp(argv[1], "--instance"))
			udf_vfs_info.instance = strtol(argv[2], NULL, 10);
		else {
			log_msg(LOG_DEFAULT, LVL_FATAL, "Unrecognized parameters");
			return 1;
		}
	}
	
	async_sess_t *vfs_sess =
	    service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0);
	if (!vfs_sess) {
		log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to connect to VFS");
		return 2;
	}
	
	int rc = fs_register(vfs_sess, &udf_vfs_info, &udf_ops,
	    &udf_libfs_ops);
	if (rc != EOK)
		goto err;
	
	rc = udf_idx_init();
	if (rc != EOK)
		goto err;
	
	log_msg(LOG_DEFAULT, LVL_NOTE, "Accepting connections");
	task_retval(0);
	async_manager();
	
	/* Not reached */
	return 0;
	
err:
	log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to register file system (%d)", rc);
	return rc;
}
Exemple #9
0
int main(int argc, char **argv)
{
	printf(NAME ": HelenOS FAT file system server\n");
	
	if (argc == 3) {
		if (!str_cmp(argv[1], "--instance"))
			fat_vfs_info.instance = strtol(argv[2], NULL, 10);
		else {
			printf(NAME " Unrecognized parameters");
			return -1;
		}
	}

	int rc = fat_idx_init();
	if (rc != EOK)
		goto err;
	
	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
	    SERVICE_VFS, 0, 0);
	if (!vfs_sess) {
		printf(NAME ": failed to connect to VFS\n");
		return -1;
	}
	
	rc = fs_register(vfs_sess, &fat_vfs_info, &fat_ops, &fat_libfs_ops);
	if (rc != EOK) {
		fat_idx_fini();
		goto err;
	}
	
	printf(NAME ": Accepting connections\n");
	task_retval(0);
	async_manager();
	
	/* Not reached */
	return 0;
	
err:
	printf(NAME ": Failed to register file system (%d)\n", rc);
	return rc;
}
Exemple #10
0
int main(int argc, char **argv)
{
	printf("%s: HelenOS ext4 file system server\n", NAME);
	
	if (argc == 3) {
		if (!str_cmp(argv[1], "--instance"))
			ext4fs_vfs_info.instance = strtol(argv[2], NULL, 10);
		else {
			printf("%s: Unrecognized parameters\n", NAME);
			return 1;
		}
	}
	
	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
	    SERVICE_VFS, 0, 0);
	if (!vfs_sess) {
		printf("%s: Failed to connect to VFS\n", NAME);
		return 2;
	}
	
	int rc = ext4fs_global_init();
	if (rc != EOK) {
		printf("%s: Global initialization failed\n", NAME);
		return rc;
	}
	
	rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4fs_ops,
	    &ext4fs_libfs_ops);
	if (rc != EOK) {
		printf("%s: Failed to register file system\n", NAME);
		return rc;
	}
	
	printf("%s: Accepting connections\n", NAME);
	task_retval(0);
	async_manager();
	
	/* Not reached */
	return 0;
}
Exemple #11
0
int __kinit__ fatfs_init(void)
{
    int err;

    SUBSYS_DEP(fs_init);
    SUBSYS_DEP(proc_init);
    SUBSYS_INIT("fatfs");

    fatfs_sb_arr = kcalloc(configFATFS_MAX_MOUNTS, sizeof(struct fatfs_sb *));
    if (!fatfs_sb_arr)
        return -ENOMEM;

    fs_inherit_vnops(&fatfs_vnode_ops, &nofs_vnode_ops);

    err = ff_init();
    if (err)
        return err;

    FS_GIANT_INIT(&fatfs_fs.fs_giant);
    fs_register(&fatfs_fs);

    return 0;
}
/**
 * Initializes the nffs memory and data structures.  This must be called before
 * any nffs operations are attempted.
 *
 * @return                  0 on success; nonzero on error.
 */
int
nffs_init(void)
{
    int rc;

    nffs_config_init();

    nffs_cache_clear();

    rc = os_mutex_init(&nffs_mutex);
    if (rc != 0) {
        return FS_EOS;
    }

    free(nffs_file_mem);
    nffs_file_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_files, sizeof (struct nffs_file)));
    if (nffs_file_mem == NULL) {
        return FS_ENOMEM;
    }

    free(nffs_inode_mem);
    nffs_inode_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_inodes,
                        sizeof (struct nffs_inode_entry)));
    if (nffs_inode_mem == NULL) {
        return FS_ENOMEM;
    }

    free(nffs_block_entry_mem);
    nffs_block_entry_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_blocks,
                         sizeof (struct nffs_hash_entry)));
    if (nffs_block_entry_mem == NULL) {
        return FS_ENOMEM;
    }

    free(nffs_cache_inode_mem);
    nffs_cache_inode_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_cache_inodes,
                         sizeof (struct nffs_cache_inode)));
    if (nffs_cache_inode_mem == NULL) {
        return FS_ENOMEM;
    }

    free(nffs_cache_block_mem);
    nffs_cache_block_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_cache_blocks,
                         sizeof (struct nffs_cache_block)));
    if (nffs_cache_block_mem == NULL) {
        return FS_ENOMEM;
    }

    free(nffs_dir_mem);
    nffs_dir_mem = malloc(
        OS_MEMPOOL_BYTES(nffs_config.nc_num_dirs,
                         sizeof (struct nffs_dir)));
    if (nffs_dir_mem == NULL) {
        return FS_ENOMEM;
    }

    rc = nffs_misc_reset();
    if (rc != 0) {
        return rc;
    }

    fs_register(&nffs_ops);
    return 0;
}