2005-01-06 18:27:30 +00:00
|
|
|
/*-
|
2017-12-02 17:22:55 +00:00
|
|
|
* SPDX-License-Identifier: MIT-CMU
|
|
|
|
*
|
1995-11-05 23:25:12 +00:00
|
|
|
* Copyright (c) 1995 The University of Utah and
|
|
|
|
* the Computer Systems Laboratory at the University of Utah (CSL).
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software is hereby
|
|
|
|
* granted provided that (1) source code retains these copyright, permission,
|
|
|
|
* and disclaimer notices, and (2) redistributions including binaries
|
|
|
|
* reproduce the notices in supporting documentation, and (3) all advertising
|
|
|
|
* materials mentioning features or use of this software display the following
|
|
|
|
* acknowledgement: ``This product includes software developed by the
|
|
|
|
* Computer Systems Laboratory at the University of Utah.''
|
|
|
|
*
|
|
|
|
* THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
|
|
|
|
* IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
|
|
|
|
* ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* CSL requests users of this software to return to csl-dist@cs.utah.edu any
|
|
|
|
* improvements that they make and grant CSL redistribution rights.
|
|
|
|
*
|
|
|
|
* Utah $Hdr$
|
2000-01-01 14:43:20 +00:00
|
|
|
* $FreeBSD$
|
1995-11-05 23:25:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2002-05-16 19:08:03 +00:00
|
|
|
* routines to convert on disk ext2 inodes into inodes and back
|
1995-11-05 23:25:12 +00:00
|
|
|
*/
|
1995-11-09 08:41:25 +00:00
|
|
|
#include <sys/param.h>
|
1995-11-08 04:50:00 +00:00
|
|
|
#include <sys/systm.h>
|
2012-12-20 02:22:36 +00:00
|
|
|
#include <sys/endian.h>
|
1997-12-05 19:55:52 +00:00
|
|
|
#include <sys/lock.h>
|
2019-04-16 11:20:10 +00:00
|
|
|
#include <sys/sdt.h>
|
1995-11-09 08:41:25 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
2013-08-12 21:34:48 +00:00
|
|
|
#include <fs/ext2fs/fs.h>
|
2010-01-14 14:30:54 +00:00
|
|
|
#include <fs/ext2fs/inode.h>
|
|
|
|
#include <fs/ext2fs/ext2fs.h>
|
|
|
|
#include <fs/ext2fs/ext2_dinode.h>
|
2012-12-20 02:22:36 +00:00
|
|
|
#include <fs/ext2fs/ext2_extern.h>
|
1995-11-05 23:25:12 +00:00
|
|
|
|
2019-04-16 11:20:10 +00:00
|
|
|
SDT_PROVIDER_DECLARE(ext2fs);
|
|
|
|
/*
|
|
|
|
* ext2fs trace probe:
|
|
|
|
* arg0: verbosity. Higher numbers give more verbose messages
|
|
|
|
* arg1: Textual message
|
|
|
|
*/
|
|
|
|
SDT_PROBE_DEFINE2(ext2fs, , trace, inode_cnv, "int", "char*");
|
|
|
|
|
|
|
|
#ifdef EXT2FS_PRINT_EXTENTS
|
1995-11-08 04:50:00 +00:00
|
|
|
void
|
2013-02-10 19:49:37 +00:00
|
|
|
ext2_print_inode(struct inode *in)
|
1995-11-05 23:25:12 +00:00
|
|
|
{
|
|
|
|
int i;
|
2013-08-12 21:34:48 +00:00
|
|
|
struct ext4_extent_header *ehp;
|
|
|
|
struct ext4_extent *ep;
|
2002-05-16 19:08:03 +00:00
|
|
|
|
2016-12-28 15:43:17 +00:00
|
|
|
printf("Inode: %5ju", (uintmax_t)in->i_number);
|
|
|
|
printf( /* "Inode: %5d" */
|
2018-05-13 19:19:10 +00:00
|
|
|
" Type: %10s Mode: 0x%o Flags: 0x%x Version: %d acl: 0x%jx\n",
|
2017-05-03 22:35:41 +00:00
|
|
|
"n/a", in->i_mode, in->i_flags, in->i_gen, in->i_facl);
|
2013-08-12 21:34:48 +00:00
|
|
|
printf("User: %5u Group: %5u Size: %ju\n",
|
|
|
|
in->i_uid, in->i_gid, (uintmax_t)in->i_size);
|
|
|
|
printf("Links: %3d Blockcount: %ju\n",
|
|
|
|
in->i_nlink, (uintmax_t)in->i_blocks);
|
2018-05-13 19:19:10 +00:00
|
|
|
printf("ctime: 0x%x ", in->i_ctime);
|
|
|
|
printf("atime: 0x%x ", in->i_atime);
|
|
|
|
printf("mtime: 0x%x ", in->i_mtime);
|
2013-08-12 21:34:48 +00:00
|
|
|
if (E2DI_HAS_XTIME(in))
|
2018-05-13 19:19:10 +00:00
|
|
|
printf("crtime %#x\n", in->i_birthtime);
|
|
|
|
else
|
|
|
|
printf("\n");
|
2017-10-17 20:45:44 +00:00
|
|
|
if (in->i_flag & IN_E4EXTENTS) {
|
|
|
|
printf("Extents:\n");
|
|
|
|
ehp = (struct ext4_extent_header *)in->i_db;
|
|
|
|
printf("Header (magic 0x%x entries %d max %d depth %d gen %d)\n",
|
2020-05-17 14:52:54 +00:00
|
|
|
le16toh(ehp->eh_magic), le16toh(ehp->eh_ecount),
|
|
|
|
le16toh(ehp->eh_max), le16toh(ehp->eh_depth),
|
|
|
|
le32toh(ehp->eh_gen));
|
2017-10-17 20:45:44 +00:00
|
|
|
ep = (struct ext4_extent *)(char *)(ehp + 1);
|
2020-05-17 14:52:54 +00:00
|
|
|
printf("Index (blk %d len %d start_lo %d start_hi %d)\n",
|
|
|
|
le32toh(ep->e_blk),
|
|
|
|
le16toh(ep->e_len), le32toh(ep->e_start_lo),
|
|
|
|
le16toh(ep->e_start_hi));
|
2017-10-17 20:45:44 +00:00
|
|
|
printf("\n");
|
|
|
|
} else {
|
2021-02-18 07:48:10 +00:00
|
|
|
printf("Blocks:");
|
2017-10-17 20:45:44 +00:00
|
|
|
for (i = 0; i < (in->i_blocks <= 24 ? (in->i_blocks + 1) / 2 : 12); i++)
|
|
|
|
printf(" %d", in->i_db[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
1995-11-05 23:25:12 +00:00
|
|
|
}
|
2019-04-16 11:20:10 +00:00
|
|
|
#endif /* EXT2FS_PRINT_EXTENTS */
|
1995-11-05 23:25:12 +00:00
|
|
|
|
2020-05-17 14:52:54 +00:00
|
|
|
#define XTIME_TO_NSEC(x) ((le32toh(x) & EXT3_NSEC_MASK) >> 2)
|
|
|
|
|
2021-02-18 08:26:50 +00:00
|
|
|
static inline bool
|
|
|
|
ext2_old_valid_dev(dev_t dev)
|
|
|
|
{
|
|
|
|
return (major(dev) < 256 && minor(dev) < 256);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint16_t
|
|
|
|
ext2_old_encode_dev(dev_t dev)
|
|
|
|
{
|
|
|
|
return ((major(dev) << 8) | minor(dev));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline dev_t
|
|
|
|
ext2_old_decode_dev(uint16_t val)
|
|
|
|
{
|
|
|
|
return (makedev((val >> 8) & 255, val & 255));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
ext2_new_encode_dev(dev_t dev)
|
|
|
|
{
|
|
|
|
unsigned maj = major(dev);
|
|
|
|
unsigned min = minor(dev);
|
|
|
|
|
|
|
|
return ((min & 0xff) | (maj << 8) | ((min & ~0xff) << 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline dev_t
|
|
|
|
ext2_new_decode_dev(uint32_t dev)
|
|
|
|
{
|
|
|
|
unsigned maj = (dev & 0xfff00) >> 8;
|
|
|
|
unsigned min = (dev & 0xff) | ((dev >> 12) & 0xfff00);
|
|
|
|
|
|
|
|
return (makedev(maj, min));
|
|
|
|
}
|
|
|
|
|
1995-11-05 23:25:12 +00:00
|
|
|
/*
|
2020-05-17 14:52:54 +00:00
|
|
|
* raw ext2 inode LE to host inode conversion
|
1995-11-05 23:25:12 +00:00
|
|
|
*/
|
2018-01-14 20:46:39 +00:00
|
|
|
int
|
2013-02-10 19:49:37 +00:00
|
|
|
ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
|
1995-11-05 23:25:12 +00:00
|
|
|
{
|
2019-03-04 10:55:01 +00:00
|
|
|
struct m_ext2fs *fs = ip->i_e2fs;
|
2020-05-17 14:52:54 +00:00
|
|
|
uint32_t ei_flags_host;
|
|
|
|
uint16_t ei_extra_isize_le;
|
|
|
|
int i;
|
2019-03-04 10:55:01 +00:00
|
|
|
|
|
|
|
if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) ||
|
|
|
|
(ip->i_number < EXT2_ROOTINO) ||
|
2020-05-17 14:52:54 +00:00
|
|
|
(ip->i_number > le32toh(fs->e2fs->e2fs_icount))) {
|
2019-04-16 11:20:10 +00:00
|
|
|
SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "bad inode number");
|
2019-03-04 10:55:01 +00:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
2018-01-14 20:46:39 +00:00
|
|
|
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_nlink = le16toh(ei->e2di_nlink);
|
|
|
|
if (ip->i_number == EXT2_ROOTINO && ip->i_nlink == 0) {
|
2019-04-16 11:20:10 +00:00
|
|
|
SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "root inode unallocated");
|
2019-03-04 10:55:01 +00:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check extra inode size */
|
2020-05-17 14:52:54 +00:00
|
|
|
ei_extra_isize_le = le16toh(ei->e2di_extra_isize);
|
2019-03-04 10:55:01 +00:00
|
|
|
if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) {
|
2020-05-17 14:52:54 +00:00
|
|
|
if (E2FS_REV0_INODE_SIZE + ei_extra_isize_le >
|
|
|
|
EXT2_INODE_SIZE(fs) || (ei_extra_isize_le & 3)) {
|
2019-04-16 11:20:10 +00:00
|
|
|
SDT_PROBE2(ext2fs, , trace, inode_cnv, 1,
|
|
|
|
"bad extra inode size");
|
2019-03-04 10:55:01 +00:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-28 15:43:17 +00:00
|
|
|
/*
|
|
|
|
* Godmar thinks - if the link count is zero, then the inode is
|
|
|
|
* unused - according to ext2 standards. Ufs marks this fact by
|
|
|
|
* setting i_mode to zero - why ? I can see that this might lead to
|
|
|
|
* problems in an undelete.
|
|
|
|
*/
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_mode = ip->i_nlink ? le16toh(ei->e2di_mode) : 0;
|
|
|
|
ip->i_size = le32toh(ei->e2di_size);
|
2004-02-18 14:08:25 +00:00
|
|
|
if (S_ISREG(ip->i_mode))
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_size |= (uint64_t)le32toh(ei->e2di_size_high) << 32;
|
|
|
|
ip->i_atime = le32toh(ei->e2di_atime);
|
|
|
|
ip->i_mtime = le32toh(ei->e2di_mtime);
|
|
|
|
ip->i_ctime = le32toh(ei->e2di_ctime);
|
2012-03-08 21:06:05 +00:00
|
|
|
if (E2DI_HAS_XTIME(ip)) {
|
2020-08-20 05:08:49 +00:00
|
|
|
ip->i_atimensec = XTIME_TO_NSEC(ei->e2di_atime_extra);
|
|
|
|
ip->i_mtimensec = XTIME_TO_NSEC(ei->e2di_mtime_extra);
|
|
|
|
ip->i_ctimensec = XTIME_TO_NSEC(ei->e2di_ctime_extra);
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_birthtime = le32toh(ei->e2di_crtime);
|
2020-08-20 05:08:49 +00:00
|
|
|
ip->i_birthnsec = XTIME_TO_NSEC(ei->e2di_crtime_extra);
|
2012-03-08 21:06:05 +00:00
|
|
|
}
|
2014-01-11 15:19:04 +00:00
|
|
|
ip->i_flags = 0;
|
2020-05-17 14:52:54 +00:00
|
|
|
ei_flags_host = le32toh(ei->e2di_flags);
|
|
|
|
ip->i_flags |= (ei_flags_host & EXT2_APPEND) ? SF_APPEND : 0;
|
|
|
|
ip->i_flags |= (ei_flags_host & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0;
|
|
|
|
ip->i_flags |= (ei_flags_host & EXT2_NODUMP) ? UF_NODUMP : 0;
|
|
|
|
ip->i_flag |= (ei_flags_host & EXT3_INDEX) ? IN_E3INDEX : 0;
|
|
|
|
ip->i_flag |= (ei_flags_host & EXT4_EXTENTS) ? IN_E4EXTENTS : 0;
|
|
|
|
ip->i_blocks = le32toh(ei->e2di_nblock);
|
|
|
|
ip->i_facl = le32toh(ei->e2di_facl);
|
2013-08-12 21:34:48 +00:00
|
|
|
if (E2DI_HAS_HUGE_FILE(ip)) {
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_blocks |= (uint64_t)le16toh(ei->e2di_nblock_high) << 32;
|
|
|
|
ip->i_facl |= (uint64_t)le16toh(ei->e2di_facl_high) << 32;
|
|
|
|
if (ei_flags_host & EXT4_HUGE_FILE)
|
2016-12-28 15:43:17 +00:00
|
|
|
ip->i_blocks = fsbtodb(ip->i_e2fs, ip->i_blocks);
|
2013-08-12 21:34:48 +00:00
|
|
|
}
|
2020-05-17 14:52:54 +00:00
|
|
|
ip->i_gen = le32toh(ei->e2di_gen);
|
|
|
|
ip->i_uid = le16toh(ei->e2di_uid);
|
|
|
|
ip->i_gid = le16toh(ei->e2di_gid);
|
|
|
|
ip->i_uid |= (uint32_t)le16toh(ei->e2di_uid_high) << 16;
|
|
|
|
ip->i_gid |= (uint32_t)le16toh(ei->e2di_gid_high) << 16;
|
2017-07-09 15:19:28 +00:00
|
|
|
|
2021-02-18 08:26:50 +00:00
|
|
|
if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) {
|
|
|
|
if (ei->e2di_blocks[0])
|
|
|
|
ip->i_rdev = ext2_old_decode_dev(le32toh(ei->e2di_blocks[0]));
|
|
|
|
else
|
|
|
|
ip->i_rdev = ext2_new_decode_dev(le32toh(ei->e2di_blocks[1]));
|
|
|
|
} else if ((ip->i_flag & IN_E4EXTENTS)) {
|
2020-05-17 14:52:54 +00:00
|
|
|
memcpy(ip->i_data, ei->e2di_blocks, sizeof(ei->e2di_blocks));
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < EXT2_NDADDR; i++)
|
|
|
|
ip->i_db[i] = le32toh(ei->e2di_blocks[i]);
|
|
|
|
for (i = 0; i < EXT2_NIADDR; i++)
|
|
|
|
ip->i_ib[i] = le32toh(ei->e2di_blocks[EXT2_NDIR_BLOCKS + i]);
|
|
|
|
}
|
2018-01-14 20:46:39 +00:00
|
|
|
|
2018-05-13 19:48:30 +00:00
|
|
|
/* Verify inode csum. */
|
2018-05-13 19:29:35 +00:00
|
|
|
return (ext2_ei_csum_verify(ip, ei));
|
1995-11-05 23:25:12 +00:00
|
|
|
}
|
|
|
|
|
2020-05-17 14:52:54 +00:00
|
|
|
#define NSEC_TO_XTIME(t) (htole32((t << 2) & EXT3_NSEC_MASK))
|
|
|
|
|
1995-11-05 23:25:12 +00:00
|
|
|
/*
|
2020-05-17 14:52:54 +00:00
|
|
|
* inode to raw ext2 LE inode conversion
|
1995-11-05 23:25:12 +00:00
|
|
|
*/
|
2017-09-27 16:12:13 +00:00
|
|
|
int
|
2013-02-10 19:49:37 +00:00
|
|
|
ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei)
|
1995-11-05 23:25:12 +00:00
|
|
|
{
|
2017-09-27 16:12:13 +00:00
|
|
|
struct m_ext2fs *fs;
|
2020-05-17 14:52:54 +00:00
|
|
|
int i;
|
1995-11-05 23:25:12 +00:00
|
|
|
|
2017-09-27 16:12:13 +00:00
|
|
|
fs = ip->i_e2fs;
|
2020-05-17 14:52:54 +00:00
|
|
|
ei->e2di_mode = htole16(ip->i_mode);
|
|
|
|
ei->e2di_nlink = htole16(ip->i_nlink);
|
|
|
|
ei->e2di_size = htole32(ip->i_size);
|
|
|
|
if (S_ISREG(ip->i_mode))
|
|
|
|
ei->e2di_size_high = htole32(ip->i_size >> 32);
|
|
|
|
ei->e2di_atime = htole32(ip->i_atime);
|
|
|
|
ei->e2di_mtime = htole32(ip->i_mtime);
|
|
|
|
ei->e2di_ctime = htole32(ip->i_ctime);
|
2016-12-28 15:43:17 +00:00
|
|
|
/*
|
|
|
|
* Godmar thinks: if dtime is nonzero, ext2 says this inode has been
|
|
|
|
* deleted, this would correspond to a zero link count
|
1995-11-05 23:25:12 +00:00
|
|
|
*/
|
2020-05-17 14:52:54 +00:00
|
|
|
ei->e2di_dtime = htole32(le16toh(ei->e2di_nlink) ? 0 :
|
|
|
|
le32toh(ei->e2di_mtime));
|
2016-02-03 14:31:23 +00:00
|
|
|
if (E2DI_HAS_XTIME(ip)) {
|
2020-08-17 15:05:41 +00:00
|
|
|
ei->e2di_ctime_extra = NSEC_TO_XTIME(ip->i_ctimensec);
|
|
|
|
ei->e2di_mtime_extra = NSEC_TO_XTIME(ip->i_mtimensec);
|
|
|
|
ei->e2di_atime_extra = NSEC_TO_XTIME(ip->i_atimensec);
|
2020-05-17 14:52:54 +00:00
|
|
|
ei->e2di_crtime = htole32(ip->i_birthtime);
|
2020-08-17 15:05:41 +00:00
|
|
|
ei->e2di_crtime_extra = NSEC_TO_XTIME(ip->i_birthnsec);
|
2016-02-03 14:31:23 +00:00
|
|
|
}
|
2020-05-17 14:52:54 +00:00
|
|
|
/* Keep these in host endian for a while since they change a lot */
|
2014-01-11 15:19:04 +00:00
|
|
|
ei->e2di_flags = 0;
|
2020-05-17 14:52:54 +00:00
|
|
|
ei->e2di_flags |= htole32((ip->i_flags & SF_APPEND) ? EXT2_APPEND : 0);
|
|
|
|
ei->e2di_flags |= htole32((ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE : 0);
|
|
|
|
ei->e2di_flags |= htole32((ip->i_flags & UF_NODUMP) ? EXT2_NODUMP : 0);
|
|
|
|
ei->e2di_flags |= htole32((ip->i_flag & IN_E3INDEX) ? EXT3_INDEX : 0);
|
|
|
|
ei->e2di_flags |= htole32((ip->i_flag & IN_E4EXTENTS) ? EXT4_EXTENTS : 0);
|
2017-09-27 16:12:13 +00:00
|
|
|
if (ip->i_blocks > ~0U &&
|
|
|
|
!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) {
|
2019-04-16 11:20:10 +00:00
|
|
|
SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "i_blocks value is out of range");
|
2017-09-27 16:12:13 +00:00
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
if (ip->i_blocks <= 0xffffffffffffULL) {
|
2020-05-17 14:52:54 +00:00
|
|
|
ei->e2di_nblock = htole32(ip->i_blocks & 0xffffffff);
|
|
|
|
ei->e2di_nblock_high = htole16(ip->i_blocks >> 32 & 0xffff);
|
|
|
|
} else {
|
|
|
|
ei->e2di_flags |= htole32(EXT4_HUGE_FILE);
|
|
|
|
ei->e2di_nblock = htole32(dbtofsb(fs, ip->i_blocks));
|
|
|
|
ei->e2di_nblock_high = htole16(dbtofsb(fs, ip->i_blocks) >> 32 & 0xffff);
|
|
|
|
}
|
|
|
|
|
|
|
|
ei->e2di_facl = htole32(ip->i_facl & 0xffffffff);
|
|
|
|
ei->e2di_facl_high = htole16(ip->i_facl >> 32 & 0xffff);
|
|
|
|
ei->e2di_gen = htole32(ip->i_gen);
|
|
|
|
ei->e2di_uid = htole16(ip->i_uid & 0xffff);
|
|
|
|
ei->e2di_uid_high = htole16(ip->i_uid >> 16 & 0xffff);
|
|
|
|
ei->e2di_gid = htole16(ip->i_gid & 0xffff);
|
|
|
|
ei->e2di_gid_high = htole16(ip->i_gid >> 16 & 0xffff);
|
|
|
|
|
2021-02-18 08:26:50 +00:00
|
|
|
if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) {
|
|
|
|
if (ext2_old_valid_dev(ip->i_rdev)) {
|
|
|
|
ei->e2di_blocks[0] = htole32(ext2_old_encode_dev(ip->i_rdev));
|
|
|
|
ei->e2di_blocks[1] = 0;
|
|
|
|
} else {
|
|
|
|
ei->e2di_blocks[0] = 0;
|
|
|
|
ei->e2di_blocks[1] = htole32(ext2_new_encode_dev(ip->i_rdev));
|
|
|
|
ei->e2di_blocks[2] = 0;
|
|
|
|
}
|
|
|
|
} else if ((ip->i_flag & IN_E4EXTENTS)) {
|
2020-05-17 14:52:54 +00:00
|
|
|
memcpy(ei->e2di_blocks, ip->i_data, sizeof(ei->e2di_blocks));
|
2017-09-27 16:12:13 +00:00
|
|
|
} else {
|
2020-05-17 14:52:54 +00:00
|
|
|
for (i = 0; i < EXT2_NDADDR; i++)
|
|
|
|
ei->e2di_blocks[i] = htole32(ip->i_db[i]);
|
|
|
|
for (i = 0; i < EXT2_NIADDR; i++)
|
|
|
|
ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = htole32(ip->i_ib[i]);
|
2017-09-27 16:12:13 +00:00
|
|
|
}
|
|
|
|
|
2018-05-13 19:48:30 +00:00
|
|
|
/* Set inode csum. */
|
2018-01-14 20:46:39 +00:00
|
|
|
ext2_ei_csum_set(ip, ei);
|
|
|
|
|
2017-09-27 16:12:13 +00:00
|
|
|
return (0);
|
1995-11-05 23:25:12 +00:00
|
|
|
}
|