Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363231
b: refs/heads/master
c: d3d1ee3
h: refs/heads/master
i:
  363229: 960276b
  363227: 7f5c107
  363223: 66f2268
  363215: 2040797
  363199: 23963c9
v: v3
  • Loading branch information
Olaf Hering authored and Greg Kroah-Hartman committed Apr 24, 2013
1 parent 3e36b22 commit 818bae2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 038336a5b40ceeea394a6eb3e8c6fc75701eec47
refs/heads/master: d3d1ee3ab28711360937839423158cc185f710f2
39 changes: 21 additions & 18 deletions trunk/tools/hv/hv_vss_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/poll.h>
#include <linux/types.h>
#include <stdio.h>
#include <mntent.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
Expand All @@ -47,11 +48,10 @@ static int vss_operate(int operation)
{
char *fs_op;
char cmd[512];
char buf[512];
FILE *file;
char *p;
char *x;
int error = 0;
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
int error = 0, root_seen = 0;

switch (operation) {
case VSS_OP_FREEZE:
Expand All @@ -64,25 +64,28 @@ static int vss_operate(int operation)
return -1;
}

file = popen("mount | awk '/^\\/dev\\// { print $3}'", "r");
if (file == NULL)
mounts = setmntent("/proc/mounts", "r");
if (mounts == NULL)
return -1;

while ((p = fgets(buf, sizeof(buf), file)) != NULL) {
x = strchr(p, '\n');
*x = '\0';
if (!strncmp(p, "/", sizeof("/")))
while((ent = getmntent(mounts))) {
if (strncmp(ent->mnt_fsname, match, strlen(match)))
continue;

sprintf(cmd, "%s %s %s", "fsfreeze ", fs_op, p);
if (strcmp(ent->mnt_dir, "/") == 0) {
root_seen = 1;
continue;
}
snprintf(cmd, sizeof(cmd), "fsfreeze %s '%s'", fs_op, ent->mnt_dir);
syslog(LOG_INFO, "VSS cmd is %s\n", cmd);
error = system(cmd);
error |= system(cmd);
}
pclose(file);
endmntent(mounts);

sprintf(cmd, "%s %s %s", "fsfreeze ", fs_op, "/");
syslog(LOG_INFO, "VSS cmd is %s\n", cmd);
error = system(cmd);
if (root_seen) {
sprintf(cmd, "fsfreeze %s /", fs_op);
syslog(LOG_INFO, "VSS cmd is %s\n", cmd);
error |= system(cmd);
}

return error;
}
Expand Down

0 comments on commit 818bae2

Please sign in to comment.