Added ramdisk driver.
[planlOS.git] / system / modules / ramdisk / ramdisk_cdi.h
blob0498a66f7ee460ea3afa9914f39b14a132ce1f9a
1 /*
2 * Copyright (c) 2008 The LOST Project. All rights reserved.
4 * This code is derived from software contributed to the LOST Project
5 * by Alexander Siol and Janosch Graef.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the LOST Project
18 * and its contributors.
19 * 4. Neither the name of the LOST Project nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef _RAMDISK_CDI_H_
37 #define _RAMDISK_CDI_H_
39 #include <stdint.h>
40 #include <stdlib.h>
42 #include "cdi/fs.h"
45 /**
46 * Dateisystemressource fuer ramdisk
48 struct ramdisk_fs_res {
49 struct cdi_fs_res res;
51 // Buffer fuer die Daten, und dessen Groesse
52 void* buffer;
53 size_t size;
55 // Zugriffszeiten (Meta-Informationen)
56 int64_t creation_time;
57 int64_t access_time;
58 int64_t modification_time;
62 // CDI-IF
63 int ramdisk_fs_init(struct cdi_fs_filesystem* fs);
64 int ramdisk_fs_destroy(struct cdi_fs_filesystem* fs);
66 // CDI Res
67 int ramdisk_fs_res_load(struct cdi_fs_stream* stream);
68 int ramdisk_fs_res_unload(struct cdi_fs_stream* stream);
69 int ramdisk_fs_res_remove(struct cdi_fs_stream* stream);
70 int ramdisk_fs_res_rename(struct cdi_fs_stream* stream, const char* name);
71 //int ramdisk_fs_res_move(struct cdi_fs_stream* stream, struct cdi_fs_res* dest);
72 int ramdisk_fs_res_assign_class(struct cdi_fs_stream* stream,
73 cdi_fs_res_class_t class);
74 int ramdisk_fs_res_remove_class(struct cdi_fs_stream* stream,
75 cdi_fs_res_class_t class);
76 int64_t ramdisk_fs_res_meta_read(struct cdi_fs_stream* stream, cdi_fs_meta_t meta);
77 int ramdisk_fs_res_meta_write(struct cdi_fs_stream* stream, cdi_fs_meta_t meta,
78 int64_t value);
79 int ramdisk_fs_res_destroy(struct ramdisk_fs_res* res);
81 // CDI File
82 size_t ramdisk_fs_file_read(struct cdi_fs_stream* stream, uint64_t start,
83 size_t size, void* data);
84 size_t ramdisk_fs_file_write(struct cdi_fs_stream* stream, uint64_t start,
85 size_t size, const void* data);
86 int ramdisk_fs_file_truncate(struct cdi_fs_stream* stream, uint64_t size);
88 // CDI Dir
89 cdi_list_t ramdisk_fs_dir_list(struct cdi_fs_stream* stream);
90 int ramdisk_fs_dir_create_child(struct cdi_fs_stream* stream,
91 const char* name, struct cdi_fs_res* parent);
93 // CDI Link
94 const char* ramdisk_fs_link_read(struct cdi_fs_stream* stream);
95 int ramdisk_fs_link_write(struct cdi_fs_stream* stream, const char* path);
98 // ramdisk-Ressourcen(-Typen)
99 extern struct cdi_fs_res_res ramdisk_fs_res;
100 extern struct cdi_fs_res_file ramdisk_fs_file;
101 extern struct cdi_fs_res_dir ramdisk_fs_dir;
102 extern struct cdi_fs_res_link ramdisk_fs_link;
103 extern struct cdi_fs_res_special ramdisk_fs_special;
105 #endif