1 /* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- 2 * 3 * Copyright (c) 2014-2015 Datalight, Inc. 4 * All Rights Reserved Worldwide. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; use version 2 of the License. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but "AS-IS," 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. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 /* Businesses and individuals that for commercial or other reasons cannot 21 * comply with the terms of the GPLv2 license may obtain a commercial license 22 * before incorporating Reliance Edge into proprietary software for 23 * distribution in any form. Visit http://www.datalight.com/reliance-edge for 24 * more information. 25 */ 26 27 /** @file 28 */ 29 #ifndef REDVOLUME_H 30 #define REDVOLUME_H 31 32 33 /** @brief Per-volume configuration structure. 34 * 35 * Contains the configuration values that may differ between volumes. Must be 36 * declared in an array in redconf.c in the Reliance Edge project directory and 37 * statically initialized with values representing the volume configuration of 38 * the target system. 39 */ 40 typedef struct 41 { 42 /** The sector size for the block device underlying the volume: the basic 43 * unit for reading and writing to the storage media. Commonly ranges 44 * between 512 and 4096, but any power-of-two value not greater than the 45 * block size will work. 46 */ 47 uint32_t ulSectorSize; 48 49 /** The number of sectors in this file system volume. 50 */ 51 uint64_t ullSectorCount; 52 53 /** Whether a sector write on the block device underlying the volume is 54 * atomic. It is atomic if when the sector write is interrupted, the 55 * contents of the sector are guaranteed to be either all of the new data, 56 * or all of the old data. If unsure, leave as false. 57 */ 58 bool fAtomicSectorWrite; 59 60 /** This is the maximum number of inodes (files and directories). This 61 * number includes the root directory inode (inode 2; created during 62 * format), but does not include inodes 0 or 1, which do not exist on 63 * disk. The number of inodes cannot be less than 1. 64 */ 65 uint32_t ulInodeCount; 66 67 /** This is the maximum number of times a block device I/O operation will 68 * be retried. If a block device read, write, or flush fails, Reliance 69 * Edge will try again up to this number of times until the operation is 70 * successful. Set this to 0 to disable retries. 71 */ 72 uint8_t bBlockIoRetries; 73 74 #if REDCONF_API_POSIX == 1 75 76 /** The path prefix for the volume; for example, "VOL1:", "FlashDisk", etc. 77 */ 78 const char * pszPathPrefix; 79 #endif 80 } VOLCONF; 81 82 extern const VOLCONF gaRedVolConf[ REDCONF_VOLUME_COUNT ]; 83 extern const VOLCONF * CONST_IF_ONE_VOLUME gpRedVolConf; 84 85 86 /** @brief Per-volume run-time data. 87 */ 88 typedef struct 89 { 90 /** Whether the volume is currently mounted. 91 */ 92 bool fMounted; 93 94 #if REDCONF_READ_ONLY == 0 95 96 /** Whether the volume is read-only. 97 */ 98 bool fReadOnly; 99 100 /** The active automatic transaction mask. 101 */ 102 uint32_t ulTransMask; 103 #endif 104 105 /** The power of 2 difference between sector size and block size. 106 */ 107 uint8_t bBlockSectorShift; 108 109 /** The number of logical blocks in this file system volume. The unit here 110 * is the global block size. 111 */ 112 uint32_t ulBlockCount; 113 114 /** The total number of allocable blocks; Also the maximum count of free 115 * blocks. 116 */ 117 uint32_t ulBlocksAllocable; 118 119 /** The maximum number of bytes that an inode is capable of addressing. 120 */ 121 uint64_t ullMaxInodeSize; 122 123 /** The current metadata sequence number. This value is included in all 124 * metadata nodes and incremented every time a metadata node is written. 125 * It is assumed to never wrap around. 126 */ 127 uint64_t ullSequence; 128 } VOLUME; 129 130 /* Array of VOLUME structures, populated at during RedCoreInit(). 131 */ 132 extern VOLUME gaRedVolume[ REDCONF_VOLUME_COUNT ]; 133 134 /* Volume number currently being accessed; populated during 135 * RedCoreVolSetCurrent(). 136 */ 137 extern CONST_IF_ONE_VOLUME uint8_t gbRedVolNum; 138 139 /* Pointer to the volume currently being accessed; populated during 140 * RedCoreVolSetCurrent(). 141 */ 142 extern VOLUME * CONST_IF_ONE_VOLUME gpRedVolume; 143 144 #endif /* ifndef REDVOLUME_H */ 145