Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
List overview
Download
cluster-commits
August 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
cluster-commits@lists.stg.fedorahosted.org
8 participants
54 discussions
Start a n
N
ew thread
gfs2-utils: master - gfs_controld: fix ignore_nolock for mounted nolock fs
by David Teigland
30 Aug '12
30 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=e04ac4bed3…
Commit: e04ac4bed3cf5b2b3376fdcbf4485bc4fa2f2b36 Parent: 0d6743bc762d01ca66867e9cf58692d57fce0317 Author: Bob Peterson <rpeterso(a)redhat.com> AuthorDate: Thu Aug 30 11:36:43 2012 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Thu Aug 30 11:54:13 2012 -0500 gfs_controld: fix ignore_nolock for mounted nolock fs kernel now shows lock_module/proto_name for lock_nolock, so fix the check. bz 853180 Signed-off-by: Bob Peterson <rpeterso(a)redhat.com> Signed-off-by: David Teigland <teigland(a)redhat.com> --- group/gfs_controld/util.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/group/gfs_controld/util.c b/group/gfs_controld/util.c index 440f974..f77f85b 100644 --- a/group/gfs_controld/util.c +++ b/group/gfs_controld/util.c @@ -184,7 +184,8 @@ void update_dmsetup_wait(void) static int ignore_nolock(const char *sysfs_dir, char *table) { char path[PATH_MAX]; - int fd; + char buf[32]; + int fd, rv; memset(path, 0, PATH_MAX); @@ -198,7 +199,16 @@ static int ignore_nolock(const char *sysfs_dir, char *table) if (fd < 0) return 1; + memset(buf, 0, sizeof(buf)); + + rv = read(fd, buf, sizeof(buf)); close(fd); + if (rv < 0) + return 1; + + if (!strncmp(buf, "lock_nolock", 11)) + return 1; + return 0; }
1
0
0
0
cluster: STABLE32 - fenced: fix ignore_nolock for mounted nolock fs
by David Teigland
30 Aug '12
30 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=80b7f2cc7bc5e…
Commit: 80b7f2cc7bc5eaa52cdeb89e53a0c5be1ae9a1e9 Parent: 606ad31b5c7d31b33c74633e048d6b89666a183f Author: Bob Peterson <rpeterso(a)redhat.com> AuthorDate: Thu Aug 30 11:36:43 2012 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Thu Aug 30 11:51:22 2012 -0500 fenced: fix ignore_nolock for mounted nolock fs kernel now shows lock_module/proto_name for lock_nolock, so fix the check. bz 853180 Signed-off-by: Bob Peterson <rpeterso(a)redhat.com> Signed-off-by: David Teigland <teigland(a)redhat.com> --- fence/fenced/main.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/fence/fenced/main.c b/fence/fenced/main.c index 312414c..2339a5d 100644 --- a/fence/fenced/main.c +++ b/fence/fenced/main.c @@ -636,7 +636,8 @@ static void register_controlled_dir(const char *path) static int ignore_nolock(char *sysfs_dir, char *table) { char path[PATH_MAX]; - int fd; + char buf[32]; + int fd, rv; memset(path, 0, PATH_MAX); @@ -650,7 +651,16 @@ static int ignore_nolock(char *sysfs_dir, char *table) if (fd < 0) return 1; + memset(buf, 0, sizeof(buf)); + + rv = read(fd, buf, sizeof(buf)); close(fd); + if (rv < 0) + return 1; + + if (!strncmp(buf, "lock_nolock", 11)) + return 1; + return 0; }
1
0
0
0
cluster: RHEL6 - gfs_controld, fenced: fix ignore_nolock for mounted nolock fs
by David Teigland
30 Aug '12
30 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6b7602b0f6526…
Commit: 6b7602b0f65268e2f09c87a314cda3947d839b35 Parent: bb0daf4c52d18205b0c57448f7ee160d29fed90c Author: Bob Peterson <rpeterso(a)redhat.com> AuthorDate: Thu Aug 30 11:36:43 2012 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Thu Aug 30 11:46:50 2012 -0500 gfs_controld, fenced: fix ignore_nolock for mounted nolock fs kernel now shows lock_module/proto_name for lock_nolock, so fix the check. bz 853180 Signed-off-by: Bob Peterson <rpeterso(a)redhat.com> Signed-off-by: David Teigland <teigland(a)redhat.com> --- fence/fenced/main.c | 12 +++++++++++- group/gfs_controld/util.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/fence/fenced/main.c b/fence/fenced/main.c index cc11382..827dab6 100644 --- a/fence/fenced/main.c +++ b/fence/fenced/main.c @@ -636,7 +636,8 @@ static void register_controlled_dir(const char *path) static int ignore_nolock(char *sysfs_dir, char *table) { char path[PATH_MAX]; - int fd; + char buf[32]; + int fd, rv; memset(path, 0, PATH_MAX); @@ -650,7 +651,16 @@ static int ignore_nolock(char *sysfs_dir, char *table) if (fd < 0) return 1; + memset(buf, 0, sizeof(buf)); + + rv = read(fd, buf, sizeof(buf)); close(fd); + if (rv < 0) + return 1; + + if (!strncmp(buf, "lock_nolock", 11)) + return 1; + return 0; } diff --git a/group/gfs_controld/util.c b/group/gfs_controld/util.c index 7aea26e..80e2bf7 100644 --- a/group/gfs_controld/util.c +++ b/group/gfs_controld/util.c @@ -217,7 +217,8 @@ void update_dmsetup_wait(void) static int ignore_nolock(const char *sysfs_dir, char *table) { char path[PATH_MAX]; - int fd; + char buf[32]; + int fd, rv; memset(path, 0, PATH_MAX); @@ -231,7 +232,16 @@ static int ignore_nolock(const char *sysfs_dir, char *table) if (fd < 0) return 1; + memset(buf, 0, sizeof(buf)); + + rv = read(fd, buf, sizeof(buf)); close(fd); + if (rv < 0) + return 1; + + if (!strncmp(buf, "lock_nolock", 11)) + return 1; + return 0; }
1
0
0
0
cluster: RHEL58 - rgmanager: Fix for reading /proc/mounts in fs.sh
by Ryan McCabe
30 Aug '12
30 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=bdf0650eb6110…
Commit: bdf0650eb61104933d76a4b74adc12c37ac3511a Parent: 790a470007b24c94089d2d97f18f5664c6ddaada Author: Ryan McCabe <rmccabe(a)redhat.com> AuthorDate: Wed Aug 29 09:54:56 2012 -0400 Committer: Ryan McCabe <rmccabe(a)redhat.com> CommitterDate: Thu Aug 30 09:23:18 2012 -0400 rgmanager: Fix for reading /proc/mounts in fs.sh This patch fixes a problem with the fs resource agent that caused status checks to mistakenly fail as a result of /proc/mounts changing while it was being read. Patch from John Ruemker <jruemker(a)redhat.com> Resolves rhbz#852865 Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com> Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com> --- rgmanager/src/resources/fs.sh | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh index a98cddc..7e6898c 100755 --- a/rgmanager/src/resources/fs.sh +++ b/rgmanager/src/resources/fs.sh @@ -560,6 +560,8 @@ mountInUse () { dev=$1 mp=$2 + typeset proc_mounts=$(mktemp /tmp/fs-$OCF_RESKEY_name.proc.mounts.XXXXXX) + cat /proc/mounts > $proc_mounts while read tmp_dev tmp_mp junka junkb junkc junkd; do if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then return $YES @@ -568,7 +570,8 @@ mountInUse () { if [ -n "$tmp_mp" -a "$tmp_mp" = "$mp" ]; then return $YES fi - done < /proc/mounts + done < $proc_mounts + rm -f $proc_mounts return $NO } @@ -609,6 +612,8 @@ isMounted () { ret=$NO + typeset proc_mounts=$(mktemp /tmp/fs-$OCF_RESKEY_name.proc.mounts.XXXXXX) + cat /proc/mounts > $proc_mounts while read tmp_dev tmp_mp junk_a junk_b junk_c junk_d do real_device $tmp_dev @@ -633,7 +638,8 @@ isMounted () { fi ret=$YES fi - done < /proc/mounts + done < $proc_mounts + rm -f $proc_mounts if [ $ret -eq $YES ] && [ $found -ne 0 ]; then ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
1
0
0
0
cluster: RHEL59 - rgmanager: Fix for reading /proc/mounts in fs.sh
by Ryan McCabe
29 Aug '12
29 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=b1f42a7a30d0e…
Commit: b1f42a7a30d0ea55c5d152774acde97f5704928b Parent: 25eebc0689b97ffaa32cf43a59f4c8db8819a9cd Author: Ryan McCabe <rmccabe(a)redhat.com> AuthorDate: Wed Aug 29 09:54:56 2012 -0400 Committer: Ryan McCabe <rmccabe(a)redhat.com> CommitterDate: Wed Aug 29 09:54:56 2012 -0400 rgmanager: Fix for reading /proc/mounts in fs.sh This patch fixes a problem with the fs resource agent that caused status checks to mistakenly fail as a result of /proc/mounts changing while it was being read. Patch from John Ruemker <jruemker(a)redhat.com> Resolves rhbz#847125 Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com> --- rgmanager/src/resources/fs.sh | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh index 9dec8d1..147f246 100755 --- a/rgmanager/src/resources/fs.sh +++ b/rgmanager/src/resources/fs.sh @@ -560,6 +560,8 @@ mountInUse () { dev=$1 mp=$2 + typeset proc_mounts=$(mktemp /tmp/fs-$OCF_RESKEY_name.proc.mounts.XXXXXX) + cat /proc/mounts > $proc_mounts while read tmp_dev tmp_mp junka junkb junkc junkd; do if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then return $YES @@ -568,7 +570,8 @@ mountInUse () { if [ -n "$tmp_mp" -a "$tmp_mp" = "$mp" ]; then return $YES fi - done < /proc/mounts + done < $proc_mounts + rm -f $proc_mounts return $NO } @@ -609,6 +612,8 @@ isMounted () { ret=$NO + typeset proc_mounts=$(mktemp /tmp/fs-$OCF_RESKEY_name.proc.mounts.XXXXXX) + cat /proc/mounts > $proc_mounts while read tmp_dev tmp_mp junk_a junk_b junk_c junk_d do real_device $tmp_dev @@ -633,7 +638,8 @@ isMounted () { fi ret=$YES fi - done < /proc/mounts + done < $proc_mounts + rm -f $proc_mounts if [ $ret -eq $YES ] && [ $found -ne 0 ]; then ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
1
0
0
0
gfs2-utils: master - gfs2_edit: Some comment cleanups
by Andrew Price
28 Aug '12
28 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=0d6743bc76…
Commit: 0d6743bc762d01ca66867e9cf58692d57fce0317 Parent: d246cd8dda0a2fc9a3e1389ac7be8d33d46eba21 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Mon Aug 6 19:59:54 2012 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Aug 28 16:28:39 2012 +0100 gfs2_edit: Some comment cleanups Remove some empty function comments to make things a bit more readable. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/edit/extended.c | 45 --------------------------------- gfs2/edit/gfs2hex.c | 68 ++----------------------------------------------- gfs2/edit/hexedit.c | 10 ------- 3 files changed, 3 insertions(+), 120 deletions(-) diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c index e2567a5..17372ae 100644 --- a/gfs2/edit/extended.c +++ b/gfs2/edit/extended.c @@ -30,9 +30,6 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height, int pndx, uint64_t file_offset); -/* ------------------------------------------------------------------------ */ -/* get_height */ -/* ------------------------------------------------------------------------ */ static int get_height(void) { int cur_height = 0, i; @@ -49,9 +46,6 @@ static int get_height(void) return cur_height; } -/* ------------------------------------------------------------------------ */ -/* _do_indirect_extended */ -/* ------------------------------------------------------------------------ */ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt) { unsigned int x, y; @@ -81,9 +75,6 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt) return i_blocks; } -/* ------------------------------------------------------------------------ */ -/* do_indirect_extended */ -/* ------------------------------------------------------------------------ */ int do_indirect_extended(char *diebuf, struct iinfo *iinf) { return _do_indirect_extended(diebuf, iinf, get_height()); @@ -107,9 +98,6 @@ static int dinode_valid(void) return 0; } -/* ------------------------------------------------------------------------ */ -/* metapath_to_lblock - convert from metapath, height to logical block */ -/* ------------------------------------------------------------------------ */ static uint64_t metapath_to_lblock(struct metapath *mp, int hgt) { int h; @@ -128,9 +116,6 @@ static uint64_t metapath_to_lblock(struct metapath *mp, int hgt) return lblock; } -/* ------------------------------------------------------------------------ */ -/* display_indirect */ -/* ------------------------------------------------------------------------ */ static int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t startoff) { @@ -246,9 +231,6 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level, return 0; } -/* ------------------------------------------------------------------------ */ -/* print_inode_type */ -/* ------------------------------------------------------------------------ */ static void print_inode_type(__be16 de_type) { if (sbd.gfs1) { @@ -314,9 +296,6 @@ static void print_inode_type(__be16 de_type) } } -/* ------------------------------------------------------------------------ */ -/* display_leaf - display directory leaf */ -/* ------------------------------------------------------------------------ */ static int display_leaf(struct iinfo *ind) { int start_line, total_dirents = start_row[dmode]; @@ -374,9 +353,6 @@ static int display_leaf(struct iinfo *ind) return 0; } -/* ------------------------------------------------------------------------ */ -/* print_block_details */ -/* ------------------------------------------------------------------------ */ static void print_block_details(struct iinfo *ind, int level, int cur_height, int pndx, uint64_t file_offset) { @@ -441,9 +417,6 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height, free(more_indir); } -/* ------------------------------------------------------------------------ */ -/* gfs_jindex_print - print an jindex entry. */ -/* ------------------------------------------------------------------------ */ static void gfs_jindex_print(struct gfs_jindex *ji) { pv((unsigned long long)ji, ji_addr, "%llu", "0x%llx"); @@ -451,9 +424,6 @@ static void gfs_jindex_print(struct gfs_jindex *ji) pv(ji, ji_pad, "%u", "0x%x"); } -/* ------------------------------------------------------------------------ */ -/* print_jindex - print the jindex file. */ -/* ------------------------------------------------------------------------ */ static int print_jindex(struct gfs2_inode *dij) { int error, start_line; @@ -494,9 +464,6 @@ static int print_jindex(struct gfs2_inode *dij) return error; } -/* ------------------------------------------------------------------------ */ -/* parse_rindex - print the rgindex file. */ -/* ------------------------------------------------------------------------ */ static int parse_rindex(struct gfs2_inode *dip, int print_rindex) { int error, start_line; @@ -562,9 +529,6 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex) return error; } -/* ------------------------------------------------------------------------ */ -/* print_inum - print the inum file. */ -/* ------------------------------------------------------------------------ */ static int print_inum(struct gfs2_inode *dii) { uint64_t inum, inodenum; @@ -587,9 +551,6 @@ static int print_inum(struct gfs2_inode *dii) return 0; } -/* ------------------------------------------------------------------------ */ -/* print_statfs - print the statfs file. */ -/* ------------------------------------------------------------------------ */ static int print_statfs(struct gfs2_inode *dis) { struct gfs2_statfs_change sfb, sfc; @@ -613,9 +574,6 @@ static int print_statfs(struct gfs2_inode *dis) return 0; } -/* ------------------------------------------------------------------------ */ -/* print_quota - print the quota file. */ -/* ------------------------------------------------------------------------ */ static int print_quota(struct gfs2_inode *diq) { struct gfs2_quota qbuf, q; @@ -642,9 +600,6 @@ static int print_quota(struct gfs2_inode *diq) return 0; } -/* ------------------------------------------------------------------------ */ -/* display_extended */ -/* ------------------------------------------------------------------------ */ int display_extended(void) { struct gfs2_inode *tmp_inode; diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c index 41630f9..6979cd9 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -19,7 +19,6 @@ #include "extended.h" #include "gfs2hex.h" -/* from libgfs2: */ #include "libgfs2.h" #define pv(struct, member, fmt, fmt2) do { \ @@ -255,21 +254,6 @@ static int indirect_dirent(struct indirect_info *indir, char *ptr, int d) return de.de_rec_len; } -/****************************************************************************** -******************************************************************************* -** -** do_dinode_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh) { unsigned int x, y, ptroff = 0; @@ -350,21 +334,9 @@ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh) } /* if exhash */ }/* do_dinode_extended */ -/****************************************************************************** -******************************************************************************* -** -** do_leaf_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: next leaf block, if any, in a chain of leaf blocks -** -******************************************************************************* -******************************************************************************/ +/** + * Returns: next leaf block, if any, in a chain of leaf blocks + */ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir) { int x, i; @@ -403,23 +375,6 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir) return leaf.lf_next; } - -/****************************************************************************** -******************************************************************************* -** -** do_eattr_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ - static void do_eattr_extended(struct gfs2_buffer_head *ebh) { struct gfs2_ea_header ea; @@ -524,23 +479,6 @@ static void gfs1_rgrp_print(struct gfs1_rgrp *rg) pv(rg, rg_freemeta, "%u", "0x%x"); } -/****************************************************************************** -******************************************************************************* -** -** int display_gfs2() -** -** Description: -** This routine... -** -** Input(s): -** *buffer - -** extended - -** -** Returns: -** 0 if OK, 1 on error. -** -******************************************************************************* -******************************************************************************/ int display_gfs2(void) { struct gfs2_meta_header mh; diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 79082b8..ff0dca9 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -3101,16 +3101,6 @@ static void process_parameters(int argc, char *argv[], int pass) } /* for */ }/* process_parameters */ -/****************************************************************************** -******************************************************************************* -** -** main() -** -** Description: -** Do everything -** -******************************************************************************* -******************************************************************************/ int main(int argc, char *argv[]) { int i, j, fd;
1
0
0
0
gfs2-utils: master - libgfs2: Remove exit call from __gfs_inode_get
by Andrew Price
28 Aug '12
28 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=d246cd8dda…
Commit: d246cd8dda0a2fc9a3e1389ac7be8d33d46eba21 Parent: 9da423e59289bf8ce8bd4c78653fb678539c49b4 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Sat Aug 25 00:26:23 2012 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Sat Aug 25 00:26:23 2012 +0100 libgfs2: Remove exit call from __gfs_inode_get Return NULL instead of exiting on a failed calloc() and handle the error at all call points. Also update the names of gfs_inode_{get,read} with the lgfs2_ prefix. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/convert/gfs2_convert.c | 12 ++++++++++-- gfs2/edit/savemeta.c | 30 +++++++++++++++++------------- gfs2/fsck/metawalk.c | 4 ++-- gfs2/libgfs2/gfs1.c | 7 +++---- gfs2/libgfs2/libgfs2.h | 4 ++-- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 51ec256..b5d993d 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -895,7 +895,11 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh) struct inode_block *fixdir; int inode_was_gfs1; - inode = gfs_inode_get(sbp, bh); + inode = lgfs2_gfs_inode_get(sbp, bh); + if (inode == NULL) { + log_crit(_("Error reading inode: %s\n"), strerror(errno)); + return -1; + } inode_was_gfs1 = (inode->i_di.di_num.no_formal_ino == inode->i_di.di_num.no_addr); @@ -1591,7 +1595,11 @@ static int init(struct gfs2_sbd *sbp) } /* get gfs1 rindex inode - gfs1's rindex inode ptr became __pad2 */ gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_rindex_di); - sbp->md.riinode = gfs_inode_read(sbp, inum.no_addr); + sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.no_addr); + if (sbp->md.riinode == NULL) { + log_crit(_("Could not read resource group index: %s\n"), strerror(errno)); + exit(-1); + } /* get gfs1 jindex inode - gfs1's journal index inode ptr became master */ gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di); sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr); diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 77165a7..f35c35d 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -147,13 +147,13 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type, break; case GFS2_METATYPE_DI: /* 4 (disk inode) */ if (sbd.gfs1) { - inode = gfs_inode_get(&sbd, lbh); + inode = lgfs2_gfs_inode_get(&sbd, lbh); } else { inode = lgfs2_inode_get(&sbd, lbh); - if (inode == NULL) { - fprintf(stderr, "Out of memory\n"); - exit(-1); - } + } + if (inode == NULL) { + perror("Error reading inode"); + exit(-1); } if (S_ISDIR(inode->i_di.di_mode) || (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)) @@ -488,14 +488,14 @@ static void save_inode_data(struct metafd *mfd) for (i = 0; i < GFS2_MAX_META_HEIGHT; i++) osi_list_init(&metalist[i]); metabh = bread(&sbd, block); - if (sbd.gfs1) - inode = gfs_inode_get(&sbd, metabh); - else { + if (sbd.gfs1) { + inode = lgfs2_gfs_inode_get(&sbd, metabh); + } else { inode = lgfs2_inode_get(&sbd, metabh); - if (inode == NULL) { - fprintf(stderr, "Failed to read inode: %s\n", strerror(errno)); - exit(-1); - } + } + if (inode == NULL) { + perror("Failed to read inode"); + exit(-1); } height = inode->i_di.di_height; /* If this is a user inode, we don't follow to the file height. @@ -611,8 +611,12 @@ static void get_journal_inode_blocks(void) struct gfs_jindex ji; char jbuf[sizeof(struct gfs_jindex)]; - j_inode = gfs_inode_read(&sbd, + j_inode = lgfs2_gfs_inode_read(&sbd, sbd1->sb_jindex_di.no_addr); + if (j_inode == NULL) { + fprintf(stderr, "Error reading journal inode: %s\n", strerror(errno)); + return; + } amt = gfs2_readi(j_inode, (void *)&jbuf, journal * sizeof(struct gfs_jindex), sizeof(struct gfs_jindex)); diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index aa4f0b5..24de901 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -226,7 +226,7 @@ struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block) if (ip) return ip; if (sdp->gfs1) - return gfs_inode_read(sdp, block); + return lgfs2_gfs_inode_read(sdp, block); return lgfs2_inode_read(sdp, block); } @@ -242,7 +242,7 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp, return sysip; if (sdp->gfs1) - return gfs_inode_get(sdp, bh); + return lgfs2_gfs_inode_get(sdp, bh); return lgfs2_inode_get(sdp, bh); } diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index d6f8794..06fa98f 100644 --- a/gfs2/libgfs2/gfs1.c +++ b/gfs2/libgfs2/gfs1.c @@ -293,8 +293,7 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, ip = calloc(1, sizeof(struct gfs2_inode)); if (ip == NULL) { - fprintf(stderr, "Out of memory in %s\n", __FUNCTION__); - exit(-1); + return NULL; } ip->bh_owned = 0; @@ -332,13 +331,13 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, return ip; } -struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp, +struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh) { return __gfs_inode_get(sdp, bh, 0); } -struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr) +struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr) { return __gfs_inode_get(sdp, NULL, di_addr); } diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 9b128ff..74ee2d0 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -646,9 +646,9 @@ extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset, unsigned int size); extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet); -extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp, +extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh); -extern struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, +extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr); extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf); extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
1
0
0
0
gfs2-utils: master - libgfs2: Remove exit calls from inode_read and inode_get
by Andrew Price
28 Aug '12
28 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=9da423e592…
Commit: 9da423e59289bf8ce8bd4c78653fb678539c49b4 Parent: 150b51604f75c0de65cf3f837bc7b8ac30aa6d8b Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Sat Aug 25 00:04:50 2012 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Sat Aug 25 00:04:50 2012 +0100 libgfs2: Remove exit calls from inode_read and inode_get - Remove exit calls from inode_read and inode_get - Fix error handling for the functions up the call tree - The two functions are almost identical so define inode_read using inode_get - Update their names with an lgfs2_ prefix - Move block_is_in_per_node into savemeta.c and make it static Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/convert/gfs2_convert.c | 24 ++++++++++++--- gfs2/edit/extended.c | 24 +++++++++++---- gfs2/edit/hexedit.c | 47 +++++++++++------------------ gfs2/edit/hexedit.h | 1 - gfs2/edit/savemeta.c | 56 +++++++++++++++++++++++++++++++---- gfs2/fsck/fs_recovery.c | 4 ++- gfs2/fsck/initialize.c | 68 ++++++++++++++++++++++++++++++++----------- gfs2/fsck/metawalk.c | 4 +- gfs2/libgfs2/fs_ops.c | 34 ++++++++++++--------- gfs2/libgfs2/libgfs2.h | 4 +- gfs2/libgfs2/structures.c | 8 ++++- gfs2/mkfs/main_grow.c | 7 +++- 12 files changed, 192 insertions(+), 89 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 9944d23..51ec256 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -1092,7 +1092,9 @@ static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock, { struct gfs2_inode *fix_inode; - fix_inode = inode_read(sbp, iblock); + fix_inode = lgfs2_inode_read(sbp, iblock); + if (fix_inode == NULL) + return 1; inum->no_formal_ino = fix_inode->i_di.di_num.no_formal_ino; inum->no_addr = fix_inode->i_di.di_num.no_addr; if (eablk) @@ -1289,7 +1291,9 @@ static int process_directory(struct gfs2_sbd *sbp, uint64_t dirblock, uint64_t d struct gfs2_inode *dip; int error = 0; /* read in the directory inode */ - dip = inode_read(sbp, dirblock); + dip = lgfs2_inode_read(sbp, dirblock); + if (dip == NULL) + return -1; /* fix the directory: either exhash (leaves) or linear (stuffed) */ if (dip->i_di.di_flags & GFS2_DIF_EXHASH) { if (fix_one_directory_exhash(sbp, dip, dentmod)) { @@ -1391,7 +1395,9 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix) /* initialize the symlink inode to be a directory */ bh = init_dinode(sbp, &fix, S_IFDIR | 0755, 0, &dir); - fix_inode = inode_get(sbp, bh); + fix_inode = lgfs2_inode_get(sbp, bh); + if (fix_inode == NULL) + return -1; fix_inode->i_di.di_eattr = eablk; /*fix extended attribute */ inode_put(&fix_inode); bmodified(bh); @@ -1588,7 +1594,11 @@ static int init(struct gfs2_sbd *sbp) sbp->md.riinode = gfs_inode_read(sbp, inum.no_addr); /* get gfs1 jindex inode - gfs1's journal index inode ptr became master */ gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di); - sbp->md.jiinode = inode_read(sbp, inum.no_addr); + sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr); + if (sbp->md.jiinode == NULL) { + log_crit(_("Could not read journal index: %s\n"), strerror(errno)); + exit(-1); + } /* read in the journal index data */ read_gfs1_jiindex(sbp); /* read in the resource group index data: */ @@ -2056,7 +2066,11 @@ static void copy_quotas(struct gfs2_sbd *sdp) } gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di); - oq_ip = inode_read(sdp, inum.no_addr); + oq_ip = lgfs2_inode_read(sdp, inum.no_addr); + if (oq_ip == NULL) { + fprintf(stderr, _("Couldn't lookup old quota file: %s\n"), strerror(errno)); + exit(1); + } nq_ip->i_di.di_height = oq_ip->i_di.di_height; nq_ip->i_di.di_size = oq_ip->i_di.di_size; diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c index 566fb5b..e2567a5 100644 --- a/gfs2/edit/extended.c +++ b/gfs2/edit/extended.c @@ -654,7 +654,9 @@ int display_extended(void) /* Display any indirect pointers that we have. */ if (block_is_rindex()) { tmp_bh = bread(&sbd, block); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; parse_rindex(tmp_inode, TRUE); inode_put(&tmp_inode); brelse(tmp_bh); @@ -669,35 +671,45 @@ int display_extended(void) tmp_bh = bread(&sbd, sbd1->sb_rindex_di.no_addr); else tmp_bh = bread(&sbd, masterblock("rindex")); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; parse_rindex(tmp_inode, FALSE); inode_put(&tmp_inode); brelse(tmp_bh); } else if (block_is_jindex()) { tmp_bh = bread(&sbd, block); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; print_jindex(tmp_inode); inode_put(&tmp_inode); brelse(tmp_bh); } else if (block_is_inum_file()) { tmp_bh = bread(&sbd, block); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; print_inum(tmp_inode); inode_put(&tmp_inode); brelse(tmp_bh); } else if (block_is_statfs_file()) { tmp_bh = bread(&sbd, block); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; print_statfs(tmp_inode); inode_put(&tmp_inode); brelse(tmp_bh); } else if (block_is_quota_file()) { tmp_bh = bread(&sbd, block); - tmp_inode = inode_get(&sbd, tmp_bh); + tmp_inode = lgfs2_inode_get(&sbd, tmp_bh); + if (tmp_inode == NULL) + return -1; print_quota(tmp_inode); inode_put(&tmp_inode); brelse(tmp_bh); diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 2ff1125..79082b8 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1063,7 +1063,9 @@ static uint64_t get_rg_addr(int rgnum) gblock = sbd1->sb_rindex_di.no_addr; else gblock = masterblock("rindex"); - riinode = inode_read(&sbd, gblock); + riinode = lgfs2_inode_read(&sbd, gblock); + if (riinode == NULL) + return 0; if (rgnum < riinode->i_di.di_size / sizeof(struct gfs2_rindex)) rgblk = find_rgrp_block(riinode, rgnum); else @@ -1205,29 +1207,6 @@ int block_is_per_node(void) } /* ------------------------------------------------------------------------ */ -/* block_is_in_per_node */ -/* ------------------------------------------------------------------------ */ -int block_is_in_per_node(void) -{ - int d; - struct gfs2_inode *per_node_di; - - if (sbd.gfs1) - return FALSE; - - per_node_di = inode_read(&sbd, masterblock("per_node")); - - do_dinode_extended(&per_node_di->i_di, per_node_di->i_bh); - inode_put(&per_node_di); - - for (d = 0; d < indirect->ii[0].dirents; d++) { - if (block == indirect->ii[0].dirent[d].block) - return TRUE; - } - return FALSE; -} - -/* ------------------------------------------------------------------------ */ /* block_has_extended_info */ /* ------------------------------------------------------------------------ */ static int block_has_extended_info(void) @@ -1301,15 +1280,19 @@ static void read_superblock(int fd) sizeof(uint64_t); sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs_dinode)) / sizeof(uint64_t); - sbd.md.riinode = inode_read(&sbd, sbd1->sb_rindex_di.no_addr); + sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr); } else { sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs2_meta_header)) / sizeof(uint64_t); sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs2_dinode)) / sizeof(uint64_t); - sbd.master_dir = inode_read(&sbd, + sbd.master_dir = lgfs2_inode_read(&sbd, sbd.sd_sb.sb_master_dir.no_addr); - gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode); + if (sbd.master_dir == NULL) { + sbd.md.riinode = NULL; + } else { + gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode); + } } sbd.fssize = sbd.device.length; if (sbd.md.riinode) /* If we found the rindex */ @@ -1521,7 +1504,9 @@ static uint64_t find_journal_block(const char *journal, uint64_t *j_size) struct gfs2_inode *jiinode; struct gfs_jindex ji; - jiinode = inode_get(&sbd, jindex_bh); + jiinode = lgfs2_inode_get(&sbd, jindex_bh); + if (jiinode == NULL) + return 0; amtread = gfs2_readi(jiinode, (void *)&jbuf, journal_num * sizeof(struct gfs_jindex), sizeof(struct gfs_jindex)); @@ -2682,7 +2667,11 @@ static void dump_journal(const char *journal) return; if (!sbd.gfs1) { j_bh = bread(&sbd, jblock); - j_inode = inode_get(&sbd, j_bh); + j_inode = lgfs2_inode_get(&sbd, j_bh); + if (j_inode == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(-1); + } jbuf = malloc(sbd.bsize); if (jbuf == NULL) { fprintf(stderr, "Out of memory\n"); diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h index dd76810..706909c 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -217,7 +217,6 @@ extern int block_is_inum_file(void); extern int block_is_statfs_file(void); extern int block_is_quota_file(void); extern int block_is_per_node(void); -extern int block_is_in_per_node(void); extern int display_block_type(int from_restore); extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf); extern void gfs_log_header_in(struct gfs_log_header *head, diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 77cd7fa..77165a7 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -60,6 +60,30 @@ static int block_is_a_journal(void) return FALSE; } +static int block_is_in_per_node(void) +{ + int d; + struct gfs2_inode *per_node_di; + + if (sbd.gfs1) + return FALSE; + + per_node_di = lgfs2_inode_read(&sbd, masterblock("per_node")); + if (per_node_di == NULL) { + fprintf(stderr, "Failed to read per_node: %s\n", strerror(errno)); + exit(1); + } + + do_dinode_extended(&per_node_di->i_di, per_node_di->i_bh); + inode_put(&per_node_di); + + for (d = 0; d < indirect->ii[0].dirents; d++) { + if (block == indirect->ii[0].dirent[d].block) + return TRUE; + } + return FALSE; +} + static int block_is_systemfile(void) { return block_is_jindex() || block_is_inum_file() || @@ -122,10 +146,15 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type, *gstruct_len = sbd.bsize; break; case GFS2_METATYPE_DI: /* 4 (disk inode) */ - if (sbd.gfs1) + if (sbd.gfs1) { inode = gfs_inode_get(&sbd, lbh); - else - inode = inode_get(&sbd, lbh); + } else { + inode = lgfs2_inode_get(&sbd, lbh); + if (inode == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(-1); + } + } if (S_ISDIR(inode->i_di.di_mode) || (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)) *gstruct_len = sbd.bsize; @@ -461,8 +490,13 @@ static void save_inode_data(struct metafd *mfd) metabh = bread(&sbd, block); if (sbd.gfs1) inode = gfs_inode_get(&sbd, metabh); - else - inode = inode_get(&sbd, metabh); + else { + inode = lgfs2_inode_get(&sbd, metabh); + if (inode == NULL) { + fprintf(stderr, "Failed to read inode: %s\n", strerror(errno)); + exit(-1); + } + } height = inode->i_di.di_height; /* If this is a user inode, we don't follow to the file height. We stop one level less. That way we save off the indirect @@ -678,11 +712,19 @@ void savemeta(char *out_fn, int saveoption, int gziplevel) printf("There are %llu blocks of %u bytes in the destination " "device.\n", (unsigned long long)sbd.fssize, sbd.bsize); if (sbd.gfs1) { - sbd.md.riinode = inode_read(&sbd, sbd1->sb_rindex_di.no_addr); + sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr); + if (sbd.md.riinode == NULL) { + fprintf(stderr, "Unable to read rindex: %s.\n", strerror(errno)); + exit(-1); + } jindex_block = sbd1->sb_jindex_di.no_addr; } else { - sbd.master_dir = inode_read(&sbd, + sbd.master_dir = lgfs2_inode_read(&sbd, sbd.sd_sb.sb_master_dir.no_addr); + if (sbd.master_dir == NULL) { + fprintf(stderr, "Unable to read master: %s.\n", strerror(errno)); + exit(-1); + } gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode); jindex_block = masterblock("jindex"); diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 1d9f632..6c92d0e 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -667,7 +667,9 @@ int ji_update(struct gfs2_sbd *sdp) return -1; } gfs_jindex_in(&ji, buf); - sdp->md.journal[i] = inode_read(sdp, ji.ji_addr); + sdp->md.journal[i] = lgfs2_inode_read(sdp, ji.ji_addr); + if (sdp->md.journal[i] == NULL) + return -1; } else { /* FIXME check snprintf return code */ snprintf(journal_name, JOURNAL_NAME_SIZE, diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index e56161e..a1047f3 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -366,7 +366,11 @@ static int rebuild_master(struct gfs2_sbd *sdp) inum.no_formal_ino = sdp->md.next_inum++; inum.no_addr = sdp->sd_sb.sb_master_dir.no_addr; bh = init_dinode(sdp, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum); - sdp->master_dir = inode_get(sdp, bh); + sdp->master_dir = lgfs2_inode_get(sdp, bh); + if (sdp->master_dir == NULL) { + log_crit(_("Error reading master: %s\n"), strerror(errno)); + return -1; + } sdp->master_dir->bh_owned = 1; if (fix_md.jiinode) { @@ -610,7 +614,9 @@ static int init_system_inodes(struct gfs2_sbd *sdp) log_info( _("Initializing special inodes...\n")); /* Get root dinode */ - sdp->md.rooti = inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr); + sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr); + if (sdp->md.rooti == NULL) + return -1; err = fetch_rgrps(sdp); if (err) @@ -655,9 +661,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp) sdp->md.next_inum = be64_to_cpu(inumbuf); } - if (sdp->gfs1) - sdp->md.statfs = inode_read(sdp, sbd1->sb_license_di.no_addr); - else + if (sdp->gfs1) { + sdp->md.statfs = lgfs2_inode_read(sdp, sbd1->sb_license_di.no_addr); + if (sdp->md.statfs == NULL) { + log_crit(_("Error reading statfs inode: %s\n"), strerror(errno)); + goto fail; + } + } else gfs2_lookupi(sdp->master_dir, "statfs", 6, &sdp->md.statfs); if (!sdp->gfs1 && !sdp->md.statfs) { if (!query( _("The gfs2 system statfs inode is missing. " @@ -697,9 +707,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp) } } - if (sdp->gfs1) - sdp->md.qinode = inode_read(sdp, sbd1->sb_quota_di.no_addr); - else + if (sdp->gfs1) { + sdp->md.qinode = lgfs2_inode_read(sdp, sbd1->sb_quota_di.no_addr); + if (sdp->md.qinode == NULL) { + log_crit(_("Error reading quota inode: %s\n"), strerror(errno)); + goto fail; + } + } else gfs2_lookupi(sdp->master_dir, "quota", 5, &sdp->md.qinode); if (!sdp->gfs1 && !sdp->md.qinode) { if (!query( _("The gfs2 system quota inode is missing. " @@ -839,7 +853,11 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di, sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr; return; } - ip = inode_read(sdp, di->di_num.no_addr); + ip = lgfs2_inode_read(sdp, di->di_num.no_addr); + if (ip == NULL) { + log_crit(_("Error reading inode: %s\n"), strerror(errno)); + return; + } if ((!sdp->gfs1 && di->di_num.no_formal_ino == 3) || (sdp->gfs1 && (di->di_flags & GFS2_DIF_JDATA) && (di->di_size % sizeof(struct gfs_jindex) == 0))) { @@ -962,7 +980,11 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di, log_warn(_("Root directory copied from the journal.\n")); return; } - ip = inode_read(sdp, di->di_num.no_addr); + ip = lgfs2_inode_read(sdp, di->di_num.no_addr); + if (ip == NULL) { + log_crit(_("Error reading inode: %s\n"), strerror(errno)); + return; + } while (ip) { gfs2_lookupi(ip, "..", 2, &parent_ip); if (parent_ip && parent_ip->i_di.di_num.no_addr == @@ -1147,7 +1169,7 @@ static int sb_repair(struct gfs2_sbd *sdp) log_err(_("Found a possible root at: 0x%llx\n"), (unsigned long long)possible_root); sdp->sd_sb.sb_root_dir.no_addr = possible_root; - sdp->md.rooti = inode_read(sdp, possible_root); + sdp->md.rooti = lgfs2_inode_read(sdp, possible_root); if (!sdp->md.rooti || sdp->md.rooti->i_di.di_header.mh_magic != GFS2_MAGIC) { struct gfs2_buffer_head *bh; @@ -1174,14 +1196,22 @@ static int sb_repair(struct gfs2_sbd *sdp) if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) { log_info(_("Found system master directory at: 0x%llx\n"), sdp->sd_sb.sb_master_dir.no_addr); - sdp->master_dir = inode_read(sdp, + sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); + if (sdp->master_dir == NULL) { + log_crit(_("Error reading master inode: %s\n"), strerror(errno)); + return -1; + } sdp->master_dir->i_di.di_num.no_addr = sdp->sd_sb.sb_master_dir.no_addr; log_info(_("Found the root directory at: 0x%llx\n"), sdp->sd_sb.sb_root_dir.no_addr); - sdp->md.rooti = inode_read(sdp, + sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr); + if (sdp->md.rooti == NULL) { + log_crit(_("Error reading root inode: %s\n"), strerror(errno)); + return -1; + } get_random_bytes(uuid, sizeof(uuid)); build_sb(sdp, uuid); inode_put(&sdp->md.rooti); @@ -1345,7 +1375,7 @@ static int init_rindex(struct gfs2_sbd *sdp) int err; if (sdp->gfs1) - sdp->md.riinode = inode_read(sdp, sbd1->sb_rindex_di.no_addr); + sdp->md.riinode = lgfs2_inode_read(sdp, sbd1->sb_rindex_di.no_addr); else gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode); @@ -1376,7 +1406,7 @@ static int init_jindex(struct gfs2_sbd *sdp) /* rgrepair requires the journals be read in in order to distinguish "real" rgrps from rgrps that are just copies left in journals. */ if (sdp->gfs1) - sdp->md.jiinode = inode_read(sdp, sbd1->sb_jindex_di.no_addr); + sdp->md.jiinode = lgfs2_inode_read(sdp, sbd1->sb_jindex_di.no_addr); else gfs2_lookupi(sdp->master_dir, "jindex", 6, &sdp->md.jiinode); @@ -1488,7 +1518,7 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen, if (sdp->gfs1) sdp->master_dir = NULL; else - sdp->master_dir = inode_read(sdp, + sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); if (!sdp->gfs1 && (sdp->master_dir->i_di.di_header.mh_magic != GFS2_MAGIC || @@ -1496,8 +1526,12 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen, !sdp->master_dir->i_di.di_size)) { inode_put(&sdp->master_dir); rebuild_master(sdp); - sdp->master_dir = inode_read(sdp, + sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); + if (sdp->master_dir == NULL) { + log_crit(_("Error reading master directory: %s\n"), strerror(errno)); + return FSCK_ERROR; + } } /* Look up the "per_node" inode. If there are journals missing, we diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index acdd10f..aa4f0b5 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -227,7 +227,7 @@ struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block) return ip; if (sdp->gfs1) return gfs_inode_read(sdp, block); - return inode_read(sdp, block); + return lgfs2_inode_read(sdp, block); } /* fsck_inode_get - same as inode_get() in libgfs2 but system inodes @@ -243,7 +243,7 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp, if (sdp->gfs1) return gfs_inode_get(sdp, bh); - return inode_get(sdp, bh); + return lgfs2_inode_get(sdp, bh); } /* fsck_inode_put - same as inode_put() in libgfs2 but system inodes diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index 9409332..ec150e8 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -34,34 +34,32 @@ static int inode_is_stuffed(struct gfs2_inode *ip) return !ip->i_di.di_height; } -struct gfs2_inode *inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh) +struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh) { struct gfs2_inode *ip; ip = calloc(1, sizeof(struct gfs2_inode)); if (ip == NULL) { - fprintf(stderr, "Out of memory in %s\n", __FUNCTION__); - exit(-1); + return NULL; } gfs2_dinode_in(&ip->i_di, bh); ip->i_bh = bh; ip->i_sbd = sdp; - ip->bh_owned = 0; /* caller did the bread so we don't own the bh */ return ip; } -struct gfs2_inode *inode_read(struct gfs2_sbd *sdp, uint64_t di_addr) +struct gfs2_inode *lgfs2_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr) { struct gfs2_inode *ip; - - ip = calloc(1, sizeof(struct gfs2_inode)); + struct gfs2_buffer_head *bh = bread(sdp, di_addr); + if (bh == NULL) { + return NULL; + } + ip = lgfs2_inode_get(sdp, bh); if (ip == NULL) { - fprintf(stderr, "Out of memory in %s\n", __FUNCTION__); - exit(-1); + brelse(bh); + return NULL; } - ip->i_bh = bread(sdp, di_addr); - gfs2_dinode_in(&ip->i_di, ip->i_bh); - ip->i_sbd = sdp; ip->bh_owned = 1; /* We did the bread so we own the bh */ return ip; } @@ -1405,7 +1403,9 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip, bh = __init_dinode(sdp, &inum, mode, flags, &dip->i_di.di_num, if_gfs1); - ip = inode_get(sdp, bh); + ip = lgfs2_inode_get(sdp, bh); + if (ip == NULL) + return NULL; bmodified(bh); } ip->bh_owned = 1; @@ -1764,7 +1764,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len, return 0; } else - *ipp = inode_read(sdp, inum.no_addr); + *ipp = lgfs2_inode_read(sdp, inum.no_addr); return error; } @@ -1808,7 +1808,11 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock) osi_list_init(&metalist[h]); bh = bread(sdp, diblock); - ip = inode_get(sdp, bh); + if (bh == NULL) + return -1; + ip = lgfs2_inode_get(sdp, bh); + if (ip == NULL) + return -1; height = ip->i_di.di_height; osi_list_add(&bh->b_altlist, &metalist[0]); diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 09f0b1d..9b128ff 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -425,9 +425,9 @@ extern struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block); extern void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, unsigned int height, struct metapath *mp, int create, int *new, uint64_t *block); -extern struct gfs2_inode *inode_get(struct gfs2_sbd *sdp, +extern struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh); -extern struct gfs2_inode *inode_read(struct gfs2_sbd *sdp, uint64_t di_addr); +extern struct gfs2_inode *lgfs2_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr); extern struct gfs2_inode *is_system_inode(struct gfs2_sbd *sdp, uint64_t block); extern void inode_put(struct gfs2_inode **ip); diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c index 0c22b01..645c45a 100644 --- a/gfs2/libgfs2/structures.c +++ b/gfs2/libgfs2/structures.c @@ -26,7 +26,9 @@ int build_master(struct gfs2_sbd *sdp) bh = init_dinode(sdp, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum); - sdp->master_dir = inode_get(sdp, bh); + sdp->master_dir = lgfs2_inode_get(sdp, bh); + if (sdp->master_dir == NULL) + return -1; if (sdp->debug) { printf("\nMaster dir:\n"); @@ -429,7 +431,9 @@ int build_root(struct gfs2_sbd *sdp) inum.no_addr = bn; bh = init_dinode(sdp, &inum, S_IFDIR | 0755, 0, &inum); - sdp->md.rooti = inode_get(sdp, bh); + sdp->md.rooti = lgfs2_inode_get(sdp, bh); + if (sdp->md.rooti == NULL) + return -1; if (sdp->debug) { printf("\nRoot directory:\n"); diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index 3fe08a1..7bcfce2 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -376,8 +376,11 @@ main_grow(int argc, char *argv[]) die( _("GFS2 rindex not found. Please run gfs2_fsck.\n")); } /* Get master dinode */ - sdp->master_dir = - inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); + sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); + if (sdp->master_dir == NULL) { + perror("Could not read master"); + exit(EXIT_FAILURE); + } gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode); /* Fetch the rindex from disk. We aren't using gfs2 here, */ /* which means that the bitmaps will most likely be cached */
1
0
0
0
cluster: RHEL6 - ccs: Don't truncate lists
by Fabio M. Di Nitto
21 Aug '12
21 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=bb0daf4c52d18…
Commit: bb0daf4c52d18205b0c57448f7ee160d29fed90c Parent: 21548c1fde6ccfd160484b72bb75eb98b17f4835 Author: Christine Caulfield <ccaulfie(a)redhat.com> AuthorDate: Tue Aug 14 13:53:00 2012 +0100 Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com> CommitterDate: Tue Aug 21 08:46:25 2012 +0200 ccs: Don't truncate lists The last ccs patch caused ccs_get_list to return trunated items due to datalen not being filled in with the new cconfdb API. This fixes that. Also add a missing pointer NULL that could have resulted in corrupted memory Resolves: rhbz#847234 Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com> Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com> --- config/libs/libccsconfdb/xpathlite.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/config/libs/libccsconfdb/xpathlite.c b/config/libs/libccsconfdb/xpathlite.c index 75c33bc..0d770da 100644 --- a/config/libs/libccsconfdb/xpathlite.c +++ b/config/libs/libccsconfdb/xpathlite.c @@ -323,9 +323,12 @@ static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle, } value--; - if (value != 0) + if (value != 0) { free(keyval); + keyval = NULL; + } } + datalen = strlen(data); resval = malloc(datalen + keyvallen + 2); if (!resval) goto fail;
1
0
0
0
cluster: RHEL6 - Use new corosync confdb API to remove string limit.
by Fabio M. Di Nitto
21 Aug '12
21 Aug '12
Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=21548c1fde6cc…
Commit: 21548c1fde6ccfd160484b72bb75eb98b17f4835 Parent: f796ee8752712e9e523e1516bb9165b274552753 Author: Christine Caulfield <ccaulfie(a)redhat.com> AuthorDate: Tue Aug 14 09:13:06 2012 +0100 Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com> CommitterDate: Tue Aug 21 08:45:38 2012 +0200 Use new corosync confdb API to remove string limit. The original corosync confdb API had a 256 byte limit on all value strings returned. A new API was added that did not have this restriction, and this commit cases (mainly) libccs and others to use it so those benefits can be passed down to other cluster services. This means that cluster will now only compile against corosync libraries that have the *_typed2 API calls. Resolves: rhbz#847234 Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com> Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com> --- cman/cman_tool/main.c | 11 +++--- config/libs/libccsconfdb/fullxpath.c | 22 ++++++++---- config/libs/libccsconfdb/xpathlite.c | 59 ++++++++++++++++++++++------------ config/tools/ldap/confdb2ldif.c | 18 ++++++---- config/tools/xml/ccs_config_dump.c | 17 ++++++---- 5 files changed, 78 insertions(+), 49 deletions(-) diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c index c3d1863..958c35b 100644 --- a/cman/cman_tool/main.c +++ b/cman/cman_tool/main.c @@ -700,9 +700,9 @@ static int get_config_variables(commandline_t *comline, char **config_modules) int res; int got_iface = 1; char key_name[1024]; - size_t key_name_len; - char key_value[1024]; + char *key_value = NULL; size_t key_value_len; + confdb_value_types_t type; hdb_handle_t confdb_handle; hdb_handle_t cmanp_handle; confdb_callbacks_t callbacks = { @@ -728,9 +728,8 @@ static int get_config_variables(commandline_t *comline, char **config_modules) if (res != CS_OK) goto finish; - while ( (res = confdb_key_iter(confdb_handle, cmanp_handle, key_name, &key_name_len, - key_value, &key_value_len)) == CS_OK) { - key_name[key_name_len] = '\0'; + while ( (res = confdb_key_iter_typed2(confdb_handle, cmanp_handle, key_name, + (void**)&key_value, &key_value_len, &type)) == CS_OK) { key_value[key_value_len] = '\0'; setenv(key_name, key_value, 1); @@ -738,6 +737,8 @@ static int get_config_variables(commandline_t *comline, char **config_modules) *config_modules = strdup(key_value); got_iface = 0; } + free(key_value); + key_value = NULL; } finish: diff --git a/config/libs/libccsconfdb/fullxpath.c b/config/libs/libccsconfdb/fullxpath.c index 577c74a..86d4f59 100644 --- a/config/libs/libccsconfdb/fullxpath.c +++ b/config/libs/libccsconfdb/fullxpath.c @@ -52,8 +52,9 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han char temp[PATH_MAX]; char object_name[PATH_MAX]; char key_name[PATH_MAX]; - char key_value[PATH_MAX]; - size_t key_value_len = 0, key_name_len = 0, object_name_len = 0; + char *key_value = NULL; + size_t key_value_len = 0, object_name_len = 0; + confdb_value_types_t type; int res; res = confdb_key_iter_start(dump_handle, parent_object_handle); @@ -70,16 +71,17 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han } while ((res = - confdb_key_iter(dump_handle, parent_object_handle, key_name, - &key_name_len, key_value, - &key_value_len)) == CS_OK) { + confdb_key_iter_typed2(dump_handle, parent_object_handle, key_name, + (void **)&key_value, + &key_value_len, &type)) == CS_OK) { int char_pos = 0; - key_name[key_name_len] = '\0'; key_value[key_value_len] = '\0'; snprintf(temp, PATH_MAX - 1, " %s=\"", key_name); - if (add_to_buffer(temp, buffer, bufsize)) + if (add_to_buffer(temp, buffer, bufsize)) { + free(key_value); return -1; + } for (char_pos = 0; char_pos < key_value_len-1; char_pos++) { switch (key_value[char_pos]) { @@ -104,9 +106,13 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han temp[1] = '\0'; break; } - if (add_to_buffer(temp, buffer, bufsize)) + if (add_to_buffer(temp, buffer, bufsize)) { + free(key_value); return -1; + } } + free(key_value); + key_value = NULL; snprintf(temp, PATH_MAX - 1, "\""); if (add_to_buffer(temp, buffer, bufsize)) diff --git a/config/libs/libccsconfdb/xpathlite.c b/config/libs/libccsconfdb/xpathlite.c index 0a21f85..75c33bc 100644 --- a/config/libs/libccsconfdb/xpathlite.c +++ b/config/libs/libccsconfdb/xpathlite.c @@ -59,6 +59,7 @@ static int path_dive(confdb_handle_t handle, hdb_handle_t *query_handle, char *pos = NULL, *next = NULL; int i; hdb_handle_t new_obj_handle; + confdb_value_types_t type; pos = current_query + 1; @@ -88,6 +89,8 @@ static int path_dive(confdb_handle_t handle, hdb_handle_t *query_handle, */ char *start = NULL, *middle = NULL, *end = NULL; + char *key_value = NULL; + size_t valuelen; char data[PATH_MAX]; size_t datalen = 0; @@ -191,17 +194,22 @@ static int path_dive(confdb_handle_t handle, hdb_handle_t *query_handle, &new_obj_handle) != CS_OK) goto fail; else { - if (confdb_key_get + key_value = NULL; + if (confdb_key_get_typed2 (handle, new_obj_handle, - middle, strlen(middle), - data, - &datalen) == CS_OK) { + middle, + (void **) &key_value, + &valuelen, &type) == CS_OK) { if (!strcmp - (data, value)) + (key_value, value)) goout = 1; + free(key_value); + key_value = NULL; } } } + free(key_value); + key_value = NULL; confdb_object_find_destroy(handle, *query_handle); *query_handle = new_obj_handle; @@ -224,15 +232,14 @@ static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle, { int cmp; char data[PATH_MAX]; - char resval[PATH_MAX]; - char keyval[PATH_MAX]; + char *resval; + char *keyval; hdb_handle_t new_obj_handle; unsigned int value = 0; + confdb_value_types_t type; size_t datalen = 0, keyvallen = PATH_MAX; memset(data, 0, PATH_MAX); - memset(resval, 0, PATH_MAX); - memset(keyval, 0, PATH_MAX); // we need to handle child::*[int value] in non list mode. cmp = strcmp(curpos, "child::*"); @@ -283,8 +290,11 @@ static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle, value--; } - snprintf(resval, sizeof(resval), "%s=%s", data, keyval); - *rtn = strndup(resval, datalen + keyvallen + 2); + resval = malloc(datalen + keyvallen + 2); + if (!resval) + goto fail; + snprintf(resval, datalen + keyvallen + 2, "%s=%s", data, keyval); + *rtn = resval; } else if (!strncmp(curpos, "@*", strlen("@*"))) { @@ -304,18 +314,24 @@ static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle, while (value != 0) { memset(data, 0, PATH_MAX); - if (confdb_key_iter - (handle, query_handle, data, &datalen, keyval, - &keyvallen) != CS_OK) { + keyval = NULL; + if (confdb_key_iter_typed2 + (handle, query_handle, data, (void **)&keyval, + &keyvallen, &type) != CS_OK) { reset_iterator(handle, connection_handle); goto fail; } value--; + if (value != 0) + free(keyval); } - - snprintf(resval, sizeof(resval), "%s=%s", data, keyval); - *rtn = strndup(resval, datalen + keyvallen + 2); + resval = malloc(datalen + keyvallen + 2); + if (!resval) + goto fail; + snprintf(resval, datalen + keyvallen + 2, "%s=%s", data, keyval); + *rtn = resval; + free(keyval); } else { /* pure data request */ char *query; @@ -333,12 +349,13 @@ static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle, query = query + 1; - if (confdb_key_get - (handle, query_handle, query, strlen(query), data, - &datalen) != CS_OK) + keyval = NULL; + if (confdb_key_get_typed2 + (handle, query_handle, query, (void **)&keyval, + &keyvallen, &type) != CS_OK) goto fail; - *rtn = strndup(data, datalen); + *rtn = keyval; } return 0; diff --git a/config/tools/ldap/confdb2ldif.c b/config/tools/ldap/confdb2ldif.c index 35f8c31..6891f27 100644 --- a/config/tools/ldap/confdb2ldif.c +++ b/config/tools/ldap/confdb2ldif.c @@ -41,8 +41,8 @@ static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object char object_name[1024]; size_t object_name_len; char key_name[1024]; - size_t key_name_len; - char key_value[1024]; + char *key_value=NULL; + confdb_value_types_t type; size_t key_value_len; char cumulative_dn[4096]; int res; @@ -57,13 +57,14 @@ static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object return; } - while ( (res = confdb_key_iter(handle, parent_object_handle, key_name, &key_name_len, - key_value, &key_value_len)) == CS_OK) { - key_name[key_name_len] = '\0'; + while ( (res = confdb_key_iter_typed2(handle, parent_object_handle, key_name, + (void**)&key_value, &key_value_len, &type)) == CS_OK) { key_value[key_value_len] = '\0'; printf("%s: %s\n", ldap_attr_name(key_name), key_value); keycount++; + free(key_value); + key_value=NULL; } if (strncmp(fulldn, "cn=", 3) == 0) { printf("cn: %s\n", dn); @@ -97,15 +98,16 @@ static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object object_name[object_name_len] = '\0'; /* Check for "name", and create dummy parent object */ - res = confdb_key_get(handle, object_handle, "name", strlen("name"), key_value, &key_value_len); + res = confdb_key_get_typed2(handle, object_handle, "name", (void **)&key_value, &key_value_len, &type); if (res == CS_OK) { sprintf(cumulative_dn, "cn=%s,%s", object_name, fulldn); printf("\n"); printf("dn: %s\n", cumulative_dn); printf("cn: %s\n", object_name); printf("objectclass: %s\n", "nsContainer"); - - sprintf(cumulative_dn, "name=%s,cn=%s,%s", key_value, object_name, fulldn); + snprintf(cumulative_dn, sizeof(cumulative_dn) - 1, "name=%s,cn=%s,%s", key_value, object_name, fulldn); + free(key_value); + key_value = NULL; } else { sprintf(cumulative_dn, "cn=%s,%s", object_name, fulldn); diff --git a/config/tools/xml/ccs_config_dump.c b/config/tools/xml/ccs_config_dump.c index 74c33c2..1264aa3 100644 --- a/config/tools/xml/ccs_config_dump.c +++ b/config/tools/xml/ccs_config_dump.c @@ -14,20 +14,21 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han hdb_handle_t parent_object_handle, int level) { hdb_handle_t object_handle; - char object_name[PATH_MAX], key_name[PATH_MAX], key_value[PATH_MAX]; - size_t key_value_len = 0, key_name_len = 0, object_name_len = 0; + char object_name[PATH_MAX], key_name[PATH_MAX]; + char *key_value=NULL; + size_t key_value_len = 0, object_name_len = 0; int current_level = level+1; int has_children = 0; + confdb_value_types_t type; if (confdb_key_iter_start(dump_handle, parent_object_handle) != CS_OK) return -1; - while (confdb_key_iter(dump_handle, parent_object_handle, key_name, - &key_name_len, key_value, - &key_value_len) == CS_OK) { + while (confdb_key_iter_typed2(dump_handle, parent_object_handle, key_name, + (void**)&key_value, + &key_value_len, &type) == CS_OK) { int char_pos = 0; - key_name[key_name_len] = '\0'; key_value[key_value_len] = '\0'; printf(" %s=\"", key_name); for (char_pos = 0; char_pos < key_value_len-1; char_pos++) { @@ -54,6 +55,8 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han } } printf("\""); + free(key_value); + key_value = NULL; } if (confdb_object_iter_start(dump_handle, parent_object_handle) != CS_OK) @@ -61,7 +64,7 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han while (confdb_object_iter(dump_handle, parent_object_handle, &object_handle, object_name, - &object_name_len) == CS_OK) { + &object_name_len) == CS_OK) { hdb_handle_t parent; int i; int found_children;
1
0
0
0
← Newer
1
2
3
4
5
6
Older →
Jump to page:
1
2
3
4
5
6
Results per page:
10
25
50
100
200