Changeset b65cae22 in mainline for uspace/lib/ext2/libext2_inode.c
- Timestamp:
- 2011-02-16T20:21:03Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f483a15
- Parents:
- a2a1792
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_inode.c
ra2a1792 rb65cae22 36 36 #include "libext2.h" 37 37 #include "libext2_inode.h" 38 #include "libext2_superblock.h" 38 39 #include <byteorder.h> 39 40 … … 43 44 * @param inode pointer to inode 44 45 */ 45 inline uint 16_t ext2_inode_get_mode(ext2_inode_t *inode)46 inline uint32_t ext2_inode_get_mode(ext2_superblock_t *sb, ext2_inode_t *inode) 46 47 { 48 if (ext2_superblock_get_os(sb) == EXT2_SUPERBLOCK_OS_HURD) { 49 return ((uint32_t)uint16_t_le2host(inode->mode_high)) << 16 | 50 ((uint32_t)uint16_t_le2host(inode->mode)); 51 } 47 52 return uint16_t_le2host(inode->mode); 48 53 } … … 53 58 * @param inode pointer to inode 54 59 */ 55 inline uint32_t ext2_inode_get_user_id(ext2_ inode_t *inode)60 inline uint32_t ext2_inode_get_user_id(ext2_superblock_t *sb, ext2_inode_t *inode) 56 61 { 57 // TODO: use additional OS specific bits 62 uint32_t os = ext2_superblock_get_os(sb); 63 if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) { 64 return ((uint32_t)uint16_t_le2host(inode->user_id_high)) << 16 | 65 ((uint32_t)uint16_t_le2host(inode->user_id)); 66 } 58 67 return uint16_t_le2host(inode->user_id); 59 68 } … … 62 71 * Get size of file 63 72 * 73 * For regular files in revision 1 and later, the high 32 bits of 74 * file size are stored in inode->size_high and are 0 otherwise 75 * 64 76 * @param inode pointer to inode 65 77 */ 66 inline uint 32_t ext2_inode_get_size(ext2_inode_t *inode)78 inline uint64_t ext2_inode_get_size(ext2_superblock_t *sb, ext2_inode_t *inode) 67 79 { 68 // TODO: Directory ACLS! 69 return uint16_t_le2host(inode->size); 80 uint32_t major_rev = ext2_superblock_get_rev_major(sb); 81 uint32_t mode = ext2_inode_get_mode(sb, inode); 82 83 if (major_rev > 0 && mode & EXT2_INODE_MODE_FILE) { 84 return ((uint64_t)uint32_t_le2host(inode->size_high)) << 32 | 85 ((uint64_t)uint32_t_le2host(inode->size)); 86 } 87 return uint32_t_le2host(inode->size); 70 88 } 71 89 … … 73 91 * Get gid this inode belongs to 74 92 * 93 * For Linux and Hurd, the high 16 bits are stored in OS dependent part 94 * of inode structure 95 * 75 96 * @param inode pointer to inode 76 97 */ 77 inline uint32_t ext2_inode_get_group_id(ext2_ inode_t *inode)98 inline uint32_t ext2_inode_get_group_id(ext2_superblock_t *sb, ext2_inode_t *inode) 78 99 { 79 // TODO: use additional OS specific bits 100 uint32_t os = ext2_superblock_get_os(sb); 101 if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) { 102 return ((uint32_t)uint16_t_le2host(inode->group_id_high)) << 16 | 103 ((uint32_t)uint16_t_le2host(inode->group_id)); 104 } 80 105 return uint16_t_le2host(inode->group_id); 81 106 } … … 93 118 94 119 /** 95 * Get size of inode in 512 byte blocks 96 * TODO: clarify this 120 * Get number of 512-byte data blocks allocated for contents of the file 121 * represented by this inode. 122 * This should be multiple of block size unless fragments are used. 97 123 * 98 124 * @param inode pointer to inode … … 108 134 * @param inode pointer to inode 109 135 */ 110 111 136 inline uint32_t ext2_inode_get_flags(ext2_inode_t *inode) { 112 137 return uint32_t_le2host(inode->flags);
Note:
See TracChangeset
for help on using the changeset viewer.