[Ocfs2-tools-devel] [RESEND][PATCH] Improvement to tunefs.ocfs2 online resize to handle symbolic link

Jiaju Zhang jjzhang.linux at gmail.com
Tue Mar 23 21:49:14 PDT 2010


On Tue, Mar 23, 2010 at 06:45:01PM +0800, Wengang Wang wrote:
> Hi Jiaju,
> 
> > 
> > Oh yes, thanks a lot for the modification;-)
> > New patch attached as below.
> > 
> > Thanks,
> > Jiaju
> > ---
> >  ocfs2_controld/mount.c |   15 ++++++++++++++-
> >  1 files changed, 14 insertions(+), 1 deletions(-)
> > 
> > diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
> > index 36459d1..b46a04b 100644
> > --- a/ocfs2_controld/mount.c
> > +++ b/ocfs2_controld/mount.c
> > @@ -260,11 +260,24 @@ static void add_service(struct mountgroup *mg, const char *device,
> >  			   const char *service, int ci, int fd)
> >  {
> >  	struct service *ms;
> > +	struct stat st1, st2;
> >  
> >  	log_debug("Adding service %s to device %s uuid %s",
> >  		  service, device, mg->mg_uuid);
> >  
> > -	if (strcmp(mg->mg_device, device)) {
> > +	if (stat(mg->mg_device, &st1)) {
> > +		fill_error(mg, errno, "Failed to stat device \"%s\": %s",
> > +			   mg->mg_device, strerror(errno));
> > +		return;
> > +	}
> > +
> > +	if (stat(device, &st2)) {
> > +		fill_error(mg, errno, "Failed to stat device \"%s\": %s",
> > +			   device, strerror(errno));
> > +		return;
> > +	}
> > +
> > +	if (st1.st_rdev != st2.st_rdev) {
> >  		fill_error(mg, EINVAL,
> >  			   "Trying to mount fs %s on device %s, but it is already mounted from device %s",
> >  			   mg->mg_uuid, device, mg->mg_device);
> 
> I guess Joel meant also the device string here, \"%s\".

Thanks to Wengang's kindly reminder, I added the double quotation
marks for the "uuid", "service" and "device" string in this patch.
Also, I found some other places may need to add the double quotation
marks too. Since they are not related to this fix, I'll send another
patch to do the code cleanup job.

Thanks a lot for your review;-)
Jiaju

Signed-off-by: Jiaju Zhang <jjzhang at suse.de>
---
 ocfs2_controld/mount.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
index 36459d1..797b66f 100644
--- a/ocfs2_controld/mount.c
+++ b/ocfs2_controld/mount.c
@@ -260,13 +260,27 @@ static void add_service(struct mountgroup *mg, const char *device,
 			   const char *service, int ci, int fd)
 {
 	struct service *ms;
+	struct stat st1, st2;
 
-	log_debug("Adding service %s to device %s uuid %s",
+	log_debug("Adding service \"%s\" to device \"%s\" uuid \"%s\"",
 		  service, device, mg->mg_uuid);
 
-	if (strcmp(mg->mg_device, device)) {
+	if (stat(mg->mg_device, &st1)) {
+		fill_error(mg, errno, "Failed to stat device \"%s\": %s",
+			   mg->mg_device, strerror(errno));
+		return;
+	}
+
+	if (stat(device, &st2)) {
+		fill_error(mg, errno, "Failed to stat device \"%s\": %s",
+			   device, strerror(errno));
+		return;
+	}
+
+	if (st1.st_rdev != st2.st_rdev) {
 		fill_error(mg, EINVAL,
-			   "Trying to mount fs %s on device %s, but it is already mounted from device %s",
+			   "Trying to mount fs \"%s\" on device \"%s\", "
+			   "but it is already mounted from device \"%s\"",
 			   mg->mg_uuid, device, mg->mg_device);
 		return;
 	}



More information about the Ocfs2-tools-devel mailing list