Skip to content

Commit

Permalink
hv: hypervvssd: call endmntent before call setmntent again
Browse files Browse the repository at this point in the history
If freeze fails, vss_operate will re-enter itself to thaw. But it forgets
to call endmntent() before it recalls setmntent() again.

Signed-off-by: Vaughan Cao <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Vaughan Cao authored and gregkh committed Mar 25, 2015
1 parent f2eddbc commit 4ce50e9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/hv/hv_vss_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static int vss_operate(int operation)
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
char errdir[1024] = {0};
unsigned int cmd;
int error = 0, root_seen = 0, save_errno = 0;

Expand Down Expand Up @@ -115,6 +116,8 @@ static int vss_operate(int operation)
goto err;
}

endmntent(mounts);

if (root_seen) {
error |= vss_do_freeze("/", cmd);
if (error && operation == VSS_OP_FREEZE)
Expand All @@ -124,16 +127,19 @@ static int vss_operate(int operation)
goto out;
err:
save_errno = errno;
if (ent) {
strncpy(errdir, ent->mnt_dir, sizeof(errdir)-1);
endmntent(mounts);
}
vss_operate(VSS_OP_THAW);
/* Call syslog after we thaw all filesystems */
if (ent)
syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
ent->mnt_dir, save_errno, strerror(save_errno));
errdir, save_errno, strerror(save_errno));
else
syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno,
strerror(save_errno));
out:
endmntent(mounts);
return error;
}

Expand Down

0 comments on commit 4ce50e9

Please sign in to comment.