if (ret)
return NULL;
inode_item = *(struct btrfs_inode_item *)path.data;
- if (!(inode = alloc_inode(fs, inr, sizeof(u64))))
+ if (!(inode = alloc_inode(fs, inr, sizeof(struct btrfs_pvt_inode))))
return NULL;
inode->ino = inr;
inode->size = inode_item.size;
+ offsetof(struct btrfs_file_extent_item, disk_bytenr);
else
offset = extent_item.disk_bytenr;
- *(u64 *)inode->pvt = offset;
+ PVT(inode)->offset = offset;
}
return inode;
}
static int btrfs_readlink(struct inode *inode, char *buf)
{
- btrfs_read(buf, logical_physical(*(u64 *)inode->pvt), inode->size);
+ btrfs_read(buf, logical_physical(PVT(inode)->offset), inode->size);
buf[inode->size] = '\0';
return inode->size;
}
struct inode *inode = file->inode;
struct disk *disk = fs->fs_dev->disk;
u32 sec_shift = fs->fs_dev->disk->sector_shift;
- u32 phy = logical_physical(*(u64 *)inode->pvt + file->offset);
+ u32 phy = logical_physical(PVT(inode)->offset + file->offset);
u32 sec = phy >> sec_shift;
u32 off = phy - (sec << sec_shift);
u32 remain = file->file_len - file->offset;
__le16 name_len;
} __attribute__ ((__packed__));
+/*
+ * btrfs private inode information
+ */
+struct btrfs_pvt_inode {
+ uint64_t offset;
+};
+
+#define PVT(i) ((struct btrfs_pvt_inode *)((i)->pvt))
+
#endif
int i;
block_t start;
- leaf = ext4_find_leaf(fs, (const struct ext4_extent_header *)inode->pvt,
- block);
+ leaf = ext4_find_leaf(fs, &PVT(inode)->i_extent_hdr, block);
if (!leaf) {
printf("ERROR, extent leaf not found\n");
return 0;
/* direct blocks */
if (block < direct_blocks)
- return ((uint32_t *)inode->pvt)[block];
+ return PVT(inode)->i_block[block];
/* indirect blocks */
block -= direct_blocks;
if (block < indirect_blocks)
- return bmap_indirect(fs, ((uint32_t *)inode->pvt)[EXT2_IND_BLOCK],
+ return bmap_indirect(fs, PVT(inode)->i_block[EXT2_IND_BLOCK],
block, 1);
/* double indirect blocks */
block -= indirect_blocks;
if (block < double_blocks)
- return bmap_indirect(fs, ((uint32_t *)inode->pvt)[EXT2_DIND_BLOCK],
+ return bmap_indirect(fs, PVT(inode)->i_block[EXT2_DIND_BLOCK],
block, 2);
/* triple indirect block */
block -= double_blocks;
if (block < triple_blocks)
- return bmap_indirect(fs, ((uint32_t *)inode->pvt)[EXT2_TIND_BLOCK],
+ return bmap_indirect(fs, PVT(inode)->i_block[EXT2_TIND_BLOCK],
block, 3);
/* This can't happen... */
*
* @fs: the fs_info structure.
* @inode: the inode structure.
- * @block: the logical blcok needed to be maped.
- * @retrun: the physic block number.
+ * @block: the logical block to be mapped.
+ * @retrun: the physical block number.
*
*/
block_t ext2_bmap(struct inode *inode, block_t block)
inode->blocks = e_inode->i_blocks;
inode->flags = e_inode->i_flags;
inode->file_acl = e_inode->i_file_acl;
- memcpy(inode->pvt, e_inode->i_block, EXT2_N_BLOCKS * sizeof(uint32_t *));
+ memcpy(PVT(inode)->i_block, e_inode->i_block,
+ EXT2_N_BLOCKS * sizeof(uint32_t *));
}
static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
struct inode *inode;
e_inode = ext2_get_inode(fs, inr);
- if (!(inode = alloc_inode(fs, inr, EXT2_N_BLOCKS*sizeof(uint32_t *))))
+ if (!(inode = alloc_inode(fs, inr, sizeof(struct ext2_pvt_inode))))
return NULL;
fill_inode(inode, e_inode);
return -1; /* Error! */
fast_symlink = (inode->file_acl ? sec_per_block : 0) == inode->blocks;
- if (fast_symlink) {
- memcpy(buf, inode->pvt, inode->size);
- } else {
+ if (fast_symlink)
+ memcpy(buf, PVT(inode)->i_block, inode->size);
+ else
cache_get_file(inode, buf, inode->size);
- }
return inode->size;
}
#define EXT2_INODES_PER_BLOCK(fs) (EXT2_SB(fs)->s_inodes_per_block)
#define EXT2_DESC_PER_BLOCK(fs) (EXT2_SB(fs)->s_desc_per_block)
+/*
+ * ext2 private inode information
+ */
+struct ext2_pvt_inode {
+ union {
+ uint32_t i_block[EXT2_N_BLOCKS];
+ struct ext4_extent_header i_extent_hdr;
+ };
+};
+
+#define PVT(i) ((struct ext2_pvt_inode *)((i)->pvt))
/*
* functions
static struct inode *new_iso_inode(struct fs_info *fs)
{
- return alloc_inode(fs, 0, sizeof(uint32_t));
+ return alloc_inode(fs, 0, sizeof(struct iso9660_pvt_inode));
}
-static inline struct iso_sb_info * ISO_SB(struct fs_info *fs)
+static inline struct iso_sb_info *ISO_SB(struct fs_info *fs)
{
return fs->fs_info;
}
uint32_t bytes_left = file->inode->size - file->offset;
uint32_t blocks_left = (bytes_left + BLOCK_SIZE(file->fs) - 1)
>> file->fs->block_shift;
- block_t block = *(uint32_t *)file->inode->pvt
- + (file->offset >> fs->block_shift);
+ block_t block = PVT(file->inode)->lba + (file->offset >> fs->block_shift);
if (blocks > blocks_left)
blocks = blocks_left;
iso_find_entry(const char *dname, struct inode *inode)
{
struct fs_info *fs = inode->fs;
- block_t dir_block = *(uint32_t *)inode->pvt;
+ block_t dir_block = PVT(inode)->lba;
int i = 0, offset = 0;
const char *de_name;
int de_name_len, de_len;
return NULL;
inode->mode = get_inode_mode(de->flags);
- inode->size = *(uint32_t *)de->size;
- *(uint32_t *)inode->pvt = *(uint32_t *)de->extent;
+ inode->size = de->size_le;
+ PVT(inode)->lba = de->extent_le;
inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1)
>> fs->block_shift;
return NULL;
inode->mode = I_DIR;
- inode->size = *(uint32_t *)root->size;
- *(uint32_t *)inode->pvt = *(uint32_t *)root->extent;
- inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1)
- >> fs->block_shift;
+ inode->size = root->size_le;
+ PVT(inode)->lba = root->extent_le;
+ inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1) >> BLOCK_SHIFT(fs);
return inode;
}
#ifndef ISO9660_FS_H
#define ISO9660_FS_H
+#include <klibc/compiler.h>
#include <stdint.h>
/* The root dir entry offset in the primary volume descriptor */
#define ROOT_DIR_OFFSET 156
struct iso_dir_entry {
- uint8_t length; /* 00 */
- uint8_t ext_attr_length; /* 01 */
- uint8_t extent[8]; /* 02 */
- uint8_t size[8]; /* 0a */
- uint8_t date[7]; /* 12 */
- uint8_t flags; /* 19 */
- uint8_t file_unit_size; /* 1a */
- uint8_t interleave; /* 1b */
- uint8_t volume_sequence_number[4]; /* 1c */
- uint8_t name_len; /* 20 */
- char name[0]; /* 21 */
-};
+ uint8_t length; /* 00 */
+ uint8_t ext_attr_length; /* 01 */
+ uint32_t extent_le; /* 02 */
+ uint32_t extent_be; /* 06 */
+ uint32_t size_le; /* 0a */
+ uint32_t size_be; /* 0e */
+ uint8_t date[7]; /* 12 */
+ uint8_t flags; /* 19 */
+ uint8_t file_unit_size; /* 1a */
+ uint8_t interleave; /* 1b */
+ uint16_t volume_sequence_number_le; /* 1c */
+ uint16_t volume_sequence_number_be; /* 1e */
+ uint8_t name_len; /* 20 */
+ char name[0]; /* 21 */
+} __packed;
struct iso_sb_info {
- struct iso_dir_entry root;
+ struct iso_dir_entry root;
+};
+
+/*
+ * iso9660 private inode information
+ */
+struct iso9660_pvt_inode {
+ uint32_t lba; /* Starting LBA of file data area*/
};
+#define PVT(i) ((struct iso9660_pvt_inode *)((i)->pvt))
+
#endif /* iso9660_fs.h */