source: trunk/kernel/vfs/ramfs.c @ 145

Last change on this file since 145 was 23, checked in by alain, 7 years ago

Introduce syscalls.

File size: 2.3 KB
RevLine 
[1]1/*
2 * ramfs.c  RAMFS file system API implementation.
3 *
[23]4 * Authors   Mohamed Lamine Karaoui (2014,2015)
5 *           Alain Greiner (2016,2017)
[1]6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25
26#include <hal_types.h>
27#include <hal_special.h>
28#include <printk.h>
29#include <kmem.h>
30#include <vfs.h>
31#include <ramfs.h>
32
33
34
35
36
37///////////////////////////////////////////////////////////////////////////////////////
[23]38//             The following functions are called by the VFS.
[1]39///////////////////////////////////////////////////////////////////////////////////////
40
[23]41//////////////////////////////////////////////
42error_t ramfs_mount( xptr_t   parent_inode_xp,
43                     char   * ramfs_root_name )
[1]44{
[23]45    xptr_t        root_inode_xp;   // unused                     
46 
47    // create VFS dentry and VFS inode for RAMFS root directory
48    return  vfs_add_child_in_parent( INODE_TYPE_DIR,
49                                     FS_TYPE_RAMFS,
50                                     parent_inode_xp,
51                                     ramfs_root_name,
52                                     &root_inode_xp );
53}
[1]54
55
[23]56////////////////////////////////////////////
57error_t ramfs_ctx_init( vfs_ctx_t * vfs_ctx,
58                        xptr_t      root_inode_xp )
[1]59
[23]60{
61    vfs_ctx->type    = FS_TYPE_RAMFS;
62    vfs_ctx->attr    = 0;                // not READ_ONLY / not SYNC
63    vfs_ctx->count   = 0;                // unused for RAMFS
64    vfs_ctx->blksize = 512;              // unused for RAMFS
65    vfs_ctx->root_xp = root_inode_xp;
66    vfs_ctx->extend  = NULL;             // unused for DEVFS
[1]67
[23]68    spinlock_init( &vfs_ctx->lock );
[1]69
[23]70    bitmap_init( vfs_ctx->bitmap , CONFIG_VFS_MAX_INODES );
[1]71
72    return 0;
73}
74
Note: See TracBrowser for help on using the repository browser.