public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - libgfs2: Move get_list out of libgfs2
@ 2009-02-19 10:12 Fabio M. Di Nitto
  0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-02-19 10:12 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b9f3126df3677591639af69bebd5c279bd655ef6
Commit:        b9f3126df3677591639af69bebd5c279bd655ef6
Parent:        7e5b2eea8826e79f4be10a2dc41887564e4a503e
Author:        Andrew Price <andy@andrewprice.me.uk>
AuthorDate:    Fri Feb 13 16:16:18 2009 +0000
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Thu Feb 19 10:59:58 2009 +0100

libgfs2: Move get_list out of libgfs2

This function was only used in gfs2_tool so it can be moved out of
libgfs2 and merged into gfs2_tool's print_list function. This also
removes four more uses of 'die' from libgfs2.
---
 gfs2/libgfs2/libgfs2.h |    1 -
 gfs2/libgfs2/misc.c    |   64 ------------------------------------------------
 gfs2/tool/misc.c       |   54 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 53 insertions(+), 66 deletions(-)

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index a89c25c..a25cf7b 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -630,7 +630,6 @@ extern int dir_exists(const char *dir);
 extern int check_for_gfs2(struct gfs2_sbd *sdp);
 extern void mount_gfs2_meta(struct gfs2_sbd *sdp);
 extern void cleanup_metafs(struct gfs2_sbd *sdp);
-extern char *get_list(void);
 extern char *find_debugfs_mount(void);
 extern char *mp2fsname(char *mp);
 extern char *get_sysfs(char *fsname, char *filename);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index d5ce490..21329f3 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -267,70 +267,6 @@ int set_sysfs(char *fsname, char *filename, char *val)
 	return 0;
 }
 
-/**
- * get_list - Get the list of GFS2 filesystems
- *
- * Returns: a NULL terminated string
- */
-
-#define LIST_SIZE 1048576
-
-char *get_list(void)
-{
-	char path[PATH_MAX];
-	char s_id[PATH_MAX];
-	char *list, *p;
-	int rv, fd, x = 0, total = 0;
-	DIR *d;
-	struct dirent *de;
-
-	list = malloc(LIST_SIZE);
-	if (!list)
-		die("out of memory\n");
-
-	memset(path, 0, PATH_MAX);
-	snprintf(path, PATH_MAX, "%s", SYS_BASE);
-
-	d = opendir(path);
-	if (!d)
-		die("can't open %s: %s\n", SYS_BASE, strerror(errno));
-
-	while ((de = readdir(d))) {
-		if (de->d_name[0] == '.')
-			continue;
-
-		memset(path, 0, PATH_MAX);
-		snprintf(path, PATH_MAX, "%s/%s/id", SYS_BASE, de->d_name);
-
-		fd = open(path, O_RDONLY);
-		if (fd < 0)
-			die("can't open %s: %s\n", path, strerror(errno));
-
-		memset(s_id, 0, PATH_MAX);
-
-		rv = read(fd, s_id, sizeof(s_id));
-		if (rv < 0)
-			die("can't read %s: %s\n", path, strerror(errno));
-
-		close(fd);
-
-		p = strstr(s_id, "\n");
-		if (p)
-			*p = '\0';
-
-		total += strlen(s_id) + strlen(de->d_name) + 2;
-		if (total > LIST_SIZE)
-			break;
-
-		x += sprintf(list + x, "%s %s\n", s_id, de->d_name);
-
-	}
-
-	closedir(d);
-
-	return list;
-}
-
 char *find_debugfs_mount(void)
 {
 	FILE *file;
diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
index 2e57cd1..f23ec82 100644
--- a/gfs2/tool/misc.c
+++ b/gfs2/tool/misc.c
@@ -362,11 +362,63 @@ print_journals(int argc, char **argv)
  *
  */
 
+#define LIST_SIZE 1048576
+
 void
 print_list(void)
 {
-	char *list = get_list();
+	char path[PATH_MAX];
+	char s_id[PATH_MAX];
+	char *list, *p;
+	int rv, fd, x = 0, total = 0;
+	DIR *d;
+	struct dirent *de;
+
+	list = malloc(LIST_SIZE);
+	if (!list)
+		die("out of memory\n");
+
+	memset(path, 0, PATH_MAX);
+	snprintf(path, PATH_MAX, "%s", SYS_BASE);
+
+	d = opendir(path);
+	if (!d)
+		die("can't open %s: %s\n", SYS_BASE, strerror(errno));
+
+	while ((de = readdir(d))) {
+		if (de->d_name[0] == '.')
+			continue;
+
+		memset(path, 0, PATH_MAX);
+		snprintf(path, PATH_MAX, "%s/%s/id", SYS_BASE, de->d_name);
+
+		fd = open(path, O_RDONLY);
+		if (fd < 0)
+			die("can't open %s: %s\n", path, strerror(errno));
+
+		memset(s_id, 0, PATH_MAX);
+
+		rv = read(fd, s_id, sizeof(s_id));
+		if (rv < 0)
+			die("can't read %s: %s\n", path, strerror(errno));
+
+		close(fd);
+
+		p = strstr(s_id, "\n");
+		if (p)
+			*p = '\0';
+
+		total += strlen(s_id) + strlen(de->d_name) + 2;
+		if (total > LIST_SIZE)
+			break;
+
+		x += sprintf(list + x, "%s %s\n", s_id, de->d_name);
+
+	}
+
+	closedir(d);
 	printf("%s", list);
+	free(list);
 }
 
 /**


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-19 10:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-19 10:12 cluster: STABLE3 - libgfs2: Move get_list out of libgfs2 Fabio M. Di Nitto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).