Skip to contentSkip to conversation

cluster/gfs2/quota check.c gfs2_quota.h main.c

Cluster-devel [email protected] 1 participant 1 message May 31, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: adas at sourceware.org 2007-05-31 22:32:40

Modified files:
gfs2/quota : check.c gfs2_quota.h main.c

Log message:
Changes to fix broken code after Bob pulled out metafs mounting functionality from gfs2_quota into libgfs2.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/check.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/gfs2_quota.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/main.c.diff?cvsroot=cluster&r1=1.5&r2=1.6

gfs2/quota/check.c +23 -17
@@ -191,19 +191,20 @@
 	int error;
 	char quota_file[BUF_SIZE];
 	
+	strcpy(sdp->path_name, comline->filesystem);
 	check_for_gfs2(sdp);
-	read_superblock(&sdp->sd_sb);
+	read_superblock(&sdp->sd_sb, sdp);
 	if (!find_gfs2_meta(sdp))
 		mount_gfs2_meta(sdp);
 	lock_for_admin(sdp);
 	
-	strcpy(quota_file, metafs_path);
+	strcpy(quota_file, sdp->metafs_path);
 	strcat(quota_file, "/quota");
 
 	fd = open(quota_file, O_RDONLY);
 	if (fd < 0) {
-		close(metafs_fd);
-		cleanup();
+		close(sdp->metafs_fd);
+		cleanup_metafs(sdp);
 		die("can't open file %s: %s\n", comline->filesystem,
 		    strerror(errno));
 	}
@@ -216,8 +217,8 @@
 		error = read(fd, buf, sizeof(struct gfs2_quota));
 		if (error < 0) {
 			close(fd);
-			close(metafs_fd);
-			cleanup();
+			close(sdp->metafs_fd);
+			cleanup_metafs(sdp);
 			die("can't read quota file (%d): %s\n",
 			    error, strerror(errno));
 		}
@@ -237,8 +238,8 @@
 	} while (error == sizeof(struct gfs2_quota));
 
 	close(fd);
-	close(metafs_fd);
-	cleanup();
+	close(sdp->metafs_fd);
+	cleanup_metafs(sdp);
 }
 
 /**
@@ -434,20 +435,22 @@
 	int error;
 	char quota_file[BUF_SIZE];
 	char sys_q_refresh[BUF_SIZE];
-	
+	char id_str[16];
+
+	strcpy(sdp->path_name, comline->filesystem);
 	check_for_gfs2(sdp);
-	read_superblock(&sdp->sd_sb);
+	read_superblock(&sdp->sd_sb, sdp);
 	if (!find_gfs2_meta(sdp))
 		mount_gfs2_meta(sdp);
 	lock_for_admin(sdp);
 	
-	strcpy(quota_file, metafs_path);
+	strcpy(quota_file, sdp->metafs_path);
 	strcat(quota_file, "/quota");
 
 	fd = open(quota_file, O_WRONLY);
 	if (fd < 0) {
-		close(metafs_fd);
-		cleanup();
+		close(sdp->metafs_fd);
+		cleanup_metafs(sdp);
 		die("can't open file %s: %s\n", comline->filesystem,
 		    strerror(errno));
 	}
@@ -471,7 +474,7 @@
 			goto out;
 		}
 
-		/* Write "1" to sysfs quota refresh file to refresh gfs quotas */
+		/* Write the id to sysfs quota refresh file to refresh gfs quotas */
 		sprintf(sys_q_refresh, "%s%s%s", "/sys/fs/gfs2/",
 			sdp->sd_sb.sb_locktable, 
 			(user) ? "/quota_refresh_user" :
@@ -483,7 +486,10 @@
 				sys_q_refresh, strerror(errno));
 			goto out;
 		}
-		if (write(fd1,(void*)"1", 1) != 1) {
+
+		sprintf(id_str, "%d", comline->id);
+		
+		if (write(fd1,(void*)id_str, strlen(id_str)) != strlen(id_str)) {
 			close(fd1);
 			fprintf(stderr, "failed to write to %s: %s\n", 
 				sys_q_refresh, strerror(errno));
@@ -494,8 +500,8 @@
 
 out:
 	close(fd);
-	close(metafs_fd);
-	cleanup();
+	close(sdp->metafs_fd);
+	cleanup_metafs(sdp);
 }
 
 /**
gfs2/quota/gfs2_quota.h +1 -8
@@ -69,13 +69,6 @@
 
 #define BUF_SIZE 4096
 #define meta_mount "/tmp/.gfs2meta"
-char device_name[256];
-char fspath[256];
-char fsoptions[256];
-//char meta_mount[PATH_MAX]; = "/tmp/.gfs2meta";
-char metafs_path[BUF_SIZE];
-int metafs_fd;
-int metafs_mounted; /* If metafs was already mounted */
 
 struct commandline {
 	unsigned int operation;
@@ -103,7 +96,7 @@
 void lock_for_admin();
 void mount_gfs2_meta();
 void cleanup();
-void read_superblock(struct gfs2_sb *sb);
+void read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp);
 
 /*  check.c  */
 
gfs2/quota/main.c +103 -60

293 lines not on this page · raw message