FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 02-13-2009, 03:57 PM
Andrew Price
 
Default 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.

Signed-off-by: Andrew Price <andy@andrewprice.me.uk>
---
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
");
-
- memset(path, 0, PATH_MAX);
- snprintf(path, PATH_MAX, "%s", SYS_BASE);
-
- d = opendir(path);
- if (!d)
- die("can't open %s: %s
", 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
", 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
", path, strerror(errno));
-
- close(fd);
-
- p = strstr(s_id, "
");
- if (p)
- *p = '';
-
- total += strlen(s_id) + strlen(de->d_name) + 2;
- if (total > LIST_SIZE)
- break;
-
- x += sprintf(list + x, "%s %s
", 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
");
+
+ memset(path, 0, PATH_MAX);
+ snprintf(path, PATH_MAX, "%s", SYS_BASE);
+
+ d = opendir(path);
+ if (!d)
+ die("can't open %s: %s
", 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
", 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
", path, strerror(errno));
+
+ close(fd);
+
+ p = strstr(s_id, "
");
+ if (p)
+ *p = '';
+
+ total += strlen(s_id) + strlen(de->d_name) + 2;
+ if (total > LIST_SIZE)
+ break;
+
+ x += sprintf(list + x, "%s %s
", s_id, de->d_name);
+
+ }
+
+ closedir(d);
printf("%s", list);
+ free(list);
}

/**
--
1.5.6.5
 

Thread Tools




All times are GMT. The time now is 12:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org