FreeBSD/sbin/growfs/growfs.c
/*
 * Return mountpoint on which the device is currently mounted.
 */
Return mountpoint on which the device is currently mounted.
Return mountpoint on which the device is currently mounted .
static const struct statfs *
dev_to_statfs(const char *dev)
{
	struct stat devstat, mntdevstat;
	struct statfs *mntbuf, *statfsp;
	char device[MAXPATHLEN];
	char *mntdevname;
	int i, mntsize;
	if (stat(dev, &devstat) != 0)
		return (NULL);
	if (!S_ISCHR(devstat.st_mode) && !S_ISBLK(devstat.st_mode))
		return (NULL);
	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
	for (i = 0; i < mntsize; i++) {
		statfsp = &mntbuf[i];
		mntdevname = statfsp->f_mntfromname;
		if (*mntdevname != '/') {
			strcpy(device, _PATH_DEV);
			strcat(device, mntdevname);
			mntdevname = device;
		}
		if (stat(mntdevname, &mntdevstat) == 0 &&
		    mntdevstat.st_rdev == devstat.st_rdev)
			return (statfsp);
	}
	return (NULL);
}
static const struct statfs * dev_to_statfs ( const char * dev ) { struct stat devstat , mntdevstat ; struct statfs * mntbuf , * statfsp ; char device [ MAXPATHLEN ] ; char * mntdevname ; int i , mntsize ; if ( stat ( dev , & devstat ) != 0 ) return ( NULL ) ; if ( ! S_ISCHR ( devstat . st_mode ) && ! S_ISBLK ( devstat . st_mode ) ) return ( NULL ) ; mntsize = getmntinfo ( & mntbuf , MNT_NOWAIT ) ; for ( i = 0 ; i < mntsize ; i ++ ) { statfsp = & mntbuf [ i ] ; mntdevname = statfsp -> f_mntfromname ; if ( * mntdevname != ' ' ) { strcpy ( device , _PATH_DEV ) ; strcat ( device , mntdevname ) ; mntdevname = device ; } if ( stat ( mntdevname , & mntdevstat ) == 0 && mntdevstat . st_rdev == devstat . st_rdev ) return ( statfsp ) ; } return ( NULL ) ; }
Return mountpoint on which the device is currently mounted.
Return mountpoint on which the device is currently mounted .
/*
	 * First check the mounted filesystems.
	 */