From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32510 invoked by alias); 23 Jan 2009 14:46:54 -0000 Received: (qmail 32503 invoked by alias); 23 Jan 2009 14:46:53 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_40,J_CHICKENPOX_64,J_CHICKENPOX_82,KAM_MX,SPF_HELO_PASS X-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_40,J_CHICKENPOX_64,J_CHICKENPOX_82,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com Subject: gfs2-utils: master - libgfs2: Remove unused functions from misc.c To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: gfs2-utils.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 2c16b529ad7a362d64f56e95609c44de8428eec4 X-Git-Newrev: 2261ffe6720c81660023f6270ae53cf9b0f8fb08 From: Steven Whitehouse Message-Id: <20090123144635.E1AA8C024D@lists.fedorahosted.org> Date: Fri, 23 Jan 2009 14:46: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/msg00230.txt.bz2 Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=2261ffe6720c81660023f6270ae53cf9b0f8fb08 Commit: 2261ffe6720c81660023f6270ae53cf9b0f8fb08 Parent: 2c16b529ad7a362d64f56e95609c44de8428eec4 Author: Steven Whitehouse AuthorDate: Fri Jan 23 13:45:50 2009 +0000 Committer: Steven Whitehouse CommitterDate: Fri Jan 23 13:45:50 2009 +0000 libgfs2: Remove unused functions from misc.c There were several of them. Also I've marked functions only used in the same file as static. Signed-off-by: Steven Whitehouse --- gfs2/libgfs2/libgfs2.h | 4 - gfs2/libgfs2/misc.c | 179 +++-------------------------------------------- 2 files changed, 12 insertions(+), 171 deletions(-) diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index facd04c..50a732c 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -639,15 +639,11 @@ void check_for_gfs2(struct gfs2_sbd *sdp); void mount_gfs2_meta(struct gfs2_sbd *sdp); void cleanup_metafs(struct gfs2_sbd *sdp); char *get_list(void); -char **str2lines(char *str); char *find_debugfs_mount(void); char *mp2fsname(char *mp); -char *__get_sysfs(char *fsname, char *filename); char *get_sysfs(char *fsname, char *filename); unsigned int get_sysfs_uint(char *fsname, char *filename); void set_sysfs(char *fsname, char *filename, char *val); -char *do_basename(char *device); -char *mp2devname(char *mp); int is_fsname(char *name); /* recovery.c */ diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c index 97fd6ab..6dcbf30 100644 --- a/gfs2/libgfs2/misc.c +++ b/gfs2/libgfs2/misc.c @@ -46,8 +46,7 @@ uint32_t compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize, return x; } -void -compute_constants(struct gfs2_sbd *sdp) +void compute_constants(struct gfs2_sbd *sdp) { uint32_t hash_blocks, ind_blocks, leaf_blocks; uint32_t tmp_blocks; @@ -93,8 +92,7 @@ compute_constants(struct gfs2_sbd *sdp) sdp->sd_inptrs); } -void -check_for_gfs2(struct gfs2_sbd *sdp) +void check_for_gfs2(struct gfs2_sbd *sdp) { FILE *fp = fopen("/proc/mounts", "r"); char buffer[PATH_MAX]; @@ -145,8 +143,7 @@ check_for_gfs2(struct gfs2_sbd *sdp) die("gfs2 Filesystem %s is not mounted.\n", sdp->path_name); } -static void -lock_for_admin(struct gfs2_sbd *sdp) +static void lock_for_admin(struct gfs2_sbd *sdp) { int error; @@ -166,8 +163,7 @@ lock_for_admin(struct gfs2_sbd *sdp) } -void -mount_gfs2_meta(struct gfs2_sbd *sdp) +void mount_gfs2_meta(struct gfs2_sbd *sdp) { int ret; @@ -187,8 +183,7 @@ mount_gfs2_meta(struct gfs2_sbd *sdp) lock_for_admin(sdp); } -void -cleanup_metafs(struct gfs2_sbd *sdp) +void cleanup_metafs(struct gfs2_sbd *sdp) { int ret; @@ -205,7 +200,7 @@ cleanup_metafs(struct gfs2_sbd *sdp) rmdir(sdp->metafs_path); } -char *__get_sysfs(char *fsname, char *filename) +static char *__get_sysfs(char *fsname, char *filename) { char path[PATH_MAX]; int fd, rv; @@ -225,8 +220,7 @@ char *__get_sysfs(char *fsname, char *filename) return sysfs_buf; } -char * -get_sysfs(char *fsname, char *filename) +char *get_sysfs(char *fsname, char *filename) { char *p = strchr(__get_sysfs(fsname, filename), '\n'); if (p) @@ -234,16 +228,14 @@ get_sysfs(char *fsname, char *filename) return sysfs_buf; } -unsigned int -get_sysfs_uint(char *fsname, char *filename) +unsigned int get_sysfs_uint(char *fsname, char *filename) { unsigned int x; sscanf(__get_sysfs(fsname, filename), "%u", &x); return x; } -void -set_sysfs(char *fsname, char *filename, char *val) +void set_sysfs(char *fsname, char *filename, char *val) { char path[PATH_MAX]; int fd, rv, len; @@ -278,8 +270,7 @@ set_sysfs(char *fsname, char *filename, char *val) #define LIST_SIZE 1048576 -char * -get_list(void) +char *get_list(void) { char path[PATH_MAX]; char s_id[PATH_MAX]; @@ -335,123 +326,7 @@ get_list(void) return list; } -/** - * str2lines - parse a string into lines - * @list: the list - * - * Returns: An array of character pointers - */ - -char ** -str2lines(char *str) -{ - char *p; - unsigned int n = 0; - char **lines; - unsigned int x = 0; - - for (p = str; *p; p++) - if (*p == '\n') - n++; - - lines = malloc((n + 1) * sizeof(char *)); - if (!lines) - die("out of memory\n"); - - for (lines[x] = p = str; *p; p++) - if (*p == '\n') { - *p = 0; - lines[++x] = p + 1; - } - - return lines; -} - -/** - * do_basename - Create dm-N style name for the device - * @device: - * - * Returns: Pointer to dm name or basename - */ - -char * -do_basename(char *device) -{ - FILE *file; - int found = FALSE; - char line[PATH_MAX], major_name[PATH_MAX]; - unsigned int major_number; - struct stat st; - - file = fopen("/proc/devices", "r"); - if (!file) - goto punt; - - while (fgets(line, PATH_MAX, file)) { - if (sscanf(line, "%u %s", &major_number, major_name) != 2) - continue; - if (strcmp(major_name, "device-mapper") != 0) - continue; - found = TRUE; - break; - } - - fclose(file); - - if (!found) - goto punt; - - if (stat(device, &st)) - goto punt; - if (major(st.st_rdev) == major_number) { - static char realname[16]; - snprintf(realname, 16, "dm-%u", minor(st.st_rdev)); - return realname; - } - - punt: - return basename(device); -} - -char * -mp2devname(char *mp) -{ - FILE *file; - char line[PATH_MAX]; - static char device[PATH_MAX]; - char *name = NULL; - char *realname; - - realname = realpath(mp, NULL); - if (!realname) - die("Unable to allocate memory for name resolution.\n"); - file = fopen("/proc/mounts", "r"); - if (!file) - die("can't open /proc/mounts: %s\n", strerror(errno)); - - while (fgets(line, PATH_MAX, file)) { - char path[PATH_MAX], type[PATH_MAX]; - - if (sscanf(line, "%s %s %s", device, path, type) != 3) - continue; - if (strcmp(path, realname)) - continue; - if (strcmp(type, "gfs2")) - die("%s is not a GFS2 filesystem\n", mp); - - name = do_basename(device); - - break; - } - - free(realname); - fclose(file); - - return name; -} - -char * -find_debugfs_mount(void) +char *find_debugfs_mount(void) { FILE *file; char line[PATH_MAX]; @@ -480,35 +355,6 @@ find_debugfs_mount(void) return NULL; } -/* The fsname can be substituted for the mountpoint on the command line. - This is necessary when we can't resolve a devname from /proc/mounts - to a fsname. */ - -int is_fsname(char *name) -{ - int rv = 0; - DIR *d; - struct dirent *de; - - d = opendir(SYS_BASE); - if (!d) - die("can't open %s: %s\n", SYS_BASE, strerror(errno)); - - while ((de = readdir(d))) { - if (de->d_name[0] == '.') - continue; - - if (strcmp(de->d_name, name) == 0) { - rv = 1; - break; - } - } - - closedir(d); - - return rv; -} - /** * mp2fsname - Find the name for a filesystem given its mountpoint * @@ -529,8 +375,7 @@ int is_fsname(char *name) * Returns: the fsname */ -char * -mp2fsname(char *mp) +char *mp2fsname(char *mp) { char device_id[PATH_MAX], *fsname = NULL; struct stat statbuf;