summaryrefslogtreecommitdiff
path: root/core/fs/xfs/xfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/fs/xfs/xfs.c')
-rw-r--r--core/fs/xfs/xfs.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/core/fs/xfs/xfs.c b/core/fs/xfs/xfs.c
index e42e9526..6f459737 100644
--- a/core/fs/xfs/xfs.c
+++ b/core/fs/xfs/xfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -74,10 +74,13 @@ static int xfs_readdir(struct file *file, struct dirent *dirent)
return -1;
}
- if (core->di_format == XFS_DINODE_FMT_LOCAL)
+ switch (core->di_format) {
+ case XFS_DINODE_FMT_LOCAL:
return xfs_fmt_local_readdir(file, dirent, core);
- else if (core->di_format == XFS_DINODE_FMT_EXTENTS)
+ case XFS_DINODE_FMT_EXTENTS:
+ case XFS_DINODE_FMT_BTREE:
return xfs_fmt_extents_readdir(file, dirent, core);
+ }
return -1;
}
@@ -117,8 +120,10 @@ static int xfs_next_extent(struct inode *inode, uint32_t lstart)
goto out;
if (core->di_format == XFS_DINODE_FMT_EXTENTS) {
- bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)&core->di_literal_area[0] +
- XFS_PVT(inode)->i_cur_extent++);
+ bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core,
+ XFS_DATA_FORK) +
+ XFS_PVT(inode)->i_cur_extent);
+ XFS_PVT(inode)->i_cur_extent++;
bno = fsblock_to_bytes(fs, rec.br_startblock) >> BLOCK_SHIFT(fs);
@@ -130,7 +135,7 @@ static int xfs_next_extent(struct inode *inode, uint32_t lstart)
} else if (core->di_format == XFS_DINODE_FMT_BTREE) {
xfs_debug("XFS_DINODE_FMT_BTREE");
index = XFS_PVT(inode)->i_cur_extent++;
- rblock = (xfs_bmdr_block_t *)&core->di_literal_area[0];
+ rblock = XFS_DFORK_PTR(core, XFS_DATA_FORK);
fsize = XFS_DFORK_SIZE(core, fs, XFS_DATA_FORK);
pp = XFS_BMDR_PTR_ADDR(rblock, 1, xfs_bmdr_maxrecs(fsize, 0));
bno = fsblock_to_bytes(fs, be64_to_cpu(pp[0])) >> BLOCK_SHIFT(fs);
@@ -278,9 +283,9 @@ static int xfs_readlink(struct inode *inode, char *buf)
}
if (core->di_format == XFS_DINODE_FMT_LOCAL) {
- memcpy(buf, (char *)&core->di_literal_area[0], pathlen);
+ memcpy(buf, XFS_DFORK_PTR(core, XFS_DATA_FORK), pathlen);
} else if (core->di_format == XFS_DINODE_FMT_EXTENTS) {
- bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)&core->di_literal_area[0]);
+ bmbt_irec_get(&rec, XFS_DFORK_PTR(core, XFS_DATA_FORK));
db = fsblock_to_bytes(fs, rec.br_startblock) >> BLOCK_SHIFT(fs);
dir_buf = xfs_dir2_dirblks_get_cached(fs, db, rec.br_blockcount);
@@ -331,7 +336,7 @@ out:
return NULL;
}
-static inline int xfs_read_superblock(struct fs_info *fs, xfs_sb_t *sb)
+static inline int xfs_read_sb(struct fs_info *fs, xfs_sb_t *sb)
{
struct disk *disk = fs->fs_dev->disk;
@@ -376,24 +381,21 @@ static int xfs_fs_init(struct fs_info *fs)
SECTOR_SHIFT(fs) = disk->sector_shift;
SECTOR_SIZE(fs) = 1 << SECTOR_SHIFT(fs);
- if (xfs_read_superblock(fs, &sb)) {
+ if (xfs_read_sb(fs, &sb)) {
xfs_error("Superblock read failed");
goto out;
}
-
- if (!xfs_is_valid_magicnum(&sb)) {
+ if (!xfs_is_valid_sb(&sb)) {
xfs_error("Invalid superblock");
goto out;
}
-
- xfs_debug("magicnum 0x%lX", be32_to_cpu(sb.sb_magicnum));
+ xfs_debug("sb magic: 0x%lX", be32_to_cpu(sb.sb_magicnum));
info = xfs_new_sb_info(&sb);
if (!info) {
xfs_error("Failed to fill in filesystem-specific info structure");
goto out;
}
-
fs->fs_info = info;
xfs_debug("block_shift %u blocksize 0x%lX (%lu)", info->block_shift,