xref: /haiku/src/add-ons/kernel/file_systems/bfs/bfs_disk_system.cpp (revision 56eb8e78cc702792e3b032e3f5f45da9e5dbea9e)
1 /*
2  * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include "bfs_disk_system.h"
7 
8 #include "bfs.h"
9 #include "Volume.h"
10 
11 
12 status_t
13 parse_initialize_parameters(const char* parameterString,
14 	initialize_parameters& parameters)
15 {
16 	parameters.flags = 0;
17 	parameters.verbose = false;
18 
19 	void *handle = parse_driver_settings_string(parameterString);
20 	if (handle == NULL)
21 		return B_ERROR;
22 
23 	if (get_driver_boolean_parameter(handle, "noindex", false, true))
24 		parameters.flags |= VOLUME_NO_INDICES;
25 	if (get_driver_boolean_parameter(handle, "verbose", false, true))
26 		parameters.verbose = true;
27 
28 	const char *string = get_driver_parameter(handle, "block_size",
29 		NULL, NULL);
30 	uint32 blockSize = 1024;
31 	if (string != NULL)
32 		blockSize = strtoul(string, NULL, 0);
33 
34 	delete_driver_settings(handle);
35 
36 	if (blockSize != 1024 && blockSize != 2048 && blockSize != 4096
37 		&& blockSize != 8192) {
38 		return B_BAD_VALUE;
39 	}
40 
41 	parameters.blockSize = blockSize;
42 
43 	return B_OK;
44 }
45 
46 
47 status_t
48 check_volume_name(const char* name)
49 {
50 	if (name == NULL || strlen(name) >= BFS_DISK_NAME_LENGTH
51 		|| strchr(name, '/') != NULL) {
52 		return B_BAD_VALUE;
53 	}
54 
55 	return B_OK;
56 }
57 
58