/* Check mode */
if (mode != F_REG && mode != F_DIR && mode != F_BDEV && mode != F_CDEV) {
printf("Inode %d with mode 0%o is not of correct type. Zap? ",
- n, ino.i_mode);
+ n, swizzle16(ino.i_mode));
if (yes()) {
ino.i_mode = 0;
ino.i_nlink = 0;
}
}
if (ino.i_addr[b] != 0)
- bitmap[ino.i_addr[b]] = 1;
+ bitmap[swizzle16(ino.i_addr[b])] = 1;
}
/* Check the double indirect blocks */
}
}
if (buf[b] != 0)
- bitmap[buf[b]] = 1;
+ bitmap[swizzle16(buf[b])] = 1;
}
}
/* Check the rest */
for (n = ROOTINODE; n < 8 * (swizzle16(superblock.s_isize) - 2); ++n) {
iread(n, &ino);
- mode = swizzle16(ino.i_mode & F_MASK);
+ mode = swizzle16(ino.i_mode) & F_MASK;
if (mode != F_REG && mode != F_DIR)
continue;
strcpy(ename, name);
strcat(ename, dentry.d_name);
strcat(ename, "/");
- ckdir(dentry.d_ino, inum, ename);
+ ckdir(swizzle16(dentry.d_ino), inum, ename);
}
}
--depth;
ino.i_nlink = 0;
ino.i_mode = 0;
iwrite(n, &ino);
- ++superblock.s_tinode;
+ superblock.s_tinode =
+ swizzle16(swizzle16(superblock.s_tinode) + 1);
dwrite((blkno_t) 1, (char *) &superblock);
}
} else {
#if 0
printf("Inode %d has become detached. Link count is %d. Fix? ",
- n, ino.i_nlink);
+ n, swizzle16(ino.i_nlink));
if (yes()) {
ino.i_nlink = 1;
iwrite(n, &ino);
ifnot (filesys->s_nfree) {
buf = (blkno_t *) daread(newno);
- filesys->s_nfree = swizzle16(buf[0]);
+ filesys->s_nfree = buf[0];
for (j = 0; j < 50; j++) {
- filesys->s_free[j] = swizzle16(buf[j + 1]);
+ filesys->s_free[j] = buf[j + 1];
}
}
inoptr i_open();
for (j = 0; j < NDEVS; ++j)
- if (fs_tab[j].s_mounted == SMOUNTED
+ if (swizzle16(fs_tab[j].s_mounted) == SMOUNTED
&& fs_tab[j].s_mntpt == ino) {
i_deref(ino);
return (i_open(j, ROOTINODE));
}
}
- if (ino < ROOTINODE || ino >= (fs_tab[dev].s_isize - 2) * 8) {
+ if (ino < ROOTINODE || ino >= (swizzle16(fs_tab[dev].s_isize) - 2) * 8) {
printf("i_open: bad inode number\n");
return (NULLINODE);
}
now = time(NULL);
if (flag & A_TIME)
- ino->c_node.i_atime = now;
+ ino->c_node.i_atime = swizzle32(now);
if (flag & M_TIME)
- ino->c_node.i_mtime = now;
+ ino->c_node.i_mtime = swizzle32(now);
if (flag & C_TIME)
- ino->c_node.i_ctime = now;
+ ino->c_node.i_ctime = swizzle32(now);
}