ufs2: Fix inode retrieval
The code multiplied fragno by MINBSIZE instead on fragment size. Moreover IsDirectory and IsSymlink were called before inode was read. Change-Id: I9e62007c900fb4376812f8ebef508a3f8a8f619b Reviewed-on: https://review.haiku-os.org/c/haiku/+/6848 Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
21425cfca0
commit
454dc0e951
@ -26,23 +26,25 @@ Inode::Inode(Volume* volume, ino_t id)
|
||||
{
|
||||
rw_lock_init(&fLock, "ufs2 inode");
|
||||
|
||||
fInitStatus = B_OK;//UpdateNodeFromDisk();
|
||||
int fd = fVolume->Device();
|
||||
ufs2_super_block* superblock = (ufs2_super_block* )&fVolume->SuperBlock();
|
||||
int64_t fs_block = ino_to_fsba(superblock, id);
|
||||
int64_t offset_in_block = ino_to_fsbo(superblock, id);
|
||||
int64_t offset = fs_block * superblock->fs_fsize + offset_in_block * sizeof(fNode);
|
||||
|
||||
if (read_pos(fd, offset, (void*)&fNode, sizeof(fNode)) != sizeof(fNode)) {
|
||||
ERROR("Inode::Inode(): IO Error\n");
|
||||
fInitStatus = B_IO_ERROR;
|
||||
return;
|
||||
}
|
||||
fInitStatus = B_OK;
|
||||
|
||||
if (fInitStatus == B_OK) {
|
||||
if (!IsDirectory() && !IsSymLink()) {
|
||||
fCache = file_cache_create(fVolume->ID(), ID(), Size());
|
||||
fMap = file_map_create(fVolume->ID(), ID(), Size());
|
||||
}
|
||||
}
|
||||
int fd = fVolume->Device();
|
||||
ufs2_super_block* superblock = (ufs2_super_block* )&fVolume->SuperBlock();
|
||||
int64_t fs_block = ino_to_fsba(superblock, id);
|
||||
int64_t offset_in_block = ino_to_fsbo(superblock, id);
|
||||
int64_t offset = fs_block * MINBSIZE + offset_in_block * sizeof(fNode);
|
||||
|
||||
if (read_pos(fd, offset, (void*)&fNode, sizeof(fNode)) != sizeof(fNode))
|
||||
ERROR("Inode::Inode(): IO Error\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,17 +72,6 @@ typedef uint64_t ufs2_daddr_t;
|
||||
* to determine block availability, aligned fragments are examined.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MINBSIZE is the smallest allowable block size.
|
||||
* In order to insure that it is possible to create files of size
|
||||
* 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
|
||||
* MINBSIZE must be big enough to hold a cylinder group block,
|
||||
* thus changes to (struct cg) must keep its size within MINBSIZE.
|
||||
* Note that super blocks are always of size SBLOCKSIZE,
|
||||
* and that both SBLOCKSIZE and MAXBSIZE must be >= MINBSIZE.
|
||||
*/
|
||||
#define MINBSIZE 4096
|
||||
|
||||
/*
|
||||
* The path name on which the filesystem is mounted is maintained
|
||||
* in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
|
||||
|
Loading…
x
Reference in New Issue
Block a user