[eb91db7] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Frantisek Princ
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libext4
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef LIBEXT4_LIBEXT4_INODE_H_
|
---|
| 34 | #define LIBEXT4_LIBEXT4_INODE_H_
|
---|
| 35 |
|
---|
[6c501f8] | 36 | #include <libblock.h>
|
---|
[9875711] | 37 | #include <sys/types.h>
|
---|
| 38 |
|
---|
[9c0c0e1] | 39 | #define EXT4_DIRECT_BLOCK_COUNT 12
|
---|
| 40 | #define EXT4_INDIRECT_BLOCK EXT4_DIRECT_BLOCK_COUNT
|
---|
| 41 | #define EXT4_DOUBLE_INDIRECT_BLOCK (EXT4_INDIRECT_BLOCK + 1)
|
---|
| 42 | #define EXT4_TRIPPLE_INDIRECT_BLOCK (EXT4_DOUBLE_INDIRECT_BLOCK + 1)
|
---|
| 43 | #define EXT4_INODE_BLOCKS (EXT4_TRIPPLE_INDIRECT_BLOCK + 1)
|
---|
[9875711] | 44 |
|
---|
| 45 | /*
|
---|
| 46 | * Structure of an inode on the disk
|
---|
| 47 | */
|
---|
| 48 | typedef struct ext4_inode {
|
---|
[9c0c0e1] | 49 | uint16_t mode; // File mode
|
---|
| 50 | uint16_t uid; // Low 16 bits of owner uid
|
---|
| 51 | uint32_t size_lo; // Size in bytes
|
---|
[9875711] | 52 |
|
---|
[9c0c0e1] | 53 | // TODO Used in HelenOS ???
|
---|
| 54 | uint32_t atime; // Access time
|
---|
| 55 | uint32_t ctime; // Inode change time
|
---|
| 56 | uint32_t mtime; // Modification time
|
---|
| 57 | uint32_t dtime; // Deletion time
|
---|
[9875711] | 58 |
|
---|
[9c0c0e1] | 59 | uint16_t gid; // Low 16 bits of group id
|
---|
| 60 | uint16_t links_count; // Links count
|
---|
| 61 | uint32_t blocks_lo; // Blocks count
|
---|
| 62 | uint32_t flags; // File flags
|
---|
| 63 | uint32_t unused_osd1; // OS dependent - not used in HelenOS
|
---|
| 64 | uint32_t blocks[EXT4_INODE_BLOCKS]; // Pointers to blocks
|
---|
| 65 | uint32_t generation; // File version (for NFS)
|
---|
| 66 | uint32_t file_acl_lo; // File ACL
|
---|
| 67 | uint32_t size_hi;
|
---|
| 68 | uint32_t obso_faddr; // Obsoleted fragment address
|
---|
| 69 | uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS
|
---|
| 70 | uint16_t extra_isize;
|
---|
| 71 | uint16_t pad1;
|
---|
| 72 | uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch)
|
---|
| 73 | uint32_t mtime_extra; // Extra Modification time (nsec << 2 | epoch)
|
---|
| 74 | uint32_t atime_extra; // Extra Access time (nsec << 2 | epoch)
|
---|
| 75 | uint32_t crtime; // File creation time
|
---|
| 76 | uint32_t crtime_extra; // Extra file creation time (nsec << 2 | epoch)
|
---|
| 77 | uint32_t version_hi; // High 32 bits for 64-bit version
|
---|
[9875711] | 78 | } __attribute__ ((packed)) ext4_inode_t;
|
---|
| 79 |
|
---|
| 80 |
|
---|
[6c501f8] | 81 | #define EXT4_INODE_ROOT_INDEX 2
|
---|
| 82 |
|
---|
| 83 | typedef struct ext4_inode_ref {
|
---|
| 84 | block_t *block; // Reference to a block containing this inode
|
---|
| 85 | ext4_inode_t *inode;
|
---|
| 86 | uint32_t index; // Index number of this inode
|
---|
| 87 | } ext4_inode_ref_t;
|
---|
| 88 |
|
---|
| 89 | extern uint16_t ext4_inode_get_usage_count(ext4_inode_t *);
|
---|
[eb91db7] | 90 |
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
| 93 | /**
|
---|
| 94 | * @}
|
---|
| 95 | */
|
---|