Changeset 23 for trunk/kernel/vfs/ramfs.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/ramfs.c
r15 r23 2 2 * ramfs.c RAMFS file system API implementation. 3 3 * 4 * Authors Mohamed Lamine Karaoui (201 5)5 * Alain Greiner (2016 )4 * Authors Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 32 32 33 33 34 ///////////////////////////////////////////////////////////////////////////////////////35 // RAMFS specific functions : these static functions cannot be called by the VFS36 ///////////////////////////////////////////////////////////////////////////////////////37 34 38 35 39 36 40 37 /////////////////////////////////////////////////////////////////////////////////////// 41 // Generic API : the following functions are called by the VFS, 42 // and must be defined by all supported file systems. 38 // The following functions are called by the VFS. 43 39 /////////////////////////////////////////////////////////////////////////////////////// 44 40 45 //////////////////////////////////////////////////////////// 46 error_t ramfs_inode_create( struct vfs_inode_s * vfs_inode ) 41 ////////////////////////////////////////////// 42 error_t ramfs_mount( xptr_t parent_inode_xp, 43 char * ramfs_root_name ) 47 44 { 48 printk("\n[PANIC] %s not fully implemented yet\n", __FUNCTION__ ); 49 hal_core_sleep(); 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 } 50 54 51 kmem_req_t req;52 ramfs_inode_t * ramfs_inode;53 55 54 // allocate memory for ramfs inode 55 req.type = KMEM_RAMFS_INODE; 56 req.size = sizeof(ramfs_inode_t); 57 req.flags = AF_KERNEL | AF_ZERO; 58 ramfs_inode = (ramfs_inode_t *)kmem_alloc( &req ); 56 //////////////////////////////////////////// 57 error_t ramfs_ctx_init( vfs_ctx_t * vfs_ctx, 58 xptr_t root_inode_xp ) 59 59 60 if( ramfs_inode == NULL ) return ENOMEM; 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 61 67 62 // initialise ramfs_inode TODO68 spinlock_init( &vfs_ctx->lock ); 63 69 64 // link vfs_inode to ramfs_inode 65 vfs_inode->extend = ramfs_inode; 70 bitmap_init( vfs_ctx->bitmap , CONFIG_VFS_MAX_INODES ); 66 71 67 72 return 0; 68 73 } 69 74 70 //////////////////////////////////////////////////////71 void ramfs_inode_destroy( struct vfs_inode_s * inode )72 {73 assert( false , __FUNCTION__ , "not fully implemented yet" );74 }75 76 /////////////////////////////////////////////////77 error_t ramfs_write_page( struct page_s * page )78 {79 printk("\n[PANIC] %s not fully implemented yet\n", __FUNCTION__ );80 hal_core_sleep();81 82 return 0;83 }84 85 ////////////////////////////////////////////////86 error_t ramfs_read_page( struct page_s * page )87 {88 printk("\n[PANIC] %s not fully implemented yet\n", __FUNCTION__ );89 hal_core_sleep();90 91 return 0;92 }93
Note: See TracChangeset
for help on using the changeset viewer.