vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / file_systems / ntfs / kernel_interface.c
blobd2835f3798214fa5b345db29ed50d292f71d6491
1 /* kernel_interface - file system interface to Haiku's vnode layer
3 * Copyright (c) 2006-2007 Troeglazov Gerasim (3dEyes**)
5 * This program/include file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program/include file is distributed in the hope that it will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program (in the main directory of the Linux-NTFS
17 * distribution in the file COPYING); if not, write to the Free Software
18 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <ctype.h>
23 #include <dirent.h>
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <time.h>
30 #include <unistd.h>
31 #include <sys/stat.h>
33 #include <fs_interface.h>
34 #include <kernel/lock.h>
35 #include <fs_info.h>
36 #include <fs_cache.h>
37 #include <fs_attr.h>
38 #include <fs_info.h>
39 #include <fs_index.h>
40 #include <fs_query.h>
41 #include <fs_volume.h>
42 #include <NodeMonitor.h>
43 #include <util/kernel_cpp.h>
45 #include "fs_func.h"
46 #include "ntfsdir.h"
47 #include "attributes.h"
50 static status_t
51 ntfs_std_ops(int32 op, ...)
53 switch (op) {
54 case B_MODULE_INIT:
55 return B_OK;
56 case B_MODULE_UNINIT:
57 return B_OK;
58 default:
59 return B_ERROR;
63 fs_volume_ops gNTFSVolumeOps = {
64 &fs_unmount,
65 &fs_rfsstat,
66 &fs_wfsstat,
67 &fs_sync,
68 &fs_read_vnode,
70 /* index directory & index operations */
71 NULL, //&fs_open_index_dir,
72 NULL, //&fs_close_index_dir,
73 NULL, //&fs_free_index_dir_cookie,
74 NULL, //&fs_read_index_dir,
75 NULL, //&fs_rewind_index_dir,
77 NULL, //&fs_create_index,
78 NULL, //&fs_remove_index,
79 NULL, //&fs_stat_index,
81 /* query operations */
82 NULL, //&fs_open_query,
83 NULL, //&fs_close_query,
84 NULL, //&fs_free_query_cookie,
85 NULL, //&fs_read_query,
86 NULL, //&fs_rewind_query,
89 fs_vnode_ops gNTFSVnodeOps = {
90 /* vnode operations */
91 &fs_walk,
92 &fs_get_vnode_name,
93 &fs_write_vnode,
94 &fs_remove_vnode,
96 /* VM file access */
97 NULL,
98 NULL,
99 NULL,
101 NULL, // io()
102 NULL, // cancel_io()
104 NULL,
106 NULL,
107 NULL, //&fs_set_flags,
108 NULL, //&fs_select
109 NULL, //&fs_deselect
110 &fs_fsync,
112 &fs_readlink,
113 &fs_create_symlink,
115 NULL, //&fs_link,
116 &fs_unlink,
117 &fs_rename,
119 &fs_access,
120 &fs_rstat,
121 &fs_wstat,
122 NULL, // fs_preallocate
124 /* file operations */
125 &fs_create,
126 &fs_open,
127 &fs_close,
128 &fs_free_cookie,
129 &fs_read,
130 &fs_write,
132 /* directory operations */
133 &fs_mkdir,
134 &fs_rmdir,
135 &fs_opendir,
136 &fs_closedir,
137 &fs_free_dircookie,
138 &fs_readdir,
139 &fs_rewinddir,
141 /* attribute directory operations */
142 &fs_open_attrib_dir,
143 &fs_close_attrib_dir,
144 &fs_free_attrib_dir_cookie,
145 &fs_read_attrib_dir,
146 &fs_rewind_attrib_dir,
148 /* attribute operations */
149 &fs_create_attrib,
150 &fs_open_attrib,
151 &fs_close_attrib,
152 &fs_free_attrib_cookie,
153 &fs_read_attrib,
154 &fs_write_attrib,
156 &fs_read_attrib_stat,
157 NULL, //&fs_write_attr_stat,
158 NULL, //&fs_rename_attr,
159 &fs_remove_attrib,
164 static file_system_module_info sNTFSFileSystem = {
166 "file_systems/ntfs" B_CURRENT_FS_API_VERSION,
168 ntfs_std_ops,
171 "ntfs", // short_name
172 "NT File System", // pretty_name
173 B_DISK_SYSTEM_SUPPORTS_INITIALIZING
174 | B_DISK_SYSTEM_SUPPORTS_CONTENT_NAME
175 | B_DISK_SYSTEM_SUPPORTS_WRITING, // DDM flags
177 // scanning
178 fs_identify_partition,
179 fs_scan_partition,
180 fs_free_identify_partition_cookie,
181 NULL, // free_partition_content_cookie()
183 &fs_mount,
184 /* capability querying operations */
185 &fs_get_supported_operations,
187 NULL, // validate_resize
188 NULL, // validate_move
189 NULL, // validate_set_content_name
190 NULL, // validate_set_content_parameters
191 NULL, // validate_initialize,
193 /* shadow partition modification */
194 NULL, // shadow_changed
196 /* writing */
197 NULL, // defragment
198 NULL, // repair
199 NULL, // resize
200 NULL, // move
201 NULL, // set_content_name
202 NULL, // set_content_parameters
203 fs_initialize,
204 NULL
208 module_info *modules[] = {
209 (module_info *)&sNTFSFileSystem,
210 NULL,