xref: /haiku/src/add-ons/kernel/file_systems/ext2/Utility.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de.
3  * This file may be used under the terms of the MIT License.
4  */
5 #ifndef UTILITY_H
6 #define UTILITY_H
7 
8 #include "ext2.h"
9 
10 enum inode_type {
11 	S_DIRECTORY		= S_IFDIR,
12 	S_FILE			= S_IFREG,
13 	S_SYMLINK		= S_IFLNK,
14 
15 	S_INDEX_TYPES	= (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX
16 						| S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX
17 						| S_FLOAT_INDEX | S_DOUBLE_INDEX),
18 
19 	S_EXTENDED_TYPES = (S_ATTR_DIR | S_ATTR | S_INDEX_DIR)
20 };
21 
22 
23 /*!	Converts the open mode, the open flags given to bfs_open(), into
24 	access modes, e.g. since O_RDONLY requires read access to the
25 	file, it will be converted to R_OK.
26 */
27 inline int
28 open_mode_to_access(int openMode)
29 {
30 	openMode &= O_RWMASK;
31 	if (openMode == O_RDONLY)
32 		return R_OK;
33 	if (openMode == O_WRONLY)
34 		return W_OK;
35 
36 	return R_OK | W_OK;
37 }
38 
39 #endif	// UTILITY_H
40