libfs.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00036 #ifndef LIBFS_LIBFS_H_
00037 #define LIBFS_LIBFS_H_
00038 
00039 #include <ipc/vfs.h>
00040 #include <stdint.h>
00041 #include <async.h>
00042 #include <devmap.h>
00043 
00044 typedef struct {
00045         bool mp_active;
00046         int phone;
00047         fs_handle_t fs_handle;
00048         devmap_handle_t devmap_handle;
00049 } mp_data_t;
00050 
00051 typedef struct {
00052         mp_data_t mp_data;  
00053         void *data;         
00054 } fs_node_t;
00055 
00056 typedef struct {
00057         /*
00058          * The first set of methods are functions that return an integer error
00059          * code. If some additional return value is to be returned, the first
00060          * argument holds the output argument.
00061          */
00062         int (* root_get)(fs_node_t **, devmap_handle_t);
00063         int (* match)(fs_node_t **, fs_node_t *, const char *);
00064         int (* node_get)(fs_node_t **, devmap_handle_t, fs_index_t);
00065         int (* node_open)(fs_node_t *);
00066         int (* node_put)(fs_node_t *);
00067         int (* create)(fs_node_t **, devmap_handle_t, int);
00068         int (* destroy)(fs_node_t *);
00069         int (* link)(fs_node_t *, fs_node_t *, const char *);
00070         int (* unlink)(fs_node_t *, fs_node_t *, const char *);
00071         int (* has_children)(bool *, fs_node_t *);
00072         /*
00073          * The second set of methods are usually mere getters that do not return
00074          * an integer error code.
00075          */
00076         fs_index_t (* index_get)(fs_node_t *);
00077         aoff64_t (* size_get)(fs_node_t *);
00078         unsigned int (* lnkcnt_get)(fs_node_t *);
00079         char (* plb_get_char)(unsigned pos);
00080         bool (* is_directory)(fs_node_t *);
00081         bool (* is_file)(fs_node_t *);
00082         devmap_handle_t (* device_get)(fs_node_t *);
00083 } libfs_ops_t;
00084 
00085 typedef struct {
00086         int fs_handle;           
00087         uint8_t *plb_ro;         
00088 } fs_reg_t;
00089 
00090 extern int fs_register(int, fs_reg_t *, vfs_info_t *, async_client_conn_t);
00091 
00092 extern void fs_node_initialize(fs_node_t *);
00093 
00094 extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
00095 extern void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *);
00096 extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
00097 extern void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
00098 extern void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
00099     ipc_call_t *);
00100 
00101 #endif
00102 

Generated on Thu Jun 2 07:45:47 2011 for HelenOS/USB by  doxygen 1.4.7