New developer version 0.6.8; added select () function; added demonstrating example...
[ZeXOS.git] / kernel / include / vfs.h
blob554d54bd8884db6298b12e25cdde2d5d08408b67
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef _VFS_H
23 #define _VFS_H
25 #define VFS_FILEATTR_FILE 0x1
26 #define VFS_FILEATTR_DIR 0x2
27 #define VFS_FILEATTR_HIDDEN 0x4
28 #define VFS_FILEATTR_SYSTEM 0x8
29 #define VFS_FILEATTR_BIN 0x10
30 #define VFS_FILEATTR_READ 0x20
31 #define VFS_FILEATTR_WRITE 0x40
32 #define VFS_FILEATTR_MOUNTED 0x80
33 #define VFS_FILEATTR_DEVICE 0x100
35 #define VFS_FILENAME_LEN 10
36 #define VFS_MOUNTPOINT_LEN 32
38 /* data container for virtual files */
39 typedef struct {
40 char *ptr;
41 unsigned long len;
42 } vfs_content_t;
44 /* Virtual filesystem structure */
45 typedef struct vfs_context {
46 struct vfs_context *next, *prev;
48 char *name;
49 char mountpoint[VFS_MOUNTPOINT_LEN];
50 unsigned attrib;
51 vfs_content_t *content;
52 } vfs_t;
54 /* structure for directory entries */
55 typedef struct {
56 char *name;
57 unsigned attrib;
58 unsigned char next;
59 unsigned char unused;
60 } __attribute__ ((__packed__)) vfs_dirent_t;
62 /* externs */
63 extern vfs_t *vfs_list_find (char *name, char *mountpoint);
64 extern vfs_t *vfs_list_findbymp (char *mountpoint);
65 extern vfs_t *vfs_find (char *file, unsigned file_len);
66 extern vfs_t *vfs_list_add (char *name, unsigned attrib, char *mountpoint);
67 extern bool vfs_list_del (vfs_t *vfs);
68 extern bool vfs_list_delbymp (char *mountpoint);
69 extern int vfs_mmap (char *file, unsigned file_len, vfs_content_t *content);
70 extern int vfs_read (char *file, unsigned file_len, vfs_content_t *content);
71 extern int vfs_cat (char *file, unsigned file_len);
72 extern int vfs_cp (char *what, unsigned what_len, char *where, unsigned where_len);
73 extern int vfs_ls (char *file, unsigned file_len);
74 extern int vfs_cd (char *file, unsigned file_len);
75 extern int vfs_mkdir (char *file, unsigned file_len);
76 extern int vfs_touch (char *file, unsigned file_len);
77 extern int vfs_rm (char *file, unsigned file_len);
78 extern vfs_dirent_t *vfs_dirent ();
79 extern unsigned int init_vfs ();
81 #endif