source: mainline/uspace/lib/ext4/libext4_inode.h@ 9b9d37bb

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9b9d37bb was 9b9d37bb, checked in by Frantisek Princ <frantisek.princ@…>, 14 years ago

mounting + list of mounted directory (ported from ext2) - many TODO remaining

  • Property mode set to 100644
File size: 5.9 KB
Line 
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
36#include <libblock.h>
37#include <sys/types.h>
38#include "libext4_superblock.h"
39
40
41#define EXT4_INODE_DIRECT_BLOCK_COUNT 12
42#define EXT4_INODE_INDIRECT_BLOCK EXT4_INODE_DIRECT_BLOCK_COUNT
43#define EXT4_INODE_DOUBLE_INDIRECT_BLOCK (EXT4_INODE_INDIRECT_BLOCK + 1)
44#define EXT4_INODE_TRIPPLE_INDIRECT_BLOCK (EXT4_INODE_DOUBLE_INDIRECT_BLOCK + 1)
45#define EXT4_INODE_BLOCKS (EXT4_INODE_TRIPPLE_INDIRECT_BLOCK + 1)
46#define EXT4_INODE_INDIRECT_BLOCK_COUNT (EXT4_INODE_BLOCKS - EXT4_INODE_DIRECT_BLOCK_COUNT)
47
48/*
49 * Structure of an inode on the disk
50 */
51typedef struct ext4_inode {
52 uint16_t mode; // File mode
53 uint16_t uid; // Low 16 bits of owner uid
54 uint32_t size_lo; // Size in bytes
55 uint32_t acess_time; // Access time
56 uint32_t change_inode_time; // Inode change time
57 uint32_t modification_time; // Modification time
58 uint32_t deletion_time; // Deletion time
59 uint16_t gid; // Low 16 bits of group id
60 uint16_t links_count; // Links count
61 uint32_t blocks_count_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 union {
70 struct {
71 uint16_t blocks_high; /* were l_i_reserved1 */
72 uint16_t file_acl_high;
73 uint16_t uid_high; /* these 2 fields */
74 uint16_t gid_high; /* were reserved2[0] */
75 uint32_t reserved2;
76 } linux2;
77 struct {
78 uint16_t reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
79 uint16_t mode_high;
80 uint16_t uid_high;
81 uint16_t gid_high;
82 uint32_t author;
83 } hurd2;
84 struct {
85 uint16_t reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
86 uint16_t file_acl_high;
87 uint32_t reserved2[2];
88 } masix2;
89 } __attribute__ ((packed)) osd2;
90
91 uint16_t extra_isize;
92 uint16_t pad1;
93 uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch)
94 uint32_t mtime_extra; // Extra Modification time (nsec << 2 | epoch)
95 uint32_t atime_extra; // Extra Access time (nsec << 2 | epoch)
96 uint32_t crtime; // File creation time
97 uint32_t crtime_extra; // Extra file creation time (nsec << 2 | epoch)
98 uint32_t version_hi; // High 32 bits for 64-bit version
99} __attribute__ ((packed)) ext4_inode_t;
100
101#define EXT4_INODE_MODE_FIFO 0x1000
102#define EXT4_INODE_MODE_CHARDEV 0x2000
103#define EXT4_INODE_MODE_DIRECTORY 0x4000
104#define EXT4_INODE_MODE_BLOCKDEV 0x6000
105#define EXT4_INODE_MODE_FILE 0x8000
106#define EXT4_INODE_MODE_SOFTLINK 0xA000
107#define EXT4_INODE_MODE_SOCKET 0xC000
108#define EXT4_INODE_MODE_TYPE_MASK 0xF000
109
110#define EXT4_INODE_ROOT_INDEX 2
111
112typedef struct ext4_inode_ref {
113 block_t *block; // Reference to a block containing this inode
114 ext4_inode_t *inode;
115 uint32_t index; // Index number of this inode
116} ext4_inode_ref_t;
117
118
119extern uint32_t ext4_inode_get_mode(ext4_superblock_t *, ext4_inode_t *);
120extern bool ext4_inode_is_type(ext4_superblock_t *, ext4_inode_t *, uint32_t);
121/*
122extern uint32_t ext4_inode_get_uid(ext4_inode_t *);
123*/
124extern uint64_t ext4_inode_get_size(ext4_superblock_t *, ext4_inode_t *);
125/*
126extern uint32_t ext4_inode_get_access_time(ext4_inode_t *);
127extern uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *);
128extern uint32_t ext4_inode_get_modification_time(ext4_inode_t *);
129extern uint32_t ext4_inode_get_deletion_time(ext4_inode_t *);
130extern uint32_t ext4_inode_get_gid(ext4_inode_t *);
131*/
132extern uint16_t ext4_inode_get_links_count(ext4_inode_t *);
133/*
134extern uint64_t ext4_inode_get_blocks_count(ext4_inode_t *);
135extern uint32_t ext4_inode_get_flags(ext4_inode_t *);
136*/
137
138uint32_t ext4_inode_get_direct_block(ext4_inode_t *, uint8_t);
139uint32_t ext4_inode_get_indirect_block(ext4_inode_t *, uint8_t);
140
141/*
142uint32_t blocks[EXT4_INODE_BLOCKS]; // Pointers to blocks
143uint32_t generation;
144uint32_t file_acl_lo; // File ACL
145uint16_t extra_isize;
146uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch)
147uint32_t mtime_extra; // Extra Modification time (nsec << 2 | epoch)
148uint32_t atime_extra; // Extra Access time (nsec << 2 | epoch)
149uint32_t crtime; // File creation time
150uint32_t crtime_extra; // Extra file creation time (nsec << 2 | epoch)
151uint32_t version_hi; // High 32 bits for 64-bit version
152*/
153
154#endif
155
156/**
157 * @}
158 */
Note: See TracBrowser for help on using the repository browser.