aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ufs/inode.c')
-rw-r--r--fs/ufs/inode.c111
1 files changed, 80 insertions, 31 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 4295ca91cf85..dd52eecdcb0f 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -616,8 +616,8 @@ static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
616 inode->i_atime.tv_nsec = 0; 616 inode->i_atime.tv_nsec = 0;
617 inode->i_ctime.tv_nsec = 0; 617 inode->i_ctime.tv_nsec = 0;
618 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); 618 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
619 inode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen);
619 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); 620 ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
620 ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen);
621 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 621 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
622 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 622 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
623 623
@@ -661,8 +661,8 @@ static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
661 inode->i_atime.tv_nsec = 0; 661 inode->i_atime.tv_nsec = 0;
662 inode->i_ctime.tv_nsec = 0; 662 inode->i_ctime.tv_nsec = 0;
663 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); 663 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
664 inode->i_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen);
664 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags); 665 ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags);
665 ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen);
666 /* 666 /*
667 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); 667 ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
668 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); 668 ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
@@ -731,34 +731,11 @@ bad_inode:
731 make_bad_inode(inode); 731 make_bad_inode(inode);
732} 732}
733 733
734static int ufs_update_inode(struct inode * inode, int do_sync) 734static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
735{ 735{
736 struct ufs_inode_info *ufsi = UFS_I(inode); 736 struct super_block *sb = inode->i_sb;
737 struct super_block * sb; 737 struct ufs_inode_info *ufsi = UFS_I(inode);
738 struct ufs_sb_private_info * uspi; 738 unsigned i;
739 struct buffer_head * bh;
740 struct ufs_inode * ufs_inode;
741 unsigned i;
742 unsigned flags;
743
744 UFSD("ENTER, ino %lu\n", inode->i_ino);
745
746 sb = inode->i_sb;
747 uspi = UFS_SB(sb)->s_uspi;
748 flags = UFS_SB(sb)->s_flags;
749
750 if (inode->i_ino < UFS_ROOTINO ||
751 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
752 ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino);
753 return -1;
754 }
755
756 bh = sb_bread(sb, ufs_inotofsba(inode->i_ino));
757 if (!bh) {
758 ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
759 return -1;
760 }
761 ufs_inode = (struct ufs_inode *) (bh->b_data + ufs_inotofsbo(inode->i_ino) * sizeof(struct ufs_inode));
762 739
763 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); 740 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
764 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); 741 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
@@ -775,9 +752,9 @@ static int ufs_update_inode(struct inode * inode, int do_sync)
775 ufs_inode->ui_mtime.tv_usec = 0; 752 ufs_inode->ui_mtime.tv_usec = 0;
776 ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks); 753 ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks);
777 ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags); 754 ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags);
778 ufs_inode->ui_gen = cpu_to_fs32(sb, ufsi->i_gen); 755 ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation);
779 756
780 if ((flags & UFS_UID_MASK) == UFS_UID_EFT) { 757 if ((UFS_SB(sb)->s_flags & UFS_UID_MASK) == UFS_UID_EFT) {
781 ufs_inode->ui_u3.ui_sun.ui_shadow = cpu_to_fs32(sb, ufsi->i_shadow); 758 ufs_inode->ui_u3.ui_sun.ui_shadow = cpu_to_fs32(sb, ufsi->i_shadow);
782 ufs_inode->ui_u3.ui_sun.ui_oeftflag = cpu_to_fs32(sb, ufsi->i_oeftflag); 759 ufs_inode->ui_u3.ui_sun.ui_oeftflag = cpu_to_fs32(sb, ufsi->i_oeftflag);
783 } 760 }
@@ -796,6 +773,78 @@ static int ufs_update_inode(struct inode * inode, int do_sync)
796 773
797 if (!inode->i_nlink) 774 if (!inode->i_nlink)
798 memset (ufs_inode, 0, sizeof(struct ufs_inode)); 775 memset (ufs_inode, 0, sizeof(struct ufs_inode));
776}
777
778static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
779{
780 struct super_block *sb = inode->i_sb;
781 struct ufs_inode_info *ufsi = UFS_I(inode);
782 unsigned i;
783
784 UFSD("ENTER\n");
785 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
786 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
787
788 ufs_inode->ui_uid = cpu_to_fs32(sb, inode->i_uid);
789 ufs_inode->ui_gid = cpu_to_fs32(sb, inode->i_gid);
790
791 ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
792 ufs_inode->ui_atime.tv_sec = cpu_to_fs32(sb, inode->i_atime.tv_sec);
793 ufs_inode->ui_atime.tv_usec = 0;
794 ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb, inode->i_ctime.tv_sec);
795 ufs_inode->ui_ctime.tv_usec = 0;
796 ufs_inode->ui_mtime.tv_sec = cpu_to_fs32(sb, inode->i_mtime.tv_sec);
797 ufs_inode->ui_mtime.tv_usec = 0;
798
799 ufs_inode->ui_blocks = cpu_to_fs64(sb, inode->i_blocks);
800 ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags);
801 ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation);
802
803 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
804 /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */
805 ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0];
806 } else if (inode->i_blocks) {
807 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
808 ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.u2_i_data[i];
809 } else {
810 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
811 ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i];
812 }
813
814 if (!inode->i_nlink)
815 memset (ufs_inode, 0, sizeof(struct ufs2_inode));
816 UFSD("EXIT\n");
817}
818
819static int ufs_update_inode(struct inode * inode, int do_sync)
820{
821 struct super_block *sb = inode->i_sb;
822 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
823 struct buffer_head * bh;
824
825 UFSD("ENTER, ino %lu\n", inode->i_ino);
826
827 if (inode->i_ino < UFS_ROOTINO ||
828 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
829 ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino);
830 return -1;
831 }
832
833 bh = sb_bread(sb, ufs_inotofsba(inode->i_ino));
834 if (!bh) {
835 ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
836 return -1;
837 }
838 if (uspi->fs_magic == UFS2_MAGIC) {
839 struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
840
841 ufs2_update_inode(inode,
842 ufs2_inode + ufs_inotofsbo(inode->i_ino));
843 } else {
844 struct ufs_inode *ufs_inode = (struct ufs_inode *) bh->b_data;
845
846 ufs1_update_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
847 }
799 848
800 mark_buffer_dirty(bh); 849 mark_buffer_dirty(bh);
801 if (do_sync) 850 if (do_sync)