Changeset 38542dc in mainline for uspace/lib/ext4/libext4_inode.c


Ignore:
Timestamp:
2012-08-12T18:36:10Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49505fe
Parents:
b08e7970
Message:

ext4 code review and coding style cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_inode.c

    rb08e7970 r38542dc  
    2929/** @addtogroup libext4
    3030 * @{
    31  */
    32 
     31 */
    3332/**
    34  * @file        libext4_inode.c
    35  * @brief       Ext4 inode structure operations.
     33 * @file  libext4_inode.c
     34 * @brief Ext4 i-node structure operations.
    3635 */
    3736
     
    4342/** Compute number of bits for block count.
    4443 *
    45  *  @param block_size   filesystem block_size
    46  *  @return             number of bits
     44 *  @param block_size Filesystem block_size
     45 *
     46 *  @return Number of bits
     47 *
    4748 */
    4849static uint32_t ext4_inode_block_bits_count(uint32_t block_size)
     
    5051        uint32_t bits = 8;
    5152        uint32_t size = block_size;
    52 
     53       
    5354        do {
    5455                bits++;
    5556                size = size >> 1;
    5657        } while (size > 256);
    57 
     58       
    5859        return bits;
    5960}
     
    6162/** Get mode of the i-node.
    6263 *
    63  * @param sb            superblock
    64  * @param inode         i-node to load mode from
    65  * @return              mode of the i-node
     64 * @param sb    Superblock
     65 * @param inode I-node to load mode from
     66 *
     67 * @return Mode of the i-node
     68 *
    6669 */
    6770uint32_t ext4_inode_get_mode(ext4_superblock_t *sb, ext4_inode_t *inode)
    6871{
    6972        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_HURD) {
    70                 return ((uint32_t)uint16_t_le2host(inode->osd2.hurd2.mode_high)) << 16 |
    71                     ((uint32_t)uint16_t_le2host(inode->mode));
     73                return ((uint32_t) uint16_t_le2host(inode->osd2.hurd2.mode_high)) << 16 |
     74                    ((uint32_t) uint16_t_le2host(inode->mode));
    7275        }
     76       
    7377        return uint16_t_le2host(inode->mode);
    7478}
     
    7680/** Set mode of the i-node.
    7781 *
    78  * @param sb            superblock
    79  * @param inode         i-node to set mode to
    80  * @param mode          mode to set to i-node
     82 * @param sb    Superblock
     83 * @param inode I-node to set mode to
     84 * @param mode  Mode to set to i-node
     85 *
    8186 */
    8287void ext4_inode_set_mode(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t mode)
    8388{
    8489        inode->mode = host2uint16_t_le((mode << 16) >> 16);
    85 
    86         if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_HURD) {
     90       
     91        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_HURD)
    8792                inode->osd2.hurd2.mode_high = host2uint16_t_le(mode >> 16);
    88         }
    8993}
    9094
    9195/** Get ID of the i-node owner (user id).
    9296 *
    93  * @param inode         i-node to load uid from
    94  * @return              user ID of the i-node owner
     97 * @param inode I-node to load uid from
     98 *
     99 * @return User ID of the i-node owner
     100 *
    95101 */
    96102uint32_t ext4_inode_get_uid(ext4_inode_t *inode)
     
    101107/** Set ID of the i-node owner.
    102108 *
    103  * @param inode         i-node to set uid to
    104  * @param uid           ID of the i-node owner
     109 * @param inode I-node to set uid to
     110 * @param uid   ID of the i-node owner
     111 *
    105112 */
    106113void ext4_inode_set_uid(ext4_inode_t *inode, uint32_t uid)
     
    111118/** Get real i-node size.
    112119 *
    113  * @param sb            superblock
    114  * @param inode         i-node to load size from
    115  * @return              real size of i-node
     120 * @param sb    Superblock
     121 * @param inode I-node to load size from
     122 *
     123 * @return Real size of i-node
     124 *
    116125 */
    117126uint64_t ext4_inode_get_size(ext4_superblock_t *sb, ext4_inode_t *inode)
    118127{
    119128        uint32_t major_rev = ext4_superblock_get_rev_level(sb);
    120 
    121         if ((major_rev > 0) && ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)) {
     129       
     130        if ((major_rev > 0) &&
     131            (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)))
    122132                return ((uint64_t)uint32_t_le2host(inode->size_hi)) << 32 |
    123                             ((uint64_t)uint32_t_le2host(inode->size_lo));
    124         }
     133                    ((uint64_t)uint32_t_le2host(inode->size_lo));
     134       
    125135        return uint32_t_le2host(inode->size_lo);
    126136}
     
    128138/** Set real i-node size.
    129139 *
    130  *  @param inode        inode to set size to
    131  *  @param size         size of the i-node
    132  */
    133 void ext4_inode_set_size(ext4_inode_t *inode, uint64_t size) {
     140 * @param inode I-node to set size to
     141 * @param size  Size of the i-node
     142 *
     143 */
     144void ext4_inode_set_size(ext4_inode_t *inode, uint64_t size)
     145{
    134146        inode->size_lo = host2uint32_t_le((size << 32) >> 32);
    135147        inode->size_hi = host2uint32_t_le(size >> 32);
     
    138150/** Get time, when i-node was last accessed.
    139151 *
    140  * @param inode         i-node
    141  * @return                      time of the last access (POSIX)
     152 * @param inode I-node
     153 *
     154 * @return Time of the last access (POSIX)
     155 *
    142156 */
    143157uint32_t ext4_inode_get_access_time(ext4_inode_t *inode)
     
    148162/** Set time, when i-node was last accessed.
    149163 *
    150  * @param inode         i-node
    151  * @param time          time of the last access (POSIX)
     164 * @param inode I-node
     165 * @param time  Time of the last access (POSIX)
     166 *
    152167 */
    153168void ext4_inode_set_access_time(ext4_inode_t *inode, uint32_t time)
     
    158173/** Get time, when i-node was last changed.
    159174 *
    160  * @param inode         i-node
    161  * @return                      time of the last change (POSIX)
     175 * @param inode I-node
     176 *
     177 * @return Time of the last change (POSIX)
     178 *
    162179 */
    163180uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *inode)
     
    168185/** Set time, when i-node was last changed.
    169186 *
    170  * @param inode         i-node
    171  * @param time          time of the last change (POSIX)
     187 * @param inode I-node
     188 * @param time  Time of the last change (POSIX)
     189 *
    172190 */
    173191void ext4_inode_set_change_inode_time(ext4_inode_t *inode, uint32_t time)
     
    178196/** Get time, when i-node content was last modified.
    179197 *
    180  * @param inode         i-node
    181  * @return                      time of the last content modification (POSIX)
     198 * @param inode I-node
     199 *
     200 * @return Time of the last content modification (POSIX)
     201 *
    182202 */
    183203uint32_t ext4_inode_get_modification_time(ext4_inode_t *inode)
     
    188208/** Set time, when i-node content was last modified.
    189209 *
    190  * @param inode         i-node
    191  * @param time          time of the last content modification (POSIX)
     210 * @param inode I-node
     211 * @param time  Time of the last content modification (POSIX)
     212 *
    192213 */
    193214void ext4_inode_set_modification_time(ext4_inode_t *inode, uint32_t time)
     
    198219/** Get time, when i-node was deleted.
    199220 *
    200  * @param inode         i-node
    201  * @return                      time of the delete action (POSIX)
     221 * @param inode I-node
     222 *
     223 * @return Time of the delete action (POSIX)
     224 *
    202225 */
    203226uint32_t ext4_inode_get_deletion_time(ext4_inode_t *inode)
     
    208231/** Set time, when i-node was deleted.
    209232 *
    210  * @param inode         i-node
    211  * @param time          time of the delete action (POSIX)
     233 * @param inode I-node
     234 * @param time  Time of the delete action (POSIX)
     235 *
    212236 */
    213237void ext4_inode_set_deletion_time(ext4_inode_t *inode, uint32_t time)
     
    218242/** Get ID of the i-node owner's group.
    219243 *
    220  * @param inode         i-node to load gid from
    221  * @return              group ID of the i-node owner
     244 * @param inode I-node to load gid from
     245 *
     246 * @return Group ID of the i-node owner
     247 *
    222248 */
    223249uint32_t ext4_inode_get_gid(ext4_inode_t *inode)
     
    228254/** Set ID ot the i-node owner's group.
    229255 *
    230  * @param inode         i-node to set gid to
    231  * @param gid           group ID of the i-node owner
     256 * @param inode I-node to set gid to
     257 * @param gid   Group ID of the i-node owner
     258 *
    232259 */
    233260void ext4_inode_set_gid(ext4_inode_t *inode, uint32_t gid)
     
    238265/** Get number of links to i-node.
    239266 *
    240  * @param inode         i-node to load number of links from
    241  * @return              number of links to i-node
     267 * @param inode I-node to load number of links from
     268 *
     269 * @return Number of links to i-node
     270 *
    242271 */
    243272uint16_t ext4_inode_get_links_count(ext4_inode_t *inode)
     
    248277/** Set number of links to i-node.
    249278 *
    250  * @param inode         i-node to set number of links to
    251  * @param count         number of links to i-node
     279 * @param inode I-node to set number of links to
     280 * @param count Number of links to i-node
     281 *
    252282 */
    253283void ext4_inode_set_links_count(ext4_inode_t *inode, uint16_t count)
     
    258288/** Get number of 512-bytes blocks used for i-node.
    259289 *
    260  * @param sb            superblock
    261  * @param inode         i-node
    262  * @return                      number of 512-bytes blocks
     290 * @param sb    Superblock
     291 * @param inode I-node
     292 *
     293 * @return Number of 512-bytes blocks
     294 *
    263295 */
    264296uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode)
    265297{
    266         if (ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
    267 
     298        if (ext4_superblock_has_feature_read_only(sb,
     299            EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
    268300                /* 48-bit field */
    269                 uint64_t count = ((uint64_t)uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 |
    270                                 uint32_t_le2host(inode->blocks_count_lo);
    271 
     301                uint64_t count = ((uint64_t)
     302                    uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 |
     303                    uint32_t_le2host(inode->blocks_count_lo);
     304               
    272305                if (ext4_inode_has_flag(inode, EXT4_INODE_FLAG_HUGE_FILE)) {
    273                 uint32_t block_size = ext4_superblock_get_block_size(sb);
    274                 uint32_t block_bits = ext4_inode_block_bits_count(block_size);
    275                         return count  << (block_bits - 9);
    276                 } else {
     306                        uint32_t block_size = ext4_superblock_get_block_size(sb);
     307                        uint32_t block_bits = ext4_inode_block_bits_count(block_size);
     308                        return count << (block_bits - 9);
     309                } else
    277310                        return count;
    278                 }
     311        } else
     312                return uint32_t_le2host(inode->blocks_count_lo);
     313}
     314
     315/** Set number of 512-bytes blocks used for i-node.
     316 *
     317 * @param sb    Superblock
     318 * @param inode I-node
     319 * @param count Number of 512-bytes blocks
     320 *
     321 * @return Error code
     322 *
     323 */
     324int ext4_inode_set_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode,
     325    uint64_t count)
     326{
     327        /* 32-bit maximum */
     328        uint64_t max = 0;
     329        max = ~max >> 32;
     330       
     331        if (count <= max) {
     332                inode->blocks_count_lo = host2uint32_t_le(count);
     333                inode->osd2.linux2.blocks_high = 0;
     334                ext4_inode_clear_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
     335               
     336                return EOK;
     337        }
     338       
     339        /* Check if there can be used huge files (many blocks) */
     340        if (!ext4_superblock_has_feature_read_only(sb,
     341            EXT4_FEATURE_RO_COMPAT_HUGE_FILE))
     342                return EINVAL;
     343       
     344        /* 48-bit maximum */
     345        max = 0;
     346        max = ~max >> 16;
     347       
     348        if (count <= max) {
     349                inode->blocks_count_lo = host2uint32_t_le(count);
     350                inode->osd2.linux2.blocks_high = host2uint16_t_le(count >> 32);
     351                ext4_inode_clear_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
    279352        } else {
    280                 return uint32_t_le2host(inode->blocks_count_lo);
    281     }
    282 }
    283 
    284 /** Set number of 512-bytes blocks used for i-node.
    285  *
    286  * @param sb            superblock
    287  * @param inode         i-node
    288  * @param count         number of 512-bytes blocks
    289  * @return                      error code
    290  */
    291 int ext4_inode_set_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode,
    292                 uint64_t count)
    293 {
    294     /* 32-bit maximum */
    295     uint64_t max = 0;
    296     max = ~max >> 32;
    297 
    298     if (count <= max) {
    299         inode->blocks_count_lo = host2uint32_t_le(count);
    300         inode->osd2.linux2.blocks_high = 0;
    301         ext4_inode_clear_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
    302         return EOK;
    303     }
    304 
    305     /* Check if there can be used huge files (many blocks) */
    306     if (!ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
    307         return EINVAL;
    308     }
    309 
    310     /* 48-bit maximum */
    311     max = 0;
    312     max = ~max >> 16;
    313 
    314     if (count <= max) {
    315         inode->blocks_count_lo = host2uint32_t_le(count);
    316         inode->osd2.linux2.blocks_high = host2uint16_t_le(count >> 32);
    317         ext4_inode_clear_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
    318     } else {
    319         uint32_t block_size = ext4_superblock_get_block_size(sb);
    320         uint32_t block_bits = ext4_inode_block_bits_count(block_size);
    321         ext4_inode_set_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
    322         count = count >> (block_bits - 9);
    323         inode->blocks_count_lo = host2uint32_t_le(count);
    324         inode->osd2.linux2.blocks_high = host2uint16_t_le(count >> 32);
    325     }
    326     return EOK;
     353                uint32_t block_size = ext4_superblock_get_block_size(sb);
     354                uint32_t block_bits = ext4_inode_block_bits_count(block_size);
     355                ext4_inode_set_flag(inode, EXT4_INODE_FLAG_HUGE_FILE);
     356                count = count >> (block_bits - 9);
     357                inode->blocks_count_lo = host2uint32_t_le(count);
     358                inode->osd2.linux2.blocks_high = host2uint16_t_le(count >> 32);
     359        }
     360       
     361        return EOK;
    327362}
    328363
    329364/** Get flags (features) of i-node.
    330  *
    331  * @param inode         i-node to get flags from
    332  * @return              flags (bitmap)
    333  */
    334 uint32_t ext4_inode_get_flags(ext4_inode_t *inode) {
     365 *
     366 * @param inode I-node to get flags from
     367 *
     368 * @return Flags (bitmap)
     369 *
     370 */
     371uint32_t ext4_inode_get_flags(ext4_inode_t *inode)
     372{
    335373        return uint32_t_le2host(inode->flags);
    336374}
     
    338376/** Set flags (features) of i-node.
    339377 *
    340  * @param inode         i-node to set flags to
    341  * @param flags         flags to set to i-node
    342  */
    343 void ext4_inode_set_flags(ext4_inode_t *inode, uint32_t flags) {
     378 * @param inode I-node to set flags to
     379 * @param flags Flags to set to i-node
     380 *
     381 */
     382void ext4_inode_set_flags(ext4_inode_t *inode, uint32_t flags)
     383{
    344384        inode->flags = host2uint32_t_le(flags);
    345385}
     
    347387/** Get file generation (used by NFS).
    348388 *
    349  * @param inode         i-node
    350  * @return                      file generation
     389 * @param inode I-node
     390 *
     391 * @return File generation
     392 *
    351393 */
    352394uint32_t ext4_inode_get_generation(ext4_inode_t *inode)
     
    357399/** Set file generation (used by NFS).
    358400 *
    359  * @param inode                 i-node
    360  * @param generation    file generation
     401 * @param inode      I-node
     402 * @param generation File generation
     403 *
    361404 */
    362405void ext4_inode_set_generation(ext4_inode_t *inode, uint32_t generation)
     
    367410/** Get address of block, where are extended attributes located.
    368411 *
    369  * @param inode                 i-node
    370  * @param sb                    superblock
    371  * @return                              block address
     412 * @param inode I-node
     413 * @param sb    Superblock
     414 *
     415 * @return Block address
     416 *
    372417 */
    373418uint64_t ext4_inode_get_file_acl(ext4_inode_t *inode, ext4_superblock_t *sb)
    374419{
    375         if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX) {
    376                 return ((uint32_t)uint16_t_le2host(inode->osd2.linux2.file_acl_high)) << 16 |
     420        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX)
     421                return ((uint32_t)
     422                    uint16_t_le2host(inode->osd2.linux2.file_acl_high)) << 16 |
    377423                    (uint32_t_le2host(inode->file_acl_lo));
    378         }
    379 
     424       
    380425        return uint32_t_le2host(inode->file_acl_lo);
    381426}
     
    383428/** Set address of block, where are extended attributes located.
    384429 *
    385  * @param inode                 i-node
    386  * @param sb                    superblock
    387  * @param file_acl              block address
     430 * @param inode    I-node
     431 * @param sb       Superblock
     432 * @param file_acl Block address
     433 *
    388434 */
    389435void ext4_inode_set_file_acl(ext4_inode_t *inode, ext4_superblock_t *sb,
    390                 uint64_t file_acl)
     436    uint64_t file_acl)
    391437{
    392438        inode->file_acl_lo = host2uint32_t_le((file_acl << 32) >> 32);
    393 
    394         if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX) {
     439       
     440        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX)
    395441                inode->osd2.linux2.file_acl_high = host2uint16_t_le(file_acl >> 32);
    396         }
    397 }
    398 
    399 /***********************************************************************/
     442}
    400443
    401444/** Get block address of specified direct block.
    402445 *
    403  * @param inode         i-node to load block from
    404  * @param idx           index of logical block
    405  * @return              physical block address
     446 * @param inode I-node to load block from
     447 * @param idx   Index of logical block
     448 *
     449 * @return Physical block address
     450 *
    406451 */
    407452uint32_t ext4_inode_get_direct_block(ext4_inode_t *inode, uint32_t idx)
    408453{
    409454        assert(idx < EXT4_INODE_DIRECT_BLOCK_COUNT);
     455       
    410456        return uint32_t_le2host(inode->blocks[idx]);
    411457}
     
    413459/** Set block address of specified direct block.
    414460 *
    415  * @param inode         i-node to set block address to
    416  * @param idx           index of logical block
    417  * @param fblock        physical block address
     461 * @param inode  I-node to set block address to
     462 * @param idx    Index of logical block
     463 * @param fblock Physical block address
     464 *
    418465 */
    419466void ext4_inode_set_direct_block(ext4_inode_t *inode, uint32_t idx, uint32_t fblock)
    420467{
    421468        assert(idx < EXT4_INODE_DIRECT_BLOCK_COUNT);
     469       
    422470        inode->blocks[idx] = host2uint32_t_le(fblock);
    423471}
     
    425473/** Get block address of specified indirect block.
    426474 *
    427  * @param inode         i-node to get block address from
    428  * @param idx           index of indirect block
    429  * @return              physical block address
     475 * @param inode I-node to get block address from
     476 * @param idx   Index of indirect block
     477 *
     478 * @return Physical block address
     479 *
    430480 */
    431481uint32_t ext4_inode_get_indirect_block(ext4_inode_t *inode, uint32_t idx)
     
    436486/** Set block address of specified indirect block.
    437487 *
    438  * @param inode         i-node to set block address to
    439  * @param idx           index of indirect block
    440  * @param fblock        physical block address
    441  */
    442 void ext4_inode_set_indirect_block(ext4_inode_t *inode, uint32_t idx, uint32_t fblock)
    443 {
    444         inode->blocks[idx + EXT4_INODE_INDIRECT_BLOCK] = host2uint32_t_le(fblock);
     488 * @param inode  I-node to set block address to
     489 * @param idx    Index of indirect block
     490 * @param fblock Physical block address
     491 *
     492 */
     493void ext4_inode_set_indirect_block(ext4_inode_t *inode, uint32_t idx,
     494    uint32_t fblock)
     495{
     496        inode->blocks[idx + EXT4_INODE_INDIRECT_BLOCK] =
     497            host2uint32_t_le(fblock);
    445498}
    446499
    447500/** Check if i-node has specified type.
    448501 *
    449  * @param sb            superblock
    450  * @param inode         i-node to check type of
    451  * @param type          type to check
    452  * @return              result of check operation
    453  */
    454 bool ext4_inode_is_type(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t type)
     502 * @param sb    Superblock
     503 * @param inode I-node to check type of
     504 * @param type  Type to check
     505 *
     506 * @return Result of check operation
     507 *
     508 */
     509bool ext4_inode_is_type(ext4_superblock_t *sb, ext4_inode_t *inode,
     510    uint32_t type)
    455511{
    456512        uint32_t mode = ext4_inode_get_mode(sb, inode);
     
    460516/** Get extent header from the root of the extent tree.
    461517 *
    462  * @param inode         i-node to get extent header from
    463  * @return              pointer to extent header of the root node
     518 * @param inode I-node to get extent header from
     519 *
     520 * @return Pointer to extent header of the root node
     521 *
    464522 */
    465523ext4_extent_header_t * ext4_inode_get_extent_header(ext4_inode_t *inode)
    466524{
    467         return (ext4_extent_header_t *)inode->blocks;
     525        return (ext4_extent_header_t *) inode->blocks;
    468526}
    469527
    470528/** Check if i-node has specified flag.
    471529 *
    472  * @param inode         i-node to check flags of
    473  * @param flag          flag to check
    474  * @return              result of check operation
     530 * @param inode I-node to check flags of
     531 * @param flag  Flag to check
     532 *
     533 * @return Result of check operation
     534 *
    475535 */
    476536bool ext4_inode_has_flag(ext4_inode_t *inode, uint32_t flag)
    477537{
    478         if (ext4_inode_get_flags(inode) & flag) {
     538        if (ext4_inode_get_flags(inode) & flag)
    479539                return true;
    480         }
     540       
    481541        return false;
    482542}
     
    484544/** Remove specified flag from i-node.
    485545 *
    486  * @param inode         i-node to clear flag on
    487  * @param clear_flag    flag to be cleared
     546 * @param inode      I-node to clear flag on
     547 * @param clear_flag Flag to be cleared
     548 *
    488549 */
    489550void ext4_inode_clear_flag(ext4_inode_t *inode, uint32_t clear_flag)
     
    496557/** Set specified flag to i-node.
    497558 *
    498  * @param inode         i-node to set flag on
    499  * @param set_flag      falt to be set
     559 * @param inode    I-node to set flag on
     560 * @param set_flag Flag to be set
     561 *
    500562 */
    501563void ext4_inode_set_flag(ext4_inode_t *inode, uint32_t set_flag)
     
    508570/** Check if i-node can be truncated.
    509571 *
    510  * @param sb            superblock
    511  * @param inode         i-node to check
    512  * @return              result of the check operation
     572 * @param sb    Superblock
     573 * @param inode I-node to check
     574 *
     575 * @return Result of the check operation
     576 *
    513577 */
    514578bool ext4_inode_can_truncate(ext4_superblock_t *sb, ext4_inode_t *inode)
    515579{
    516          if (ext4_inode_has_flag(inode, EXT4_INODE_FLAG_APPEND)
    517                          || ext4_inode_has_flag(inode, EXT4_INODE_FLAG_IMMUTABLE)) {
    518                  return false;
    519          }
    520 
    521          if (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)
    522                          || ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_DIRECTORY)) {
    523                  return true;
    524          }
    525 
    526          return false;
     580        if ((ext4_inode_has_flag(inode, EXT4_INODE_FLAG_APPEND)) ||
     581            (ext4_inode_has_flag(inode, EXT4_INODE_FLAG_IMMUTABLE)))
     582                return false;
     583       
     584        if ((ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)) ||
     585            (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_DIRECTORY)))
     586                return true;
     587       
     588        return false;
    527589}
    528590
    529591/**
    530592 * @}
    531  */ 
     593 */
Note: See TracChangeset for help on using the changeset viewer.