From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24388 invoked by alias); 20 Mar 2009 15:09:24 -0000 Received: (qmail 24382 invoked by alias); 20 Mar 2009 15:09:23 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_64,J_CHICKENPOX_84,SPF_HELO_PASS X-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_64,J_CHICKENPOX_84,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: STABLE3 - libgfs2: Remove 'die' from mp2fsname and find_debugfs_mount To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: edbdbe7a0222696f8365630887cde07b618a5345 X-Git-Newrev: 7b1682fe3d091aebbe9a69862c65c9c94c893e9a From: Andrew Price Message-Id: <20090320150900.D55C11202D3@lists.fedorahosted.org> Date: Fri, 20 Mar 2009 15:09:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00848.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7b1682fe3d091aebbe9a69862c65c9c94c893e9a Commit: 7b1682fe3d091aebbe9a69862c65c9c94c893e9a Parent: edbdbe7a0222696f8365630887cde07b618a5345 Author: Andrew Price AuthorDate: Fri Mar 20 12:45:25 2009 +0000 Committer: Andrew Price CommitterDate: Fri Mar 20 14:41:16 2009 +0000 libgfs2: Remove 'die' from mp2fsname and find_debugfs_mount Removes the call to 'die' from mp2fsname and updates its callers to handle the error. Also removes the die calls from find_debugfs_mount which only has one caller that already handles the error cases. --- gfs2/libgfs2/misc.c | 10 ++++++---- gfs2/quota/check.c | 8 +++++++- gfs2/quota/main.c | 10 ++++++++++ gfs2/tool/df.c | 5 +++++ gfs2/tool/misc.c | 15 +++++++++++++++ gfs2/tool/tune.c | 10 ++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c index 7666ded..8441137 100644 --- a/gfs2/libgfs2/misc.c +++ b/gfs2/libgfs2/misc.c @@ -291,11 +291,13 @@ char *find_debugfs_mount(void) file = fopen("/proc/mounts", "rt"); if (!file) - die("can't open /proc/mounts: %s\n", strerror(errno)); + return NULL; path = malloc(PATH_MAX); - if (!path) - die("Can't allocate memory for debugfs.\n"); + if (!path) { + fclose(file); + return NULL; + } while (fgets(line, PATH_MAX, file)) { if (sscanf(line, "%s %s %s", device, path, type) != 3) @@ -432,7 +434,7 @@ char *mp2fsname(char *mp) d = opendir(SYS_BASE); if (!d) - die("can't open %s: %s\n", SYS_BASE, strerror(errno)); + return NULL; while ((de = readdir(d))) { if (de->d_name[0] == '.') diff --git a/gfs2/quota/check.c b/gfs2/quota/check.c index 0352fa9..9223971 100644 --- a/gfs2/quota/check.c +++ b/gfs2/quota/check.c @@ -507,8 +507,14 @@ set_list(struct gfs2_sbd *sdp, commandline_t *comline, int user, goto out; } - /* Write the id to sysfs quota refresh file to refresh gfs quotas */ fs = mp2fsname(comline->filesystem); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + comline->filesystem); + exit(-1); + } + + /* Write the id to sysfs quota refresh file to refresh gfs quotas */ sprintf(id_str, "%d", comline->id); if (set_sysfs(fs, (user) ? "quota_refresh_user" : "quota_refresh_group", id_str)) { diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c index 374b5ea..7b6ad78 100644 --- a/gfs2/quota/main.c +++ b/gfs2/quota/main.c @@ -783,6 +783,11 @@ do_sync_one(struct gfs2_sbd *sdp, char *filesystem) char *fsname; fsname = mp2fsname(filesystem); + if (!fsname) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + filesystem); + exit(-1); + } if (set_sysfs(fsname, "quota_sync", "1")) { fprintf(stderr, "Error writing to sysfs quota sync file: %s\n", strerror(errno)); @@ -992,6 +997,11 @@ do_set(struct gfs2_sbd *sdp, commandline_t *comline) } fs = mp2fsname(comline->filesystem); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + comline->filesystem); + exit(-1); + } sprintf(id_str, "%d", comline->id); if (set_sysfs(fs, comline->id_type == GQ_ID_USER ? "quota_refresh_user" : "quota_refresh_group", id_str)) { diff --git a/gfs2/tool/df.c b/gfs2/tool/df.c index c817813..8b6d9b4 100644 --- a/gfs2/tool/df.c +++ b/gfs2/tool/df.c @@ -95,6 +95,11 @@ do_df_one(char *path) exit(-1); } fs = mp2fsname(sbd.path_name); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + sbd.path_name); + exit(-1); + } sbd.device_fd = open(sbd.device_name, O_RDONLY); if (sbd.device_fd < 0) diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c index 694acb8..3315e6e 100644 --- a/gfs2/tool/misc.c +++ b/gfs2/tool/misc.c @@ -272,6 +272,11 @@ print_args(int argc, char **argv) exit(-1); } fs = mp2fsname(argv[optind]); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + argv[optind]); + exit(-1); + } memset(path, 0, PATH_MAX); snprintf(path, PATH_MAX - 1, "%s/%s/args/", SYS_BASE, fs); @@ -457,6 +462,11 @@ do_shrink(int argc, char **argv) exit(-1); } fs = mp2fsname(argv[optind]); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + argv[optind]); + exit(-1); + } if (set_sysfs(fs, "shrink", "1")) { fprintf(stderr, "Error writing to sysfs shrink file: %s\n", @@ -491,6 +501,11 @@ do_withdraw(int argc, char **argv) exit(-1); } name = mp2fsname(argv[optind]); + if (!name) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + argv[optind]); + exit(-1); + } if (set_sysfs(name, "withdraw", "1")) { fprintf(stderr, "Error writing to sysfs withdraw file: %s\n", diff --git a/gfs2/tool/tune.c b/gfs2/tool/tune.c index 29c529b..277d2dd 100644 --- a/gfs2/tool/tune.c +++ b/gfs2/tool/tune.c @@ -54,6 +54,11 @@ get_tune(int argc, char **argv) exit(-1); } fs = mp2fsname(argv[optind]); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + argv[optind]); + exit(-1); + } memset(path, 0, PATH_MAX); snprintf(path, PATH_MAX - 1, "%s/%s/tune", SYS_BASE, fs); @@ -117,6 +122,11 @@ set_tune(int argc, char **argv) exit(-1); } fs = mp2fsname(sbd.path_name); + if (!fs) { + fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n", + sbd.path_name); + exit(-1); + } if (strcmp(param, "quota_scale") == 0) { float s;