Main Page | Directories | File List | Globals

pseudo_vfs.c

Go to the documentation of this file.
00001 /*
00002  * kernel_sys/pseudo_vfs.c
00003  *
00004  * Copyright (c) 2003-2005 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2005/04
00008  * Author:      Lukasz Dembinski
00009  * Info:        It's only stub for real virtual filesystem
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 /*
00015  * TODO
00016  * - all VFS module
00017  */
00018 
00019 #include <agnix/agnix.h>
00020 #include <agnix/adi/adi.h>
00021 #include <agnix/fs.h>
00022 #include <agnix/terminal.h>
00023 #include <agnix/console.h>
00024 
00025 #define MOD_NAME        "VFS: "
00026 
00027 int do_sys_open(char *filename, int flag, int mode)
00028 {
00029     struct adi_chrdev_s *dev;    
00030     struct file_s *file;
00031     int ret;
00032     int fd;
00033 
00034     if ((dev = adi_chrdev_find_by_name(filename))) {
00035         file = file_create();
00036         file->file_ops  = dev->file_ops;
00037         file->file_data = (void *)DEV_MINOR(dev);
00038 
00039         if (file->file_ops && file->file_ops->open) {
00040                 if ((ret = file->file_ops->open(file, flag, mode)) < 0) {
00041                     file_destroy(file);
00042                     return ret;
00043             }
00044         } else {
00045             printk("no open function %08x %08x %08x\n", file->file_ops, file->file_ops->open, dev->file_ops);
00046 
00047             return -1;
00048         }
00049         
00050         if ((fd = file_install_fd(file)) < 0) {
00051             file_destroy(file);
00052             return -1;    
00053         }
00054         
00055         return fd;
00056     } 
00057 
00058     return -1;
00059 }
00060 
00061 int do_sys_read(int fd, char *buf, int count)
00062 {
00063     struct file_s *file;
00064     
00065     file = current_task->files->file[fd];
00066 
00067     if (file->file_ops && file->file_ops->read) {
00068         return file->file_ops->read(file, buf, count);
00069     }
00070     
00071     return -1;
00072 }
00073 
00074 int do_sys_write(int fd, char *buf, int count)
00075 {
00076     struct file_s *file;
00077     
00078     file = current_task->files->file[fd];
00079 
00080     if (file->file_ops && file->file_ops->write) {
00081         return file->file_ops->write(file, buf, count);
00082     }
00083 
00084     return -1;
00085 }
00086 
00087 int do_sys_lseek(int fd, int offset, int whence)
00088 {
00089     return 0;
00090 }
00091 
00092 int do_sys_close(int fd)
00093 {
00094     return 0;
00095 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix