OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [fs/] [init.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Filesystem initialisation.
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <fs.h>
7
#include <vfs.h>
8
#include <bdev.h>
9
#include <task.h>
10
#include <stdio.h>
11
#include <string.h>
12
#include <l4/lib/list.h>
13
#include <l4/api/errno.h>
14
#include <memfs/memfs.h>
15
 
16
struct link fs_type_list;
17
 
18
struct superblock *vfs_probe_filesystems(void *block)
19
{
20
        struct file_system_type *fstype;
21
        struct superblock *sb;
22
 
23
        list_foreach_struct(fstype, &fs_type_list, list) {
24
                /* Does the superblock match for this fs type? */
25
                if ((sb = fstype->ops.get_superblock(block))) {
26
                        /*
27
                         * Add this to the list of superblocks this
28
                         * fs already has.
29
                         */
30
                        list_insert(&sb->list, &fstype->sblist);
31
                        return sb;
32
                }
33
        }
34
 
35
        return PTR_ERR(-ENODEV);
36
}
37
 
38
/*
39
 * Registers each available filesystem so that these can be
40
 * used when probing superblocks on block devices.
41
 */
42
void vfs_register_filesystems(void)
43
{
44
        /* Initialise fstype list */
45
        link_init(&fs_type_list);
46
 
47
        /* Call per-fs registration functions */
48
        memfs_register_fstype(&fs_type_list);
49
}
50
 
51
/*
52
 * Filesystem initialisation.
53
 */
54
int vfs_init(void)
55
{
56
        void *rootdev_blocks;
57
        struct superblock *root_sb;
58
 
59
        /* Initialize superblock ids */
60
        vfs_fsidx_pool = id_pool_new_init(VFS_FSIDX_SIZE);
61
 
62
        /*
63
         * Waste first one so that vnums
64
         * always orr with a non-zero value
65
         */
66
        id_new(vfs_fsidx_pool);
67
 
68
        /* Get standard init data from microkernel */
69
        // request_initdata(&initdata);
70
 
71
        /* Register compiled-in filesystems with vfs core. */
72
        vfs_register_filesystems();
73
 
74
        /* Get a pointer to first block of root block device */
75
        rootdev_blocks = vfs_rootdev_open();
76
 
77
        /*
78
         * Since the *only* filesystem we have is a temporary memory
79
         * filesystem, we create it on the root device first.
80
         */
81
        memfs_format_filesystem(rootdev_blocks);
82
 
83
        /* Search for a filesystem on the root device */
84
        BUG_ON(IS_ERR(root_sb = vfs_probe_filesystems(rootdev_blocks)));
85
 
86
        /* Mount the filesystem on the root device */
87
        vfs_mount_root(root_sb);
88
 
89
        printf("%s: Mounted memfs root filesystem.\n", __TASKNAME__);
90
 
91
        return 0;
92
}
93
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.