Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363232
b: refs/heads/master
c: 7b413b6
h: refs/heads/master
v: v3
  • Loading branch information
Olaf Hering authored and Greg Kroah-Hartman committed Apr 24, 2013
1 parent 818bae2 commit e3fb174
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 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: d3d1ee3ab28711360937839423158cc185f710f2
refs/heads/master: 7b413b65531422cc3d12a8acf53a43bc0d3c9f7b
31 changes: 22 additions & 9 deletions trunk/tools/hv/hv_vss_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <mntent.h>
#include <stdlib.h>
Expand All @@ -30,6 +32,7 @@
#include <ctype.h>
#include <errno.h>
#include <arpa/inet.h>
#include <linux/fs.h>
#include <linux/connector.h>
#include <linux/hyperv.h>
#include <linux/netlink.h>
Expand All @@ -44,21 +47,35 @@ static struct sockaddr_nl addr;
#endif


static int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op)
{
int ret, fd = open(dir, O_RDONLY);

if (fd < 0)
return 1;
ret = ioctl(fd, cmd, 0);
syslog(LOG_INFO, "VSS: %s of %s: %s\n", fs_op, dir, strerror(errno));
close(fd);
return !!ret;
}

static int vss_operate(int operation)
{
char *fs_op;
char cmd[512];
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
unsigned int cmd;
int error = 0, root_seen = 0;

switch (operation) {
case VSS_OP_FREEZE:
fs_op = "-f ";
cmd = FIFREEZE;
fs_op = "freeze";
break;
case VSS_OP_THAW:
fs_op = "-u ";
cmd = FITHAW;
fs_op = "thaw";
break;
default:
return -1;
Expand All @@ -75,16 +92,12 @@ static int vss_operate(int operation)
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 |= vss_do_freeze(ent->mnt_dir, cmd, fs_op);
}
endmntent(mounts);

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

return error;
Expand Down

0 comments on commit e3fb174

Please sign in to comment.