Move nfs.c:foreach_nfs_shareopt() to libshare.c:foreach_shareopt()
so that it can be (re)used in other parts of libshare.
nfs_is_share_active(sa_share_impl_t impl_share)
{
	char line[512];
	char *tab, *cur;
	FILE *nfs_exportfs_temp_fp;

	if (!nfs_available())
		return (B_FALSE);

	nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");

	if (nfs_exportfs_temp_fp == NULL ||
	    fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) {
		fclose(nfs_exportfs_temp_fp);
		return (B_FALSE);
	}

	while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) {
		/*
		 * exportfs uses separate lines for the share path
		 * and the export options when the share path is longer
		 * than a certain amount of characters; this ignores
		 * the option lines
		 */
		if (line[0] == '\t')
			continue;

		tab = strchr(line, '\t');

		if (tab != NULL) {
			*tab = '\0';
			cur = tab - 1;
		} else {
			/*
			 * there's no tab character, which means the
			 * NFS options are on a separate line; we just
			 * need to remove the new-line character
			 * at the end of the line
			 */
			cur = line + strlen(line) - 1;
		}

		/* remove trailing spaces and new-line characters */
		while (cur >= line && (*cur == ' ' || *cur == '\n'))
			*cur-- = '\0';

		if (strcmp(line, impl_share->sharepath) == 0) {
			fclose(nfs_exportfs_temp_fp);
			return (B_TRUE);
		}
	}

	fclose(nfs_exportfs_temp_fp);

	return (B_FALSE);
}

nfs_is_share_active(sa_share_impl_t impl_share)
{
	char line[512];
	char *tab, *cur;
	FILE *nfs_exportfs_temp_fp;

	if (!nfs_available())
		return (B_FALSE);

	nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");

	if (nfs_exportfs_temp_fp == NULL ||
	    fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) {
		fclose(nfs_exportfs_temp_fp);
		return (B_FALSE);
	}

	while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) {
		/*
		 * exportfs uses separate lines for the share path
		 * and the export options when the share path is longer
		 * than a certain amount of characters; this ignores
		 * the option lines
		 */
		if (line[0] == '\t')
			continue;

		tab = strchr(line, '\t');

		if (tab != NULL) {
			*tab = '\0';
			cur = tab - 1;
		} else {
			/*
			 * there's no tab character, which means the
			 * NFS options are on a separate line; we just
			 * need to remove the new-line character
			 * at the end of the line
			 */
			cur = line + strlen(line) - 1;
		}

		/* remove trailing spaces and new-line characters */
		while (cur >= line && (*cur == ' ' || *cur == '\n'))
			*cur-- = '\0';

		if (strcmp(line, impl_share->sharepath) == 0) {
			fclose(nfs_exportfs_temp_fp);
			return (B_TRUE);
		}
	}

	fclose(nfs_exportfs_temp_fp);

	return (B_FALSE);
}
