mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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:
@@ -148,35 +148,7 @@ nfs_disable_share(sa_share_impl_t impl_share)
|
||||
static boolean_t
|
||||
nfs_is_shared(sa_share_impl_t impl_share)
|
||||
{
|
||||
char *s, last, line[MAXLINESIZE];
|
||||
size_t len;
|
||||
char *mntpoint = impl_share->sa_mountpoint;
|
||||
size_t mntlen = strlen(mntpoint);
|
||||
|
||||
FILE *fp = fopen(ZFS_EXPORTS_FILE, "re");
|
||||
if (fp == NULL)
|
||||
return (B_FALSE);
|
||||
|
||||
for (;;) {
|
||||
s = fgets(line, sizeof (line), fp);
|
||||
if (s == NULL)
|
||||
return (B_FALSE);
|
||||
/* Skip empty lines and comments. */
|
||||
if (line[0] == '\n' || line[0] == '#')
|
||||
continue;
|
||||
len = strlen(line);
|
||||
if (line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
last = line[mntlen];
|
||||
/* Skip the given mountpoint. */
|
||||
if (strncmp(mntpoint, line, mntlen) == 0 &&
|
||||
(last == '\t' || last == ' ' || last == '\0')) {
|
||||
fclose(fp);
|
||||
return (B_TRUE);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return (B_FALSE);
|
||||
return (nfs_is_shared_impl(ZFS_EXPORTS_FILE, impl_share));
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user