Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/ext2fs/ext2_inode_cnv.c
Show All 28 Lines | |||||
*/ | */ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/endian.h> | #include <sys/endian.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <fs/ext2fs/ext2fs.h> | |||||
#include <fs/ext2fs/fs.h> | #include <fs/ext2fs/fs.h> | ||||
#include <fs/ext2fs/inode.h> | #include <fs/ext2fs/inode.h> | ||||
#include <fs/ext2fs/ext2fs.h> | #include <fs/ext2fs/ext2fs.h> | ||||
#include <fs/ext2fs/ext2_dinode.h> | #include <fs/ext2fs/ext2_dinode.h> | ||||
#include <fs/ext2fs/ext2_extern.h> | #include <fs/ext2fs/ext2_extern.h> | ||||
#define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2) | #define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2) | ||||
#define NSEC_TO_XTIME(t) (le32toh(t << 2) & EXT3_NSEC_MASK) | #define NSEC_TO_XTIME(t) (le32toh(t << 2) & EXT3_NSEC_MASK) | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#endif /* EXT2FS_DEBUG */ | #endif /* EXT2FS_DEBUG */ | ||||
/* | /* | ||||
* raw ext2 inode to inode | * raw ext2 inode to inode | ||||
*/ | */ | ||||
int | int | ||||
ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) | ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) | ||||
{ | { | ||||
struct m_ext2fs *fs = ip->i_e2fs; | |||||
if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) || | |||||
(ip->i_number < EXT2_ROOTINO) || | |||||
(ip->i_number > fs->e2fs->e2fs_icount)) { | |||||
printf("ext2fs: bad inode number %ju\n", ip->i_number); | |||||
return (EINVAL); | |||||
} | |||||
if (ip->i_number == EXT2_ROOTINO && ei->e2di_nlink == 0) { | |||||
printf("ext2fs: root inode unallocated\n"); | |||||
return (EINVAL); | |||||
} | |||||
ip->i_nlink = ei->e2di_nlink; | ip->i_nlink = ei->e2di_nlink; | ||||
/* Check extra inode size */ | |||||
if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) { | |||||
if (E2FS_REV0_INODE_SIZE + ei->e2di_extra_isize > | |||||
EXT2_INODE_SIZE(fs) || (ei->e2di_extra_isize & 3)) { | |||||
printf("ext2fs: bad extra inode size %u, inode size=%u\n", | |||||
ei->e2di_extra_isize, EXT2_INODE_SIZE(fs)); | |||||
return (EINVAL); | |||||
} | |||||
} | |||||
/* | /* | ||||
* Godmar thinks - if the link count is zero, then the inode is | * Godmar thinks - if the link count is zero, then the inode is | ||||
* unused - according to ext2 standards. Ufs marks this fact by | * unused - according to ext2 standards. Ufs marks this fact by | ||||
* setting i_mode to zero - why ? I can see that this might lead to | * setting i_mode to zero - why ? I can see that this might lead to | ||||
* problems in an undelete. | * problems in an undelete. | ||||
*/ | */ | ||||
ip->i_mode = ei->e2di_nlink ? ei->e2di_mode : 0; | ip->i_mode = ei->e2di_nlink ? ei->e2di_mode : 0; | ||||
ip->i_size = ei->e2di_size; | ip->i_size = ei->e2di_size; | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |