Subject: Re: error in sup 1997/06/11
To: Erik E. Fair <fair@clock.org>
From: Rick Byers <rickb@iaw.on.ca>
List: current-users
Date: 06/11/1997 17:56:16
Yep, that is due to the new ext2fs support.  Manuel should have fstat
fixed soon.  However, in the mean time, here is a little patch I made.  It
appears to work, but I won't promise anything (I don't really know what
I'm doing <grin>).  This not only fixes the ffs support in fstat, but adds
ext2fs support as well.  I've also attached a patch to fix pstat to
compile, although I didn't try to actually add support for ext2fs (not
sure if it's necesary)

Hope this helps,
	Rick

Index: fstat.c
===================================================================
RCS file: /usr/cvsroot/netbsd/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** fstat.c	1997/05/26 23:45:12	1.1.1.1
--- fstat.c	1997/06/09 20:58:37	1.2
***************
*** 144,150 ****
  
  kvm_t *kd;
  
! int ufs_filestat(), nfs_filestat();
  void dofiles(), getinetproto(), socktrans();
  void usage(), vtrans();
  
--- 144,150 ----
  
  kvm_t *kd;
  
! int ufs_filestat(), nfs_filestat(), ext2_filestat();
  void dofiles(), getinetproto(), socktrans();
  void usage(), vtrans();
  
***************
*** 407,412 ****
--- 407,416 ----
  			if (!nfs_filestat(&vn, &fst))
  				badtype = "error";
  			break;
+ 		case VT_EXT2FS:
+ 			if (!ext2_filestat(&vn, &fst))
+ 				badtype = "error";
+ 			break;
  		default: {
  			static char unknown[10];
  			(void)snprintf(badtype = unknown, sizeof unknown,
***************
*** 484,492 ****
  	}
  	fsp->fsid = inode.i_dev & 0xffff;
  	fsp->fileid = (long)inode.i_number;
! 	fsp->mode = (mode_t)inode.i_mode;
! 	fsp->size = (u_long)inode.i_size;
! 	fsp->rdev = inode.i_rdev;
  
  	return 1;
  }
--- 488,518 ----
  	}
  	fsp->fsid = inode.i_dev & 0xffff;
  	fsp->fileid = (long)inode.i_number;
! 	fsp->mode = (mode_t)inode.i_ffs_mode;
! 	fsp->size = (u_long)inode.i_ffs_size;
! 	fsp->rdev = inode.i_ffs_rdev;
! 
! 	return 1;
! }
! 
! 
! int
! ext2_filestat(vp, fsp)
! 	struct vnode *vp;
! 	struct filestat *fsp;
! {
! 	struct inode inode;
! 
! 	if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) {
! 		dprintf(stderr, "can't read inode at %x for pid %d\n",
! 			VTOI(vp), Pid);
! 		return 0;
! 	}
! 	fsp->fsid = inode.i_dev & 0xffff;
! 	fsp->fileid = (long)inode.i_number;
! 	fsp->mode = (mode_t)inode.i_e2fs_mode;
! 	fsp->size = (u_long)inode.i_e2fs_size;
! 	fsp->rdev = inode.i_din.e2fs_din.e2di_rdev;
  
  	return 1;
  }

Index: pstat.c
===================================================================
RCS file: /usr/cvsroot/netbsd/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -c -r1.1.1.2 -r1.2
*** pstat.c	1997/06/08 22:19:38	1.1.1.2
--- pstat.c	1997/06/10 01:54:49	1.2
***************
*** 404,418 ****
  	*flags = '\0';
  
  	(void)printf(" %6d %5s", ip->i_number, flagbuf);
! 	type = ip->i_mode & S_IFMT;
! 	if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode))
! 		if (usenumflag || ((name = devname(ip->i_rdev, type)) == NULL))
  			(void)printf("   %2d,%-2d", 
! 			    major(ip->i_rdev), minor(ip->i_rdev));
  		else
  			(void)printf(" %7s", name);
  	else
! 		(void)printf(" %7qd", ip->i_size);
  	return (0);
  }
  
--- 404,418 ----
  	*flags = '\0';
  
  	(void)printf(" %6d %5s", ip->i_number, flagbuf);
! 	type = ip->i_ffs_mode & S_IFMT;
! 	if (S_ISCHR(ip->i_ffs_mode) || S_ISBLK(ip->i_ffs_mode))
! 		if (usenumflag || ((name = devname(ip->i_ffs_rdev, type)) == NULL))
  			(void)printf("   %2d,%-2d", 
! 			    major(ip->i_ffs_rdev), minor(ip->i_ffs_rdev));
  		else
  			(void)printf(" %7s", name);
  	else
! 		(void)printf(" %7qd", ip->i_ffs_size);
  	return (0);
  }
  

On Wed, 11 Jun 1997, Erik E. Fair wrote:

> ===> usr.bin/fstat
> cc -O  -Werror  -c fstat.c
> fstat.c: In function `ufs_filestat':
> fstat.c:487: structure has no member named `i_mode'
> fstat.c:488: structure has no member named `i_size'
> fstat.c:489: structure has no member named `i_rdev'
> *** Error code 1
> 
> Stop.
> 
> 

=========================================================================
Rick Byers                                      Internet Access Worldwide
rickb@iaw.on.ca                                System Admin, Tech Support
Welland, Ontario, Canada                                    (905)714-1400
http://www.iaw.on.ca/rickb/                         http://www.iaw.on.ca/