LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gfs2_fix_device_name_and_mount_point_in_utils.patch of Package cluster (Project home:sschapiro:openstack:upstream)

commit de94f7c47a2dcea549427bfbfadda5a8bb2e5a10
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Fri May 28 08:28:46 2010 -0500

    Fix device name and mount point in utils
    
    This patch fixes a regression introduced by commit 04f7da3 whereby
    the gfs2-utils identified whether a gfs2 file system was mounted.
    The method works fine when specifying the mount point for tools like
    gfs2_grow.  However, it doesn't work when the device is specified.
    The solution is to copy the discovered device name and mount point
    into the proper libgfs2 variables used by the utils.
    
    rhbz#597002

diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 8981114..31fc665 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -113,9 +113,7 @@ int is_pathname_mounted(struct gfs2_sbd *sdp, int *ro_mount)
 	}
 	if (stat(sdp->path_name, &st_buf) == 0) {
 		if (S_ISBLK(st_buf.st_mode)) {
-#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
 			file_rdev = st_buf.st_rdev;
-#endif  /* __GNU__ */
 		} else {
 			file_dev = st_buf.st_dev;
 			file_ino = st_buf.st_ino;
@@ -131,16 +129,21 @@ int is_pathname_mounted(struct gfs2_sbd *sdp, int *ro_mount)
 			strcpy(sdp->device_name, mnt->mnt_fsname); /* fix it */
 			break;
 		}
-		if (stat(mnt->mnt_fsname, &st_buf) == 0) {
-			if (S_ISBLK(st_buf.st_mode)) {
-#ifndef __GNU__
-				if (file_rdev && (file_rdev == st_buf.st_rdev))
-					break;
-#endif  /* __GNU__ */
-			} else {
-				if (file_dev && ((file_dev == st_buf.st_dev) &&
-						 (file_ino == st_buf.st_ino)))
-					break;
+		if (stat(mnt->mnt_fsname, &st_buf) != 0)
+			continue;
+
+		if (S_ISBLK(st_buf.st_mode)) {
+			if (file_rdev && (file_rdev == st_buf.st_rdev)) {
+				strcpy(sdp->device_name, mnt->mnt_fsname);
+				strcpy(sdp->path_name, mnt->mnt_dir);
+				break;
+			}
+		} else {
+			if (file_dev && ((file_dev == st_buf.st_dev) &&
+					 (file_ino == st_buf.st_ino))) {
+				strcpy(sdp->device_name, mnt->mnt_fsname);
+				strcpy(sdp->path_name, mnt->mnt_dir);
+				break;
 			}
 		}
 	}