libshare: nfs: share nfs_is_shared()

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
This commit is contained in:
наб
2021-05-17 20:25:29 +02:00
committed by Brian Behlendorf
parent 4e225e7316
commit 605e03e51a
4 changed files with 53 additions and 74 deletions
+1 -25
View File
@@ -467,31 +467,7 @@ nfs_disable_share(sa_share_impl_t impl_share)
static boolean_t
nfs_is_shared(sa_share_impl_t impl_share)
{
size_t buflen = 0;
char *buf = NULL;
FILE *fp = fopen(ZFS_EXPORTS_FILE, "re");
if (fp == NULL) {
return (B_FALSE);
}
while ((getline(&buf, &buflen, fp)) != -1) {
char *space = NULL;
if ((space = strchr(buf, ' ')) != NULL) {
int mountpoint_len = strlen(impl_share->sa_mountpoint);
if (space - buf == mountpoint_len &&
strncmp(impl_share->sa_mountpoint, buf,
mountpoint_len) == 0) {
fclose(fp);
free(buf);
return (B_TRUE);
}
}
}
free(buf);
fclose(fp);
return (B_FALSE);
return (nfs_is_shared_impl(ZFS_EXPORTS_FILE, impl_share));
}
/*