patch-2.1.126 linux/fs/ufs/inode.c

Next file: linux/fs/ufs/namei.c
Previous file: linux/fs/ufs/ialloc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.125/linux/fs/ufs/inode.c linux/fs/ufs/inode.c
@@ -53,10 +53,11 @@
 static void ufs_print_inode(struct inode * inode)
 {
 	unsigned swab = inode->i_sb->u.ufs_sb.s_swab;
-	printk("ino %lu  mode 0%6.6o  nlink %d  uid %d  gid %d"
-	       "  size %lu blocks %lu\n",
+	printk("ino %lu  mode 0%6.6o  nlink %d  uid %d  uid32 %u"
+	       "  gid %d  gid32 %u  size %lu blocks %lu\n",
 	       inode->i_ino, inode->i_mode, inode->i_nlink,
-	       inode->i_uid,inode->i_gid, inode->i_size, inode->i_blocks);
+	       inode->i_uid, inode->u.ufs_i.i_uid, inode->i_gid, 
+	       inode->u.ufs_i.i_gid, inode->i_size, inode->i_blocks);
 	printk("  db <%u %u %u %u %u %u %u %u %u %u %u %u>\n",
 		SWAB32(inode->u.ufs_i.i_u1.i_data[0]),
 		SWAB32(inode->u.ufs_i.i_u1.i_data[1]),
@@ -117,7 +118,7 @@
 	 * direct fragment
 	 */
 	if (fragment < UFS_NDIR_FRAGMENT)
-		return ufs_inode_bmap (inode, fragment);
+		return (uspi->s_sbbase + ufs_inode_bmap (inode, fragment));
 
 	/*
 	 * indirect fragment
@@ -128,8 +129,9 @@
 			UFS_IND_FRAGMENT + (fragment >> uspi->s_apbshift));
 		if (!tmp)
 			return 0;
-		return ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize), 
-			fragment & uspi->s_apbmask, uspi, swab);
+		return (uspi->s_sbbase + 
+			ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
+			fragment & uspi->s_apbmask, uspi, swab));
 	}
 
 	/*
@@ -141,12 +143,13 @@
 			UFS_DIND_FRAGMENT + (fragment >> uspi->s_2apbshift));
 		if (!tmp)
 			return 0;
-		tmp = ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize),
+		tmp = ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
 			(fragment >> uspi->s_apbshift) & uspi->s_apbmask, uspi, swab);
 		if (!tmp)
 			return 0;
-		return ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize),
-			fragment & uspi->s_apbmask, uspi, swab);
+		return (uspi->s_sbbase + 
+			ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
+			fragment & uspi->s_apbmask, uspi, swab));
 	}
 
 	/*
@@ -157,16 +160,17 @@
 		UFS_TIND_FRAGMENT + (fragment >> uspi->s_3apbshift));
 	if (!tmp)
 		return 0;
-	tmp = ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize),
+	tmp = ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
 		(fragment >> uspi->s_2apbshift) & uspi->s_apbmask, uspi, swab);
 	if (!tmp)
 		return 0;
-	tmp = ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize),
+	tmp = ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
 		(fragment >> uspi->s_apbshift) & uspi->s_apbmask, uspi, swab);
 	if (!tmp)
 		return 0;
-	return ufs_block_bmap (bread (sb->s_dev, tmp, sb->s_blocksize),
-		fragment & uspi->s_apbmask, uspi, swab);
+	return (uspi->s_sbbase + 
+		ufs_block_bmap (bread (sb->s_dev, uspi->s_sbbase + tmp, sb->s_blocksize),
+		fragment & uspi->s_apbmask, uspi, swab));
 }
 
 static struct buffer_head * ufs_inode_getfrag (struct inode * inode, 
@@ -197,7 +201,7 @@
 	tmp = SWAB32(*p);
 	lastfrag = inode->u.ufs_i.i_lastfrag;
 	if (tmp && fragment < lastfrag) {
-		result = getblk (sb->s_dev, tmp + blockoff, sb->s_blocksize);
+		result = getblk (sb->s_dev, uspi->s_sbbase + tmp + blockoff, sb->s_blocksize);
 		if (tmp == SWAB32(*p)) {
 			UFSD(("EXIT, result %u\n", tmp + blockoff))
 			return result;
@@ -308,7 +312,7 @@
 repeat:
 	tmp = SWAB32(*p);
 	if (tmp) {
-		result = getblk (bh->b_dev, tmp + blockoff, sb->s_blocksize);
+		result = getblk (bh->b_dev, uspi->s_sbbase + tmp + blockoff, sb->s_blocksize);
 		if (tmp == SWAB32(*p)) {
 			brelse (bh);
 			UFSD(("EXIT, result %u\n", tmp + blockoff))
@@ -329,7 +333,6 @@
 	tmp = ufs_new_fragments (inode, p, ufs_blknum(new_fragment), goal, uspi->s_fpb, err);
 	if (!tmp) {
 		if (SWAB32(*p)) {
-			printk("REPEAT\n");
 			goto repeat;
 		}
 		else {
@@ -464,7 +467,7 @@
 		return;
 	}
 	
-	bh = bread (sb->s_dev, ufs_inotofsba(inode->i_ino), sb->s_blocksize);
+	bh = bread (sb->s_dev, uspi->s_sbbase + ufs_inotofsba(inode->i_ino), sb->s_blocksize);
 	if (!bh) {
 		ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
 		return;
@@ -483,11 +486,12 @@
 	 * Linux has only 16-bit uid and gid, so we can't support EFT.
 	 * Files are dynamically chown()ed to root.
 	 */
-	inode->i_uid = ufs_uid(ufs_inode);
-	if (inode->i_uid == UFS_USEEFT) {
+	inode->i_uid = inode->u.ufs_i.i_uid = ufs_get_inode_uid(ufs_inode);
+	inode->i_gid = inode->u.ufs_i.i_gid = ufs_get_inode_gid(ufs_inode);
+	if (inode->u.ufs_i.i_uid >= UFS_USEEFT) {
 		inode->i_uid = 0;
 	}
-	if (inode->i_gid == UFS_USEEFT) {
+	if (inode->u.ufs_i.i_gid >= UFS_USEEFT) {
 		inode->i_gid = 0;
 	}
 	
@@ -510,8 +514,6 @@
 	inode->u.ufs_i.i_flags = SWAB32(ufs_inode->ui_flags);
 	inode->u.ufs_i.i_gen = SWAB32(ufs_inode->ui_gen);
 	inode->u.ufs_i.i_shadow = SWAB32(ufs_inode->ui_u3.ui_sun.ui_shadow);
-	inode->u.ufs_i.i_uid = SWAB32(ufs_inode->ui_u3.ui_sun.ui_uid);
-	inode->u.ufs_i.i_gid = SWAB32(ufs_inode->ui_u3.ui_sun.ui_gid);
 	inode->u.ufs_i.i_oeftflag = SWAB32(ufs_inode->ui_u3.ui_sun.ui_oeftflag);
 	inode->u.ufs_i.i_lastfrag = howmany (inode->i_size, uspi->s_fsize);
 	
@@ -540,8 +542,6 @@
 		inode->i_op = &chrdev_inode_operations;
 	else if (S_ISBLK(inode->i_mode))
 		inode->i_op = &blkdev_inode_operations;
-	else if (S_ISSOCK(inode->i_mode))
-		; /* nothing */
 	else if (S_ISFIFO(inode->i_mode))
 		init_fifo(inode);
 
@@ -558,12 +558,13 @@
 	struct buffer_head * bh;
 	struct ufs_inode * ufs_inode;
 	unsigned i;
-	unsigned swab;
+	unsigned flags, swab;
 
 	UFSD(("ENTER, ino %lu\n", inode->i_ino))
 
 	sb = inode->i_sb;
 	uspi = sb->u.ufs_sb.s_uspi;
+	flags = sb->u.ufs_sb.s_flags;
 	swab = sb->u.ufs_sb.s_swab;
 
 	if (inode->i_ino < UFS_ROOTINO || 
@@ -582,22 +583,15 @@
 	ufs_inode->ui_mode = SWAB16(inode->i_mode);
 	ufs_inode->ui_nlink = SWAB16(inode->i_nlink);
 
-	if (inode->i_uid == 0 && inode->u.ufs_i.i_uid >= UFS_USEEFT) {
-		ufs_inode->ui_u3.ui_sun.ui_uid = SWAB32(inode->u.ufs_i.i_uid);
-		ufs_inode->ui_u1.oldids.ui_suid = (__u16)ufs_inode->ui_u3.ui_sun.ui_uid;
-	}
-	else {
-		ufs_inode->ui_u1.oldids.ui_suid = SWAB16(inode->i_uid);
-		ufs_inode->ui_u3.ui_sun.ui_uid = (__u32) ufs_inode->ui_u1.oldids.ui_suid;
-	}
-	if (inode->i_gid == 0 && inode->u.ufs_i.i_gid >= UFS_USEEFT) {
-		ufs_inode->ui_u3.ui_sun.ui_gid = SWAB32(inode->u.ufs_i.i_gid);
-		ufs_inode->ui_u1.oldids.ui_sgid = (__u16)ufs_inode->ui_u3.ui_sun.ui_gid;
-	}
-	else {
-		ufs_inode->ui_u1.oldids.ui_sgid = SWAB16(inode->i_gid);
-		ufs_inode->ui_u3.ui_sun.ui_gid = (__u32) ufs_inode->ui_u1.oldids.ui_sgid;
-	}
+	if (inode->i_uid == 0 && inode->u.ufs_i.i_uid >= UFS_USEEFT)
+		ufs_set_inode_uid (ufs_inode, inode->u.ufs_i.i_uid);
+	else
+		ufs_set_inode_uid (ufs_inode, inode->i_uid);
+
+	if (inode->i_gid == 0 && inode->u.ufs_i.i_gid >= UFS_USEEFT)
+		ufs_set_inode_gid (ufs_inode, inode->u.ufs_i.i_gid);
+	else
+		ufs_set_inode_gid (ufs_inode, inode->i_gid);
 		
 	ufs_inode->ui_size = SWAB64((u64)inode->i_size);
 	ufs_inode->ui_atime.tv_sec = SWAB32(inode->i_atime);
@@ -607,11 +601,13 @@
 	ufs_inode->ui_mtime.tv_sec = SWAB32(inode->i_mtime);
 	ufs_inode->ui_mtime.tv_usec = SWAB32(0);
 	ufs_inode->ui_blocks = SWAB32(inode->i_blocks);
-
 	ufs_inode->ui_flags = SWAB32(inode->u.ufs_i.i_flags);
 	ufs_inode->ui_gen = SWAB32(inode->u.ufs_i.i_gen);
-	ufs_inode->ui_u3.ui_sun.ui_shadow = SWAB32(inode->u.ufs_i.i_shadow);
-	ufs_inode->ui_u3.ui_sun.ui_oeftflag = SWAB32(inode->u.ufs_i.i_oeftflag);
+
+	if ((flags & UFS_UID_MASK) == UFS_UID_EFT) {
+		ufs_inode->ui_u3.ui_sun.ui_shadow = SWAB32(inode->u.ufs_i.i_shadow);
+		ufs_inode->ui_u3.ui_sun.ui_oeftflag = SWAB32(inode->u.ufs_i.i_oeftflag);
+	}
 
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 		ufs_inode->ui_u2.ui_addr.ui_db[0] = SWAB32(kdev_t_to_nr(inode->i_rdev));

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov