public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon
@ 2013-03-26 16:47 Olaf Hering
  2013-03-26 16:47 ` [PATCH 2/2] tools: hv: skip iso9660 mounts " Olaf Hering
  2013-03-26 18:43 ` [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW " KY Srinivasan
  0 siblings, 2 replies; 4+ messages in thread
From: Olaf Hering @ 2013-03-26 16:47 UTC (permalink / raw)
  To: kys, gregkh; +Cc: linux-kernel, Olaf Hering

As suggested by Paolo Bonzini, use ioctl instead of calling fsfreeze.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---

NOT runtime tested!!

 tools/hv/hv_vss_daemon.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index e37d86c..830d606 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -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>
@@ -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>
@@ -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;
@@ -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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tools: hv: skip iso9660 mounts in hv_vss_daemon
  2013-03-26 16:47 [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon Olaf Hering
@ 2013-03-26 16:47 ` Olaf Hering
  2013-03-26 18:44   ` KY Srinivasan
  2013-03-26 18:43 ` [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW " KY Srinivasan
  1 sibling, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2013-03-26 16:47 UTC (permalink / raw)
  To: kys, gregkh; +Cc: linux-kernel, Olaf Hering

freeze does not work for iso9660 filesystems. A ENOSUPP may be catched
in the freeze case, but the subsequent thaw call would fail and leads to
a false error.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 tools/hv/hv_vss_daemon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 830d606..f06cd8c 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -88,6 +88,8 @@ static int vss_operate(int operation)
 	while((ent = getmntent(mounts))) {
 		if (strncmp(ent->mnt_fsname, match, strlen(match)))
 			continue;
+		if (strcmp(ent->mnt_type, "iso9660") == 0)
+			continue;
 		if (strcmp(ent->mnt_dir, "/") == 0) {
 			root_seen = 1;
 			continue;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon
  2013-03-26 16:47 [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon Olaf Hering
  2013-03-26 16:47 ` [PATCH 2/2] tools: hv: skip iso9660 mounts " Olaf Hering
@ 2013-03-26 18:43 ` KY Srinivasan
  1 sibling, 0 replies; 4+ messages in thread
From: KY Srinivasan @ 2013-03-26 18:43 UTC (permalink / raw)
  To: Olaf Hering, gregkh@linuxfoundation.org; +Cc: linux-kernel@vger.kernel.org



> -----Original Message-----
> From: Olaf Hering [mailto:olaf@aepfle.de]
> Sent: Tuesday, March 26, 2013 12:47 PM
> To: KY Srinivasan; gregkh@linuxfoundation.org
> Cc: linux-kernel@vger.kernel.org; Olaf Hering
> Subject: [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon
> 
> As suggested by Paolo Bonzini, use ioctl instead of calling fsfreeze.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>

Thanks Olaf for taking care of this.

Acked by: K. Y. Srinivasan <kys@microsoft.com>

> ---
> 
> NOT runtime tested!!
> 
>  tools/hv/hv_vss_daemon.c | 31 ++++++++++++++++++++++---------
>  1 file changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
> index e37d86c..830d606 100644
> --- a/tools/hv/hv_vss_daemon.c
> +++ b/tools/hv/hv_vss_daemon.c
> @@ -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>
> @@ -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>
> @@ -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;
> @@ -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;
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH 2/2] tools: hv: skip iso9660 mounts in hv_vss_daemon
  2013-03-26 16:47 ` [PATCH 2/2] tools: hv: skip iso9660 mounts " Olaf Hering
@ 2013-03-26 18:44   ` KY Srinivasan
  0 siblings, 0 replies; 4+ messages in thread
From: KY Srinivasan @ 2013-03-26 18:44 UTC (permalink / raw)
  To: Olaf Hering, gregkh@linuxfoundation.org; +Cc: linux-kernel@vger.kernel.org



> -----Original Message-----
> From: Olaf Hering [mailto:olaf@aepfle.de]
> Sent: Tuesday, March 26, 2013 12:47 PM
> To: KY Srinivasan; gregkh@linuxfoundation.org
> Cc: linux-kernel@vger.kernel.org; Olaf Hering
> Subject: [PATCH 2/2] tools: hv: skip iso9660 mounts in hv_vss_daemon
> 
> freeze does not work for iso9660 filesystems. A ENOSUPP may be catched
> in the freeze case, but the subsequent thaw call would fail and leads to
> a false error.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>

Olaf, thanks for fixing this.

Acked by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  tools/hv/hv_vss_daemon.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
> index 830d606..f06cd8c 100644
> --- a/tools/hv/hv_vss_daemon.c
> +++ b/tools/hv/hv_vss_daemon.c
> @@ -88,6 +88,8 @@ static int vss_operate(int operation)
>  	while((ent = getmntent(mounts))) {
>  		if (strncmp(ent->mnt_fsname, match, strlen(match)))
>  			continue;
> +		if (strcmp(ent->mnt_type, "iso9660") == 0)
> +			continue;
>  		if (strcmp(ent->mnt_dir, "/") == 0) {
>  			root_seen = 1;
>  			continue;
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-26 18:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 16:47 [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon Olaf Hering
2013-03-26 16:47 ` [PATCH 2/2] tools: hv: skip iso9660 mounts " Olaf Hering
2013-03-26 18:44   ` KY Srinivasan
2013-03-26 18:43 ` [PATCH 1/2] tools: hv: use FIFREEZE/FITHAW " KY Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox