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 9#include "btrfs.h" 10 11 12enum inode_type { 13 S_DIRECTORY = S_IFDIR, 14 S_FILE = S_IFREG, 15 S_SYMLINK = S_IFLNK, 16 17 S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX 18 | S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX 19 | S_FLOAT_INDEX | S_DOUBLE_INDEX), 20 21 S_EXTENDED_TYPES = (S_ATTR_DIR | S_ATTR | S_INDEX_DIR) 22}; 23 24 25/*! Converts the open mode, the open flags given to bfs_open(), into 26 access modes, e.g. since O_RDONLY requires read access to the 27 file, it will be converted to R_OK. 28*/ 29inline int 30open_mode_to_access(int openMode) 31{ 32 openMode &= O_RWMASK; 33 if (openMode == O_RDONLY) 34 return R_OK; 35 if (openMode == O_WRONLY) 36 return W_OK; 37 38 return R_OK | W_OK; 39} 40 41#endif // UTILITY_H 42