gfs2-utils: Don't require an external print_it() in libgfs2
cover gfs2-utils: Don't require an external print_it() in libgfs2
This patch set fixes a long-standing issue in libgfs2 where it requires apps linking to it to provide a print_it function, which it uses in lgfs2_(struct)_print() functions defined in libgfs2/ondisk.c. This was the main blocker to it becoming a library in a more meaningful sense.
The approach taken is to remove the responsibility of printing gfs2 structures from libgfs2 altogether. So the first challenge is to remove debugging output from libgfs2 and push it down into the utils, which in turn required returning more context from some libgfs2 functions, mainly the build_* functions in structures.c.
The overall result is more flexibility and control over the way the utils print on-disk structures and improved error/debug messages. Test code is also tidied up as we no longer have to define a print_it() in each of the tests.
Andrew Price (18):
libgfs2: Move debugging printf out of build_master()
libgfs2: Rework lgfs2_build_jindex()
libgfs2: Move build_jindex() into fsck.gfs2
libgfs2: Push down build_per_node() into the utils
libgfs2: Return the inode from build_inum_range()
libgfs2: Return the inode from build_statfs_change()
libgfs2: Return the inode from build_quota_change()
libgfs2: Return the inode from build_inum()
libgfs2: Return the inode from build_statfs()
libgfs2: Return the inode from build_rindex()
libgfs2: Return the inode from build_quota()
libgfs2: Move debugging printf out of build_root()
libgfs2: Remove debugging printf from do_init_statfs()
libgfs2: Move debugging output out of do_init_inum()
libgfs2: Remove debugging printfs from fix_device_geometry()
libgfs2: Remove config.[ch]
libgfs2: Move struct printing functions out of libgfs2
libgfs2: Remove print_it extern requirement
gfs2/convert/gfs2_convert.c | 80 +++++--- gfs2/edit/Makefile.am | 2 + gfs2/edit/extended.c | 18 +- gfs2/edit/gfs2hex.c | 156 +------------- gfs2/edit/hexedit.c | 36 +--- gfs2/edit/hexedit.h | 4 +- gfs2/edit/struct_print.c | 364 +++++++++++++++++++++++++++++++++ gfs2/edit/struct_print.h | 23 +++ gfs2/fsck/fs_recovery.c | 21 ++ gfs2/fsck/fs_recovery.h | 1 + gfs2/fsck/fsck.h | 1 + gfs2/fsck/initialize.c | 75 +++---- gfs2/fsck/main.c | 13 +- gfs2/fsck/pass1.c | 86 +++++++- gfs2/fsck/pass2.c | 37 +++- gfs2/glocktop/glocktop.c | 3 +- gfs2/libgfs2/Makefile.am | 2 - gfs2/libgfs2/check_libgfs2.c | 3 - gfs2/libgfs2/checks.am | 1 - gfs2/libgfs2/config.c | 9 - gfs2/libgfs2/config.h | 6 - gfs2/libgfs2/device_geometry.c | 7 - gfs2/libgfs2/gfs2l.c | 3 - gfs2/libgfs2/libgfs2.h | 40 +--- gfs2/libgfs2/ondisk.c | 199 ------------------ gfs2/libgfs2/structures.c | 226 ++++---------------- gfs2/mkfs/Makefile.am | 2 + gfs2/mkfs/gfs2_mkfs.h | 11 - gfs2/mkfs/main_jadd.c | 1 - gfs2/mkfs/main_mkfs.c | 152 +++++++++++--- gfs2/mkfs/struct_print.c | 218 ++++++++++++++++++++ gfs2/mkfs/struct_print.h | 19 ++ tests/nukerg.c | 3 - 33 files changed, 1067 insertions(+), 755 deletions(-) create mode 100644 gfs2/edit/struct_print.c create mode 100644 gfs2/edit/struct_print.h delete mode 100644 gfs2/libgfs2/config.c delete mode 100644 gfs2/libgfs2/config.h create mode 100644 gfs2/mkfs/struct_print.c create mode 100644 gfs2/mkfs/struct_print.h
Signature · 1 line
2.34.1
PATCH 1/18 libgfs2: Move debugging printf out of build_master()
mkfs.gfs2 is the only place it could ever get printed so move it there instead.
--- gfs2/libgfs2/structures.c | 4 ---- gfs2/mkfs/main_mkfs.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
gfs2/libgfs2/structures.c +0 -4
@@ -38,10 +38,6 @@ int build_master(struct gfs2_sbd *sdp)if (sdp->master_dir ==NULL )return -1 ; -if (cfg_debug) { -printf ("\nMaster dir:\n" ); -lgfs2_dinode_print (bh->b_data); - } sdp->master_dir->bh_owned =1 ;return 0 ; }
gfs2/mkfs/main_mkfs.c +4 -0
@@ -1205,6 +1205,10 @@ int main(int argc, char *argv[])fprintf (stderr,_ ("Error building '%s': %s\n" ),"master" ,strerror (errno));exit (EXIT_FAILURE ); } +if (opts.debug) { +printf ("Metafs inode:\n" ); +lgfs2_dinode_print (sbd.master_dir->i_bh->b_data); + } sbd.sd_meta_dir = sbd.master_dir->i_num; error =lgfs2_build_jindex (sbd.master_dir, mkfs_journals, opts.journals);
Signature · 1 line
2.34.1
PATCH 2/18 libgfs2: Rework lgfs2_build_jindex()
In reply to Andrew PriceReturn the inode instead of freeing it and move the debug printfs out of libgfs2.
--- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 23 ++++++++--------------- gfs2/mkfs/main_mkfs.c | 27 ++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 21 deletions(-)
gfs2/libgfs2/libgfs2.h +1 -1
@@ -777,7 +777,7 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);extern int build_journal (struct gfs2_sbd *sdp,int j,struct gfs2_inode *jindex);extern int build_jindex (struct gfs2_sbd *sdp); -extern int lgfs2_build_jindex (struct gfs2_inode *master,struct lgfs2_inum *jnls,size_t nmemb); +extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb);extern int build_per_node (struct gfs2_sbd *sdp);extern int build_inum (struct gfs2_sbd *sdp);extern int build_statfs (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +8 -15
@@ -251,39 +251,32 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)* nmemb: The number of entries in the list (number of journals). * Returns 0 on success or non-zero on error with errno set. */ -int lgfs2_build_jindex (struct gfs2_inode *master,struct lgfs2_inum *jnls,size_t nmemb) +struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *master,struct lgfs2_inum *jnls,size_t nmemb) {char fname[GFS2_FNAMESIZE +1 ];struct gfs2_inode *jindex; -unsigned j; -int ret;if (nmemb ==0 || jnls ==NULL ) { errno =EINVAL ; -return 1 ; +return NULL ; } jindex =createi (master,"jindex" ,S_IFDIR |0700 ,GFS2_DIF_SYSTEM );if (jindex ==NULL ) -return 1 ; +return NULL ; fname[GFS2_FNAMESIZE ] ='\0' ; -for (j =0 ; j < nmemb; j++) { +for (unsigned j =0 ; j < nmemb; j++) { +int ret; +snprintf (fname,GFS2_FNAMESIZE ,"journal%u" , j); ret =dir_add (jindex, fname,strlen (fname), &jnls[j],IF2DT (S_IFREG |0600 ));if (ret) {inode_put (&jindex); -return 1 ; +return NULL ; } } - -if (cfg_debug) { -printf ("\nJindex:\n" ); -lgfs2_dinode_print (jindex->i_bh->b_data); - } - -inode_put (&jindex); -return 0 ; +return jindex; }int build_jindex (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +22 -5
@@ -941,6 +941,24 @@ static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, uint64_t *rgaddrreturn 0 ; } +static int create_jindex (struct gfs2_sbd *sdp,struct mkfs_opts *opts,struct lgfs2_inum *jnls) +{ +struct gfs2_inode *jindex; + + jindex =lgfs2_build_jindex (sdp->master_dir, jnls, opts->journals); +if (jindex ==NULL ) { +fprintf (stderr,_ ("Error building '%s': %s\n" ),"jindex" ,strerror (errno)); +return 1 ; + } +if (opts->debug) { +printf ("Jindex:\n" ); +lgfs2_dinode_print (jindex->i_bh->b_data); + } +inode_put (&jindex); +return 0 ; +} + +/* * Find a reasonable journal file size (in blocks) given the number of blocks * in the filesystem. For very small filesystems, it is not reasonable to
@@ -1211,12 +1229,11 @@ int main(int argc, char *argv[]) } sbd.sd_meta_dir = sbd.master_dir->i_num; - error =lgfs2_build_jindex (sbd.master_dir, mkfs_journals, opts.journals); -if (error) { -fprintf (stderr,_ ("Error building '%s': %s\n" ),"jindex" ,strerror (errno)); -exit (EXIT_FAILURE ); - } + error =create_jindex (&sbd, &opts, mkfs_journals);free (mkfs_journals); +if (error !=0 ) +exit (1 ); + error =build_per_node (&sbd);if (error) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"per_node" ,strerror (errno));
Signature · 1 line
2.34.1
PATCH 3/18 libgfs2: Move build_jindex() into fsck.gfs2
In reply to Andrew Pricefsck.gfs2 is the only remaining util that builds journals this way so move it out of libgfs2. The debug printfs can be removed because fsck.gfs2 doesn't enable libgfs2's cfg_debug.
--- gfs2/fsck/fs_recovery.c | 21 +++++++++++++++++++++ gfs2/fsck/fs_recovery.h | 1 + gfs2/fsck/pass2.c | 1 + gfs2/libgfs2/libgfs2.h | 1 - gfs2/libgfs2/structures.c | 29 ----------------------------- 5 files changed, 23 insertions(+), 30 deletions(-)
gfs2/fsck/fs_recovery.c +21 -0
@@ -848,6 +848,27 @@ static struct metawalk_fxns jindex_check_fxns = { .check_dentry = check_jindex_dent, }; +int build_jindex (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *jindex; + + jindex =createi (sdp->master_dir,"jindex" ,S_IFDIR |0700 , +GFS2_DIF_SYSTEM ); +if (jindex ==NULL ) { +return errno; + } + sdp->md.journal =malloc (sdp->md.journals *sizeof (struct gfs2_inode *)); +for (unsigned j =0 ; j < sdp->md.journals; j++) { +int ret =build_journal (sdp, j, jindex); +if (ret) +return ret; +inode_put (&sdp->md.journal[j]); + } +free (sdp->md.journal); +inode_put (&jindex); +return 0 ; +} +/** * init_jindex - read in the rindex file */
gfs2/fsck/fs_recovery.h +1 -0
@@ -8,6 +8,7 @@ extern int replay_journals(struct gfs2_sbd *sdp, int preen, int force_check,extern int preen_is_safe (struct gfs2_sbd *sdp,int preen,int force_check);extern int ji_update (struct gfs2_sbd *sdp); +extern int build_jindex (struct gfs2_sbd *sdp);extern int init_jindex (struct gfs2_sbd *sdp,int allow_ji_rebuild);#endif /* __FS_RECOVERY_H__ */
gfs2/fsck/pass2.c +1 -0
@@ -18,6 +18,7 @@#include "lost_n_found.h" #include "inode_hash.h" #include "afterpass1_common.h" +#include "fs_recovery.h" #define MAX_FILENAME 256
gfs2/libgfs2/libgfs2.h +0 -1
@@ -776,7 +776,6 @@ extern int build_master(struct gfs2_sbd *sdp);extern int lgfs2_sb_write (const struct gfs2_sbd *sdp,int fd);extern int build_journal (struct gfs2_sbd *sdp,int j,struct gfs2_inode *jindex); -extern int build_jindex (struct gfs2_sbd *sdp);extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb);extern int build_per_node (struct gfs2_sbd *sdp);extern int build_inum (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +0 -29
@@ -279,35 +279,6 @@ struct gfs2_inode *lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inreturn jindex; } -int build_jindex (struct gfs2_sbd *sdp) -{ -struct gfs2_inode *jindex; -unsigned int j; -int ret; - - jindex =createi (sdp->master_dir,"jindex" ,S_IFDIR |0700 , -GFS2_DIF_SYSTEM ); -if (jindex ==NULL ) { -return errno; - } - sdp->md.journal =malloc (sdp->md.journals * -sizeof (struct gfs2_inode *)); -for (j =0 ; j < sdp->md.journals; j++) { - ret =build_journal (sdp, j, jindex); -if (ret) -return ret; -inode_put (&sdp->md.journal[j]); - } -if (cfg_debug) { -printf ("\nJindex:\n" ); -lgfs2_dinode_print (jindex->i_bh->b_data); - } - -free (sdp->md.journal); -inode_put (&jindex); -return 0 ; -} -int build_inum_range (struct gfs2_inode *per_node,unsigned int j) {char name[256 ];
Signature · 1 line
2.34.1
PATCH 4/18 libgfs2: Push down build_per_node() into the utils
In reply to Andrew PriceThe trouble with having this function in libgfs2 is that it creates per_node and everything inside it, which means that it's difficult to know where an error occurred and we don't have any control over how debug/error messages are printed. It's also not necessarily the order that we want to create the inodes in all utilities. Move build_per_node() down into the utils and add error reporting to match.
--- gfs2/convert/gfs2_convert.c | 36 +++++++++++++++++++++++++++ gfs2/fsck/fsck.h | 1 + gfs2/fsck/pass1.c | 36 +++++++++++++++++++++++++++ gfs2/libgfs2/libgfs2.h | 1 - gfs2/libgfs2/structures.c | 36 --------------------------- gfs2/mkfs/main_mkfs.c | 49 +++++++++++++++++++++++++++++++++---- 6 files changed, 117 insertions(+), 42 deletions(-)
gfs2/convert/gfs2_convert.c +36 -0
@@ -2099,6 +2099,42 @@ static int check_fit(struct gfs2_sbd *sdp)return blks_avail > blks_need; } +static int build_per_node (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *per_node; +unsigned int j; +int err; + + per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 , +GFS2_DIF_SYSTEM ); +if (per_node ==NULL ) { +log_crit (_ ("Error building '%s': %s\n" ),"per_node" ,strerror (errno)); +return -1 ; + } +for (j =0 ; j < sdp->md.journals; j++) { + err =build_inum_range (per_node, j); +if (err) { +log_crit (_ ("Error building '%s': %s\n" ),"inum_range" , +strerror (errno)); +return err; + } + err =build_statfs_change (per_node, j); +if (err) { +log_crit (_ ("Error building '%s': %s\n" ),"statfs_change" , +strerror (errno)); +return err; + } + err =build_quota_change (per_node, j); +if (err) { +log_crit (_ ("Error building '%s': %s\n" ),"quota_change" , +strerror (errno)); +return err; + } + } +inode_put (&per_node); +return 0 ; +} +/* We fetch the old quota inode block and copy the contents of the block * (minus the struct gfs2_dinode) into the new quota block. We update the * inode height/size of the new quota file to that of the old one and set the
gfs2/fsck/fsck.h +1 -0
@@ -200,5 +200,6 @@ extern struct special_blocks *blockfind(struct special_blocks *blist, uint64_t nextern void gfs2_special_set (struct special_blocks *blocklist,uint64_t block);extern void gfs2_special_free (struct special_blocks *blist);extern int sb_fixed; +extern int build_per_node (struct gfs2_sbd *sdp);#endif /* _FSCK_H */
gfs2/fsck/pass1.c +36 -0
@@ -1577,6 +1577,42 @@ static int build_a_journal(struct gfs2_sbd *sdp)return 0 ; } +int build_per_node (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *per_node; +unsigned int j; +int err; + + per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 , +GFS2_DIF_SYSTEM ); +if (per_node ==NULL ) { +log_err (_ ("Error building '%s': %s\n" ),"per_node" ,strerror (errno)); +return -1 ; + } +for (j =0 ; j < sdp->md.journals; j++) { + err =build_inum_range (per_node, j); +if (err) { +log_err (_ ("Error building '%s': %s\n" ),"inum_range" , +strerror (errno)); +return err; + } + err =build_statfs_change (per_node, j); +if (err) { +log_err (_ ("Error building '%s': %s\n" ),"statfs_change" , +strerror (errno)); +return err; + } + err =build_quota_change (per_node, j); +if (err) { +log_err (_ ("Error building '%s': %s\n" ),"quota_change" , +strerror (errno)); +return err; + } + } +inode_put (&per_node); +return 0 ; +} +static int check_system_inodes (struct gfs2_sbd *sdp) {int journal_count;
gfs2/libgfs2/libgfs2.h +0 -1
@@ -777,7 +777,6 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);extern int build_journal (struct gfs2_sbd *sdp,int j,struct gfs2_inode *jindex);extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb); -extern int build_per_node (struct gfs2_sbd *sdp);extern int build_inum (struct gfs2_sbd *sdp);extern int build_statfs (struct gfs2_sbd *sdp);extern int build_rindex (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +0 -36
@@ -370,42 +370,6 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)return 0 ; } -int build_per_node (struct gfs2_sbd *sdp) -{ -struct gfs2_inode *per_node; -unsigned int j; -int err; - - per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 , -GFS2_DIF_SYSTEM ); -if (per_node ==NULL ) { -return errno; - } - -for (j =0 ; j < sdp->md.journals; j++) { - err =build_inum_range (per_node, j); -if (err) { -return err; - } - err =build_statfs_change (per_node, j); -if (err) { -return err; - } - err =build_quota_change (per_node, j); -if (err) { -return err; - } - } - -if (cfg_debug) { -printf ("\nper_node:\n" ); -lgfs2_dinode_print (per_node->i_bh->b_data); - } - -inode_put (&per_node); -return 0 ; -} -int build_inum (struct gfs2_sbd *sdp) {struct gfs2_inode *ip;
gfs2/mkfs/main_mkfs.c +44 -5
61 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 5/18 libgfs2: Return the inode from build_inum_range()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 10 +++++++--- gfs2/fsck/pass1.c | 10 +++++++--- gfs2/fsck/pass2.c | 12 +++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 16 +++++----------- gfs2/mkfs/main_mkfs.c | 14 +++++++++++--- 6 files changed, 42 insertions(+), 22 deletions(-)
gfs2/convert/gfs2_convert.c +7 -3
@@ -2112,12 +2112,16 @@ static int build_per_node(struct gfs2_sbd *sdp)return -1 ; }for (j =0 ; j < sdp->md.journals; j++) { - err =build_inum_range (per_node, j); -if (err) { +struct gfs2_inode *ip; + + ip =build_inum_range (per_node, j); +if (ip ==NULL ) {log_crit (_ ("Error building '%s': %s\n" ),"inum_range" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); + err =build_statfs_change (per_node, j);if (err) { log_crit(_("Error building '%s': %s\n"), "statfs_change",
gfs2/fsck/pass1.c +7 -3
@@ -1590,12 +1590,16 @@ int build_per_node(struct gfs2_sbd *sdp)return -1 ; }for (j =0 ; j < sdp->md.journals; j++) { - err =build_inum_range (per_node, j); -if (err) { +struct gfs2_inode *ip; + + ip =build_inum_range (per_node, j); +if (ip ==NULL ) {log_err (_ ("Error building '%s': %s\n" ),"inum_range" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); + err =build_statfs_change (per_node, j);if (err) { log_err(_("Error building '%s': %s\n"), "statfs_change",
gfs2/fsck/pass2.c +11 -1
@@ -1875,6 +1875,16 @@ build_it: goto out_good; } +static int fsck_build_inum_range (struct gfs2_inode *per_node,unsigned int n) +{ +struct gfs2_inode *ip =build_inum_range (per_node, n); + +if (ip ==NULL ) +return 1 ; +inode_put (&ip); +return 0 ; +} +/* Check system directory inode */ /* Should work for all system directories: root, master, jindex, per_node */ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1959,7 +1969,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,for (j =0 ; j < sysinode->i_sbd->md.journals; j++) {sprintf (fn,"inum_range%d" , j); error +=check_pernode_for (j, sysinode, fn,16 ,0 , -NULL , build_inum_range); +NULL , fsck_build_inum_range);sprintf (fn,"statfs_change%d" , j); error +=check_pernode_for (j, sysinode, fn,24 ,0 ,NULL , build_statfs_change);
gfs2/libgfs2/libgfs2.h +1 -1
@@ -787,7 +787,7 @@ extern int do_init_statfs(struct gfs2_sbd *sdp);extern int gfs2_check_meta (const char *buf,int type);extern unsigned lgfs2_bm_scan (struct rgrp_tree *rgd,unsigned idx,uint64_t *buf,uint8_t state); -extern int build_inum_range (struct gfs2_inode *per_node,unsigned int j); +extern struct gfs2_inode *build_inum_range (struct gfs2_inode *per_node,unsigned int n);extern int build_statfs_change (struct gfs2_inode *per_node,unsigned int j);extern int build_quota_change (struct gfs2_inode *per_node,unsigned int j);
gfs2/libgfs2/structures.c +5 -11
@@ -279,7 +279,7 @@ struct gfs2_inode *lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inreturn jindex; } -int build_inum_range (struct gfs2_inode *per_node,unsigned int j) +struct gfs2_inode *build_inum_range (struct gfs2_inode *per_node,unsigned int j) {char name[256 ];struct gfs2_inode *ip;
@@ -287,19 +287,13 @@ int build_inum_range(struct gfs2_inode *per_node, unsigned int j)sprintf (name,"inum_range%u" , j); ip =createi (per_node, name,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } +if (ip ==NULL ) +return NULL ; + ip->i_size =sizeof (struct gfs2_inum_range );lgfs2_dinode_out (ip, ip->i_bh->b_data);bmodified (ip->i_bh); -if (cfg_debug) { -printf ("\nInum Range %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); - } - -inode_put (&ip); -return 0 ; +return ip; }int build_statfs_change (struct gfs2_inode *per_node,unsigned int j)
gfs2/mkfs/main_mkfs.c +11 -3
@@ -694,12 +694,20 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts)return -1 ; }for (j =0 ; j < sdp->md.journals; j++) { - err =build_inum_range (per_node, j); -if (err) { +struct gfs2_inode *ip; + + ip =build_inum_range (per_node, j); +if (ip ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"inum_range" ,strerror (errno)); -return err; +return 1 ; + } +if (opts->debug) { +printf ("\nInum Range %u:\n" , j); +lgfs2_dinode_print (ip->i_bh->b_data); } +inode_put (&ip); + err =build_statfs_change (per_node, j);if (err) { fprintf(stderr, _("Error building '%s': %s\n"), "statfs_change",
Signature · 1 line
2.34.1
PATCH 6/18 libgfs2: Return the inode from build_statfs_change()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 8 +++++--- gfs2/fsck/pass1.c | 8 +++++--- gfs2/fsck/pass2.c | 12 +++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 16 +++++----------- gfs2/mkfs/main_mkfs.c | 12 +++++++++--- 6 files changed, 36 insertions(+), 22 deletions(-)
gfs2/convert/gfs2_convert.c +5 -3
@@ -2122,12 +2122,14 @@ static int build_per_node(struct gfs2_sbd *sdp) }inode_put (&ip); - err =build_statfs_change (per_node, j); -if (err) { + ip =build_statfs_change (per_node, j); +if (ip ==NULL ) {log_crit (_ ("Error building '%s': %s\n" ),"statfs_change" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); + err =build_quota_change (per_node, j);if (err) { log_crit(_("Error building '%s': %s\n"), "quota_change",
gfs2/fsck/pass1.c +5 -3
@@ -1600,12 +1600,14 @@ int build_per_node(struct gfs2_sbd *sdp) }inode_put (&ip); - err =build_statfs_change (per_node, j); -if (err) { + ip =build_statfs_change (per_node, j); +if (ip ==NULL ) {log_err (_ ("Error building '%s': %s\n" ),"statfs_change" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); + err =build_quota_change (per_node, j);if (err) { log_err(_("Error building '%s': %s\n"), "quota_change",
gfs2/fsck/pass2.c +11 -1
@@ -1885,6 +1885,16 @@ static int fsck_build_inum_range(struct gfs2_inode *per_node, unsigned int n)return 0 ; } +static int fsck_build_statfs_change (struct gfs2_inode *per_node,unsigned int n) +{ +struct gfs2_inode *ip =build_statfs_change (per_node, n); + +if (ip ==NULL ) +return 1 ; +inode_put (&ip); +return 0 ; +} +/* Check system directory inode */ /* Should work for all system directories: root, master, jindex, per_node */ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1972,7 +1982,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname, NULL, fsck_build_inum_range);sprintf (fn,"statfs_change%d" , j); error +=check_pernode_for (j, sysinode, fn,24 ,0 , -NULL , build_statfs_change); +NULL , fsck_build_statfs_change);sprintf (fn,"quota_change%d" , j); error += check_pernode_for(j, sysinode, fn, 1048576, 1, "a_change_fxns,
gfs2/libgfs2/libgfs2.h +1 -1
@@ -788,7 +788,7 @@ extern int gfs2_check_meta(const char *buf, int type);extern unsigned lgfs2_bm_scan (struct rgrp_tree *rgd,unsigned idx,uint64_t *buf,uint8_t state);extern struct gfs2_inode *build_inum_range (struct gfs2_inode *per_node,unsigned int n); -extern int build_statfs_change (struct gfs2_inode *per_node,unsigned int j); +extern struct gfs2_inode *build_statfs_change (struct gfs2_inode *per_node,unsigned int j);extern int build_quota_change (struct gfs2_inode *per_node,unsigned int j);/* super.c */
gfs2/libgfs2/structures.c +5 -11
@@ -296,7 +296,7 @@ struct gfs2_inode *build_inum_range(struct gfs2_inode *per_node, unsigned int j)return ip; } -int build_statfs_change (struct gfs2_inode *per_node,unsigned int j) +struct gfs2_inode *build_statfs_change (struct gfs2_inode *per_node,unsigned int j) {char name[256 ];struct gfs2_inode *ip;
@@ -304,19 +304,13 @@ int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)sprintf (name,"statfs_change%u" , j); ip =createi (per_node, name,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } +if (ip ==NULL ) +return NULL ; + ip->i_size =sizeof (struct gfs2_statfs_change );lgfs2_dinode_out (ip, ip->i_bh->b_data);bmodified (ip->i_bh); -if (cfg_debug) { -printf ("\nStatFS Change %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); - } - -inode_put (&ip); -return 0 ; +return ip; }int build_quota_change (struct gfs2_inode *per_node,unsigned int j)
gfs2/mkfs/main_mkfs.c +9 -3
@@ -708,12 +708,18 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) }inode_put (&ip); - err =build_statfs_change (per_node, j); -if (err) { + ip =build_statfs_change (per_node, j); +if (ip ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"statfs_change" ,strerror (errno)); -return err; +return 1 ; } +if (opts->debug) { +printf ("\nStatFS Change %u:\n" , j); +lgfs2_dinode_print (ip->i_bh->b_data); + } +inode_put (&ip); + err =build_quota_change (per_node, j);if (err) { fprintf(stderr, _("Error building '%s': %s\n"), "quota_change",
Signature · 1 line
2.34.1
PATCH 7/18 libgfs2: Return the inode from build_quota_change()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 8 ++++---- gfs2/fsck/pass1.c | 8 ++++---- gfs2/fsck/pass2.c | 12 +++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 18 +++++------------- gfs2/mkfs/main_mkfs.c | 12 ++++++++---- 6 files changed, 33 insertions(+), 27 deletions(-)
gfs2/convert/gfs2_convert.c +4 -4
@@ -2103,7 +2103,6 @@ static int build_per_node(struct gfs2_sbd *sdp) {struct gfs2_inode *per_node;unsigned int j; -int err; per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 ,GFS2_DIF_SYSTEM );
@@ -2130,12 +2129,13 @@ static int build_per_node(struct gfs2_sbd *sdp) }inode_put (&ip); - err =build_quota_change (per_node, j); -if (err) { + ip =build_quota_change (per_node, j); +if (ip ==NULL ) {log_crit (_ ("Error building '%s': %s\n" ),"quota_change" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); }inode_put (&per_node);return 0 ;
gfs2/fsck/pass1.c +4 -4
@@ -1581,7 +1581,6 @@ int build_per_node(struct gfs2_sbd *sdp) {struct gfs2_inode *per_node;unsigned int j; -int err; per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 ,GFS2_DIF_SYSTEM );
@@ -1608,12 +1607,13 @@ int build_per_node(struct gfs2_sbd *sdp) }inode_put (&ip); - err =build_quota_change (per_node, j); -if (err) { + ip =build_quota_change (per_node, j); +if (ip ==NULL ) {log_err (_ ("Error building '%s': %s\n" ),"quota_change" ,strerror (errno)); -return err; +return 1 ; } +inode_put (&ip); }inode_put (&per_node);return 0 ;
gfs2/fsck/pass2.c +11 -1
@@ -1895,6 +1895,16 @@ static int fsck_build_statfs_change(struct gfs2_inode *per_node, unsigned int n)return 0 ; } +static int fsck_build_quota_change (struct gfs2_inode *per_node,unsigned int n) +{ +struct gfs2_inode *ip =build_quota_change (per_node, n); + +if (ip ==NULL ) +return 1 ; +inode_put (&ip); +return 0 ; +} +/* Check system directory inode */ /* Should work for all system directories: root, master, jindex, per_node */ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1986,7 +1996,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,sprintf (fn,"quota_change%d" , j); error +=check_pernode_for (j, sysinode, fn,1048576 ,1 , "a_change_fxns, - build_quota_change); + fsck_build_quota_change); } }return error;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -789,7 +789,7 @@ extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx, uint64_t *buf, uint8_t state);extern struct gfs2_inode *build_inum_range (struct gfs2_inode *per_node,unsigned int n);extern struct gfs2_inode *build_statfs_change (struct gfs2_inode *per_node,unsigned int j); -extern int build_quota_change (struct gfs2_inode *per_node,unsigned int j); +extern struct gfs2_inode *build_quota_change (struct gfs2_inode *per_node,unsigned int j);/* super.c */ extern int check_sb (void *sbp);
gfs2/libgfs2/structures.c +5 -13
@@ -313,7 +313,7 @@ struct gfs2_inode *build_statfs_change(struct gfs2_inode *per_node, unsigned intreturn ip; } -int build_quota_change (struct gfs2_inode *per_node,unsigned int j) +struct gfs2_inode *build_quota_change (struct gfs2_inode *per_node,unsigned int j) {struct gfs2_sbd *sdp = per_node->i_sbd;struct gfs2_meta_header mh;
@@ -331,9 +331,8 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)sprintf (name,"quota_change%u" , j); ip =createi (per_node, name,S_IFREG |0600 ,GFS2_DIF_SYSTEM ); -if (ip ==NULL ) { -return errno; - } +if (ip ==NULL ) +return NULL ; hgt =calc_tree_height (ip, (blocks +1 ) * sdp->sd_bsize);build_height (ip, hgt);
@@ -341,21 +340,14 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)for (x =0 ; x < blocks; x++) { bh =get_file_buf (ip, x,0 );if (!bh) -return -1 ; +return NULL ;memset (bh->b_data,0 , sdp->sd_bsize);memcpy (bh->b_data, &mh,sizeof (mh));bmodified (bh);brelse (bh); } - -if (cfg_debug) { -printf ("\nQuota Change %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); - } - -inode_put (&ip); -return 0 ; +return ip; }int build_inum (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +8 -4
@@ -685,7 +685,6 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) {struct gfs2_inode *per_node;unsigned int j; -int err; per_node =createi (sdp->master_dir,"per_node" ,S_IFDIR |0700 ,GFS2_DIF_SYSTEM );
@@ -720,12 +719,17 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) }inode_put (&ip); - err =build_quota_change (per_node, j); -if (err) { + ip =build_quota_change (per_node, j); +if (ip ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"quota_change" ,strerror (errno)); -return err; +return 1 ; + } +if (opts->debug) { +printf ("\nQuota Change %u:\n" , j); +lgfs2_dinode_print (ip->i_bh->b_data); } +inode_put (&ip); }if (opts->debug) {printf ("\nper_node:\n" );
Signature · 1 line
2.34.1
PATCH 8/18 libgfs2: Return the inode from build_inum()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 5 ++--- gfs2/fsck/initialize.c | 25 ++++++++++++------------- gfs2/fsck/pass1.c | 11 ++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 14 ++------------ gfs2/mkfs/main_mkfs.c | 9 ++++++--- 6 files changed, 33 insertions(+), 33 deletions(-)
gfs2/convert/gfs2_convert.c +2 -3
@@ -2343,13 +2343,12 @@ int main(int argc, char **argv)exit (-1 ); }/* Create the empty inode number file */ - error =build_inum (&sb2);/* Does not do inode_put */ -if (error) { + sb2.md.inum =build_inum (&sb2);/* Does not do inode_put */ +if (sb2.md.inum ==NULL ) {log_crit (_ ("Error building inum inode: %s\n" ),strerror (error));exit (-1 ); } -gfs2_lookupi (sb2.master_dir,"inum" ,4 , &sb2.md.inum);/* Create the statfs file */ error =build_statfs (&sb2);/* Does not do inode_put */ if (error) {
gfs2/fsck/initialize.c +12 -13
@@ -504,12 +504,14 @@ static int rebuild_master(struct gfs2_sbd *sdp)exit (FSCK_ERROR ); } }else { - err =build_inum (sdp); -if (err) { -log_crit (_ ("Error %d building inum inode\n" ), err); + sdp->md.inum =build_inum (sdp); +if (sdp->md.inum ==NULL ) { +log_crit (_ ("Error building inum inode: %s\n" ),strerror (errno));exit (FSCK_ERROR ); } -gfs2_lookupi (sdp->master_dir,"inum" ,4 , &sdp->md.inum); +/* Write the inode but don't free it, to avoid doing an extra lookup */ +lgfs2_dinode_out (sdp->md.inum, sdp->md.inum->i_bh->b_data); +bwrite (sdp->md.inum->i_bh); }if (fix_md.statfs) {
@@ -798,17 +800,14 @@ static int init_system_inodes(struct gfs2_sbd *sdp) "a valid inum file; aborting.\n")); goto fail; } - err =build_inum (sdp); -if (err) { -log_crit (_ ("Error %d rebuilding inum inode\n" ), - err); + sdp->md.inum =build_inum (sdp); +if (sdp->md.inum ==NULL ) { +log_crit (_ ("Error rebuilding inum inode: %s\n" ),strerror (errno));exit (FSCK_ERROR ); } -gfs2_lookupi (sdp->master_dir,"inum" ,4 , - &sdp->md.inum); -if (!sdp->md.inum) { -log_crit (_ ("System inum inode was not rebuilt." -" Aborting.\n" )); +lgfs2_dinode_out (sdp->md.inum, sdp->md.inum->i_bh->b_data); +if (bwrite (sdp->md.inum->i_bh) !=0 ) { +log_crit (_ ("System inum inode was not rebuilt. Aborting.\n" )); goto fail; } }
gfs2/fsck/pass1.c +10 -1
@@ -1619,6 +1619,15 @@ int build_per_node(struct gfs2_sbd *sdp)return 0 ; } +static int fsck_build_inum (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *ip =build_inum (sdp); +if (ip ==NULL ) +return -1 ; +inode_put (&ip); +return 0 ; +} +static int check_system_inodes (struct gfs2_sbd *sdp) {int journal_count;
@@ -1648,7 +1657,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp)return -1 ; }if (!sdp->gfs1 && -check_system_inode (sdp, &sdp->md.inum,"inum" , build_inum,0 , +check_system_inode (sdp, &sdp->md.inum,"inum" , fsck_build_inum,0 , sdp->master_dir,1 )) { stack;return -1 ;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -777,7 +777,7 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);extern int build_journal (struct gfs2_sbd *sdp,int j,struct gfs2_inode *jindex);extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb); -extern int build_inum (struct gfs2_sbd *sdp); +extern struct gfs2_inode *build_inum (struct gfs2_sbd *sdp);extern int build_statfs (struct gfs2_sbd *sdp);extern int build_rindex (struct gfs2_sbd *sdp);extern int build_quota (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +2 -12
@@ -350,23 +350,13 @@ struct gfs2_inode *build_quota_change(struct gfs2_inode *per_node, unsigned intreturn ip; } -int build_inum (struct gfs2_sbd *sdp) +struct gfs2_inode *build_inum (struct gfs2_sbd *sdp) {struct gfs2_inode *ip; ip =createi (sdp->master_dir,"inum" ,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } - -if (cfg_debug) { -printf ("\nInum Inode:\n" ); -lgfs2_dinode_print (ip->i_bh->b_data); - } - -inode_put (&ip); -return 0 ; +return ip; }int build_statfs (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +6 -3
@@ -1296,12 +1296,15 @@ int main(int argc, char *argv[])if (error !=0 )exit (1 ); - error =build_inum (&sbd); -if (error) { + sbd.md.inum =build_inum (&sbd); +if (sbd.md.inum ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"inum" ,strerror (errno));exit (EXIT_FAILURE ); } -gfs2_lookupi (sbd.master_dir,"inum" ,4 , &sbd.md.inum); +if (opts.debug) { +printf ("\nInum Inode:\n" ); +lgfs2_dinode_print (sbd.md.inum->i_bh->b_data); + } error =build_statfs (&sbd);if (error) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"statfs" ,strerror (errno));
Signature · 1 line
2.34.1
PATCH 9/18 libgfs2: Return the inode from build_statfs()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 5 ++--- gfs2/fsck/initialize.c | 16 +++++++++------- gfs2/fsck/pass1.c | 11 ++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 14 ++------------ gfs2/mkfs/main_mkfs.c | 9 ++++++--- 6 files changed, 30 insertions(+), 27 deletions(-)
gfs2/convert/gfs2_convert.c +2 -3
@@ -2350,13 +2350,12 @@ int main(int argc, char **argv)exit (-1 ); }/* Create the statfs file */ - error =build_statfs (&sb2);/* Does not do inode_put */ -if (error) { + sb2.md.statfs =build_statfs (&sb2);/* Does not do inode_put */ +if (sb2.md.statfs ==NULL ) {log_crit (_ ("Error building statfs inode: %s\n" ),strerror (error));exit (-1 ); } -gfs2_lookupi (sb2.master_dir,"statfs" ,6 , &sb2.md.statfs);do_init_statfs (&sb2);/* Create the resource group index file */
gfs2/fsck/initialize.c +9 -7
@@ -524,12 +524,14 @@ static int rebuild_master(struct gfs2_sbd *sdp)exit (FSCK_ERROR ); } }else { - err =build_statfs (sdp); -if (err) { + sdp->md.statfs =build_statfs (sdp); +if (sdp->md.statfs ==NULL ) {log_crit (_ ("Error %d building statfs inode\n" ), err);exit (FSCK_ERROR ); } -gfs2_lookupi (sdp->master_dir,"statfs" ,6 , &sdp->md.statfs); +/* Write the inode but don't free it, to avoid doing an extra lookup */ +lgfs2_dinode_out (sdp->md.statfs, sdp->md.statfs->i_bh->b_data); +bwrite (sdp->md.statfs->i_bh); }if (fix_md.riinode) {
@@ -851,13 +853,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp) "statfs file; aborting.\n")); goto fail; } - err =build_statfs (sdp); -if (err) { + sdp->md.statfs =build_statfs (sdp); +if (sdp->md.statfs ==NULL ) {log_crit (_ ("Error %d rebuilding statfs inode\n" ), err);exit (FSCK_ERROR ); } -gfs2_lookupi (sdp->master_dir,"statfs" ,6 , &sdp->md.statfs); -if (!sdp->md.statfs) { +lgfs2_dinode_out (sdp->md.statfs, sdp->md.statfs->i_bh->b_data); +if (bwrite (sdp->md.statfs->i_bh) !=0 ) {log_err (_ ("Rebuild of statfs system file failed." ));log_err (_ ("fsck.gfs2 cannot continue without " "a valid statfs file; aborting.\n" ));
gfs2/fsck/pass1.c +10 -1
@@ -1628,6 +1628,15 @@ static int fsck_build_inum(struct gfs2_sbd *sdp)return 0 ; } +static int fsck_build_statfs (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *ip =build_statfs (sdp); +if (ip ==NULL ) +return -1 ; +inode_put (&ip); +return 0 ; +} +static int check_system_inodes (struct gfs2_sbd *sdp) {int journal_count;
@@ -1662,7 +1671,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp) stack;return -1 ; } -if (check_system_inode (sdp, &sdp->md.statfs,"statfs" , build_statfs,0 , +if (check_system_inode (sdp, &sdp->md.statfs,"statfs" , fsck_build_statfs,0 , sdp->master_dir, !sdp->gfs1)) { stack;return -1 ;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -778,7 +778,7 @@ extern int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex);extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb);extern struct gfs2_inode *build_inum (struct gfs2_sbd *sdp); -extern int build_statfs (struct gfs2_sbd *sdp); +extern struct gfs2_inode *build_statfs (struct gfs2_sbd *sdp);extern int build_rindex (struct gfs2_sbd *sdp);extern int build_quota (struct gfs2_sbd *sdp);extern int build_root (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +2 -12
@@ -359,23 +359,13 @@ struct gfs2_inode *build_inum(struct gfs2_sbd *sdp)return ip; } -int build_statfs (struct gfs2_sbd *sdp) +struct gfs2_inode *build_statfs (struct gfs2_sbd *sdp) {struct gfs2_inode *ip; ip =createi (sdp->master_dir,"statfs" ,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } - -if (cfg_debug) { -printf ("\nStatFS Inode:\n" ); -lgfs2_dinode_print (ip->i_bh->b_data); - } - -inode_put (&ip); -return 0 ; +return ip; }int build_rindex (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +6 -3
@@ -1305,12 +1305,15 @@ int main(int argc, char *argv[])printf ("\nInum Inode:\n" );lgfs2_dinode_print (sbd.md.inum->i_bh->b_data); } - error =build_statfs (&sbd); -if (error) { + sbd.md.statfs =build_statfs (&sbd); +if (sbd.md.statfs ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"statfs" ,strerror (errno));exit (EXIT_FAILURE ); } -gfs2_lookupi (sbd.master_dir,"statfs" ,6 , &sbd.md.statfs); +if (opts.debug) { +printf ("\nStatFS Inode:\n" ); +lgfs2_dinode_print (sbd.md.statfs->i_bh->b_data); + } error =build_rindex (&sbd);if (error) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"rindex" ,strerror (errno));
Signature · 1 line
2.34.1
PATCH 10/18 libgfs2: Return the inode from build_rindex()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 8 +++++--- gfs2/fsck/initialize.c | 15 +++++++++------ gfs2/fsck/pass1.c | 11 ++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 20 +++++++------------- gfs2/mkfs/main_mkfs.c | 10 ++++++++-- 6 files changed, 40 insertions(+), 26 deletions(-)
gfs2/convert/gfs2_convert.c +5 -3
@@ -2308,6 +2308,7 @@ int main(int argc, char **argv)/* Create our system files and directories. */ /* ---------------------------------------------- */ if (!error) { +struct gfs2_inode *ip;int jreduce =0 ;/* Now we've got to treat it as a gfs2 file system */
@@ -2359,12 +2360,13 @@ int main(int argc, char **argv)do_init_statfs (&sb2);/* Create the resource group index file */ - error =build_rindex (&sb2); -if (error) { + ip =build_rindex (&sb2); +if (ip ==NULL ) {log_crit (_ ("Error building rindex inode: %s\n" ), -strerror (error)); +strerror (errno));exit (-1 ); } +inode_put (&ip);/* Create the quota file */ error =build_quota (&sb2);if (error) {
gfs2/fsck/initialize.c +9 -6
@@ -544,11 +544,12 @@ static int rebuild_master(struct gfs2_sbd *sdp)exit (FSCK_ERROR ); } }else { - err =build_rindex (sdp); -if (err) { -log_crit (_ ("Error %d building rindex inode\n" ), err); +struct gfs2_inode *rip =build_rindex (sdp); +if (rip ==NULL ) { +log_crit (_ ("Error building rindex inode: %s\n" ),strerror (errno));exit (FSCK_ERROR ); } +inode_put (&rip); }if (fix_md.qinode) {
@@ -1514,7 +1515,7 @@ static int reconstruct_journals(struct gfs2_sbd *sdp)*/ static int init_rindex (struct gfs2_sbd *sdp) { -int err; +struct gfs2_inode *ip;if (sdp->gfs1) sdp->md.riinode =lgfs2_inode_read (sdp, sdp->sd_rindex_di.in_addr);
@@ -1529,10 +1530,12 @@ static int init_rindex(struct gfs2_sbd *sdp)log_crit (_ ("Error: Cannot proceed without a valid rindex.\n" ));return -1 ; } -if ((err =build_rindex (sdp))) { -log_crit (_ ("Error %d rebuilding rindex\n" ), err); + ip =build_rindex (sdp); +if (ip ==NULL ) { +log_crit (_ ("Error rebuilding rindex: %s\n" ),strerror (errno));return -1 ; } +inode_put (&ip);return 0 ; }
gfs2/fsck/pass1.c +10 -1
@@ -1637,6 +1637,15 @@ static int fsck_build_statfs(struct gfs2_sbd *sdp)return 0 ; } +static int fsck_build_rindex (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *ip =build_rindex (sdp); +if (ip ==NULL ) +return -1 ; +inode_put (&ip); +return 0 ; +} +static int check_system_inodes (struct gfs2_sbd *sdp) {int journal_count;
@@ -1682,7 +1691,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp) stack;return -1 ; } -if (check_system_inode (sdp, &sdp->md.riinode,"rindex" , build_rindex, +if (check_system_inode (sdp, &sdp->md.riinode,"rindex" , fsck_build_rindex,0 , sdp->master_dir, !sdp->gfs1)) { stack;return -1 ;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -779,7 +779,7 @@ extern int build_journal(struct gfs2_sbd *sdp, int j,extern struct gfs2_inode *lgfs2_build_jindex (struct gfs2_inode *metafs,struct lgfs2_inum *jnls,size_t nmemb);extern struct gfs2_inode *build_inum (struct gfs2_sbd *sdp);extern struct gfs2_inode *build_statfs (struct gfs2_sbd *sdp); -extern int build_rindex (struct gfs2_sbd *sdp); +extern struct gfs2_inode *build_rindex (struct gfs2_sbd *sdp);extern int build_quota (struct gfs2_sbd *sdp);extern int build_root (struct gfs2_sbd *sdp);extern int do_init_inum (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +7 -13
@@ -368,7 +368,7 @@ struct gfs2_inode *build_statfs(struct gfs2_sbd *sdp)return ip; } -int build_rindex (struct gfs2_sbd *sdp) +struct gfs2_inode *build_rindex (struct gfs2_sbd *sdp) {struct gfs2_inode *ip;struct osi_node *n, *next =NULL ;
@@ -378,9 +378,9 @@ int build_rindex(struct gfs2_sbd *sdp) ip =createi (sdp->master_dir,"rindex" ,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } +if (ip ==NULL ) +return NULL ; + ip->i_payload_format =GFS2_FORMAT_RI ;bmodified (ip->i_bh);
@@ -392,20 +392,14 @@ int build_rindex(struct gfs2_sbd *sdp) count =gfs2_writei (ip, buf, ip->i_size,sizeof (struct gfs2_rindex ));if (count !=sizeof (struct gfs2_rindex )) -return -1 ; +return NULL ; }memset (buf,0 ,sizeof (struct gfs2_rindex )); count =__gfs2_writei (ip, buf, ip->i_size,sizeof (struct gfs2_rindex ),0 );if (count !=sizeof (struct gfs2_rindex )) -return -1 ; - -if (cfg_debug) { -printf ("\nResource Index:\n" ); -lgfs2_dinode_print (ip->i_bh->b_data); - } +return NULL ; -inode_put (&ip); -return 0 ; +return ip; }int build_quota (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +8 -2
@@ -1198,6 +1198,7 @@ int main(int argc, char *argv[]) {struct gfs2_sbd sbd;struct mkfs_opts opts; +struct gfs2_inode *ip;lgfs2_rgrps_t rgs;uint64_t rgaddr;int error;
@@ -1314,11 +1315,16 @@ int main(int argc, char *argv[])printf ("\nStatFS Inode:\n" );lgfs2_dinode_print (sbd.md.statfs->i_bh->b_data); } - error =build_rindex (&sbd); -if (error) { + ip =build_rindex (&sbd); +if (ip ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"rindex" ,strerror (errno));exit (EXIT_FAILURE ); } +if (opts.debug) { +printf ("\nResource Index:\n" ); +lgfs2_dinode_print (ip->i_bh->b_data); + } +inode_put (&ip);if (!opts.quiet) {printf ("%s" ,_ ("Creating quota file: " ));fflush (stdout);
Signature · 1 line
2.34.1
PATCH 11/18 libgfs2: Return the inode from build_quota()
In reply to Andrew PriceThis allows the caller to call inode_put() when it's convenient and also allows the debug message printing to be moved out of the function. fsck.gfs2 passes the function by reference so it needs a shim until the other builder functions can be given the same signature.
--- gfs2/convert/gfs2_convert.c | 5 +++-- gfs2/fsck/initialize.c | 17 +++++++++-------- gfs2/fsck/pass1.c | 11 ++++++++++- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 20 +++++++------------- gfs2/mkfs/main_mkfs.c | 9 +++++++-- 6 files changed, 37 insertions(+), 27 deletions(-)
gfs2/convert/gfs2_convert.c +3 -2
@@ -2368,12 +2368,13 @@ int main(int argc, char **argv) }inode_put (&ip);/* Create the quota file */ - error =build_quota (&sb2); -if (error) { + ip =build_quota (&sb2); +if (ip ==NULL ) {log_crit (_ ("Error building quota inode: %s\n" ),strerror (error));exit (-1 ); } +inode_put (&ip);/* Copy out the master dinode */ if (sb2.master_dir->i_bh->b_modified)
gfs2/fsck/initialize.c +9 -8
@@ -562,11 +562,12 @@ static int rebuild_master(struct gfs2_sbd *sdp)exit (FSCK_ERROR ); } }else { - err =build_quota (sdp); -if (err) { -log_crit (_ ("Error %d building quota inode\n" ), err); +struct gfs2_inode *qip =build_quota (sdp); +if (qip ==NULL ) { +log_crit (_ ("Error building quota inode: %s\n" ),strerror (errno));exit (FSCK_ERROR ); } +inode_put (&qip); }log_err (_ ("Master directory rebuilt.\n" ));
@@ -911,13 +912,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp) "rebuilt. Aborting.\n")); goto fail; } - err =build_quota (sdp); -if (err) { -log_crit (_ ("Error %d rebuilding quota inode\n" ), err); + sdp->md.qinode =build_quota (sdp); +if (sdp->md.qinode ==NULL ) { +log_crit (_ ("Error rebuilding quota inode: %s\n" ),strerror (errno));exit (FSCK_ERROR ); } -gfs2_lookupi (sdp->master_dir,"quota" ,5 , &sdp->md.qinode); -if (!sdp->md.qinode) { +lgfs2_dinode_out (sdp->md.qinode, sdp->md.qinode->i_bh->b_data); +if (bwrite (sdp->md.qinode->i_bh) !=0 ) {log_crit (_ ("Unable to rebuild system quota file " "inode. Aborting.\n" )); goto fail;
gfs2/fsck/pass1.c +10 -1
@@ -1646,6 +1646,15 @@ static int fsck_build_rindex(struct gfs2_sbd *sdp)return 0 ; } +static int fsck_build_quota (struct gfs2_sbd *sdp) +{ +struct gfs2_inode *ip =build_quota (sdp); +if (ip ==NULL ) +return -1 ; +inode_put (&ip); +return 0 ; +} +static int check_system_inodes (struct gfs2_sbd *sdp) {int journal_count;
@@ -1696,7 +1705,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp) stack;return -1 ; } -if (check_system_inode (sdp, &sdp->md.qinode,"quota" , build_quota, +if (check_system_inode (sdp, &sdp->md.qinode,"quota" , fsck_build_quota,0 , sdp->master_dir, !sdp->gfs1)) { stack;return -1 ;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -780,7 +780,7 @@ extern struct gfs2_inode *lgfs2_build_jindex(struct gfs2_inode *metafs, struct lextern struct gfs2_inode *build_inum (struct gfs2_sbd *sdp);extern struct gfs2_inode *build_statfs (struct gfs2_sbd *sdp);extern struct gfs2_inode *build_rindex (struct gfs2_sbd *sdp); -extern int build_quota (struct gfs2_sbd *sdp); +extern struct gfs2_inode *build_quota (struct gfs2_sbd *sdp);extern int build_root (struct gfs2_sbd *sdp);extern int do_init_inum (struct gfs2_sbd *sdp);extern int do_init_statfs (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +7 -13
@@ -402,7 +402,7 @@ struct gfs2_inode *build_rindex(struct gfs2_sbd *sdp)return ip; } -int build_quota (struct gfs2_sbd *sdp) +struct gfs2_inode *build_quota (struct gfs2_sbd *sdp) {struct gfs2_inode *ip;struct gfs2_quota qu;
@@ -410,9 +410,9 @@ int build_quota(struct gfs2_sbd *sdp) ip =createi (sdp->master_dir,"quota" ,S_IFREG |0600 ,GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ); -if (ip ==NULL ) { -return errno; - } +if (ip ==NULL ) +return NULL ; + ip->i_payload_format =GFS2_FORMAT_QU ;bmodified (ip->i_bh);
@@ -421,18 +421,12 @@ int build_quota(struct gfs2_sbd *sdp) count =gfs2_writei (ip, &qu, ip->i_size,sizeof (struct gfs2_quota ));if (count !=sizeof (struct gfs2_quota )) -return -1 ; +return NULL ; count =gfs2_writei (ip, &qu, ip->i_size,sizeof (struct gfs2_quota ));if (count !=sizeof (struct gfs2_quota )) -return -1 ; - -if (cfg_debug) { -printf ("\nRoot quota:\n" ); -lgfs2_quota_print (&qu); - } +return NULL ; -inode_put (&ip); -return 0 ; +return ip; }int build_root (struct gfs2_sbd *sdp)
gfs2/mkfs/main_mkfs.c +7 -2
@@ -1329,11 +1329,16 @@ int main(int argc, char *argv[])printf ("%s" ,_ ("Creating quota file: " ));fflush (stdout); } - error =build_quota (&sbd); -if (error) { + ip =build_quota (&sbd); +if (ip ==NULL ) {fprintf (stderr,_ ("Error building '%s': %s\n" ),"quota" ,strerror (errno));exit (EXIT_FAILURE ); } +if (opts.debug) { +printf ("\nQuota:\n" ); +lgfs2_dinode_print (ip->i_bh->b_data); + } +inode_put (&ip);if (!opts.quiet)printf ("%s" ,_ ("Done\n" ));
Signature · 1 line
2.34.1
PATCH 12/18 libgfs2: Move debugging printf out of build_root()
In reply to Andrew Pricemkfs.gfs2 is the only place it could ever get printed so move it there instead.
--- gfs2/libgfs2/structures.c | 4 ---- gfs2/mkfs/main_mkfs.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
gfs2/libgfs2/structures.c +0 -4
@@ -450,10 +450,6 @@ int build_root(struct gfs2_sbd *sdp)if (sdp->md.rooti ==NULL )return -1 ; -if (cfg_debug) { -printf ("\nRoot directory:\n" ); -lgfs2_dinode_print (bh->b_data); - } sdp->md.rooti->bh_owned =1 ;return 0 ; }
gfs2/mkfs/main_mkfs.c +4 -0
@@ -1343,6 +1343,10 @@ int main(int argc, char *argv[])printf ("%s" ,_ ("Done\n" ));build_root (&sbd); +if (opts.debug) { +printf ("\nRoot directory:\n" ); +lgfs2_dinode_print (sbd.md.rooti->i_bh->b_data); + } sbd.sd_root_dir = sbd.md.rooti->i_num;strncpy (sbd.sd_lockproto, opts.lockproto,GFS2_LOCKNAME_LEN -1 );
Signature · 1 line
2.34.1
PATCH 13/18 libgfs2: Remove debugging printf from do_init_statfs()
In reply to Andrew PriceAllow the caller to provide a pointer to a statfs change structure so that it can do its own debug message printing. This is only used by mkfs.gfs2.
--- gfs2/convert/gfs2_convert.c | 2 +- gfs2/fsck/initialize.c | 2 +- gfs2/fsck/main.c | 2 +- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/libgfs2/structures.c | 8 +++----- gfs2/mkfs/main_mkfs.c | 8 ++++++-- 6 files changed, 13 insertions(+), 11 deletions(-)
gfs2/convert/gfs2_convert.c +1 -1
@@ -2357,7 +2357,7 @@ int main(int argc, char **argv) strerror(error));exit (-1 ); } -do_init_statfs (&sb2); +do_init_statfs (&sb2,NULL );/* Create the resource group index file */ ip =build_rindex (&sb2);
gfs2/fsck/initialize.c +1 -1
@@ -867,7 +867,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp) "a valid statfs file; aborting.\n")); goto fail; } -do_init_statfs (sdp); +do_init_statfs (sdp,NULL ); }if (sdp->md.statfs->i_size) { buf =malloc (sdp->md.statfs->i_size);
gfs2/fsck/main.c +1 -1
@@ -228,7 +228,7 @@ static int check_statfs(struct gfs2_sbd *sdp)return 0 ; } -do_init_statfs (sdp); +do_init_statfs (sdp,NULL );log_err (_ ("The statfs file was fixed.\n" )); errors_corrected++;return 0 ;
gfs2/libgfs2/libgfs2.h +1 -1
@@ -783,7 +783,7 @@ extern struct gfs2_inode *build_rindex(struct gfs2_sbd *sdp);extern struct gfs2_inode *build_quota (struct gfs2_sbd *sdp);extern int build_root (struct gfs2_sbd *sdp);extern int do_init_inum (struct gfs2_sbd *sdp); -extern int do_init_statfs (struct gfs2_sbd *sdp); +extern int do_init_statfs (struct gfs2_sbd *sdp,struct gfs2_statfs_change *res);extern int gfs2_check_meta (const char *buf,int type);extern unsigned lgfs2_bm_scan (struct rgrp_tree *rgd,unsigned idx,uint64_t *buf,uint8_t state);
gfs2/libgfs2/structures.c +3 -5
@@ -471,7 +471,7 @@ int do_init_inum(struct gfs2_sbd *sdp)return 0 ; } -int do_init_statfs (struct gfs2_sbd *sdp) +int do_init_statfs (struct gfs2_sbd *sdp,struct gfs2_statfs_change *res) {struct gfs2_inode *ip = sdp->md.statfs;struct gfs2_statfs_change sc;
@@ -485,10 +485,8 @@ int do_init_statfs(struct gfs2_sbd *sdp)if (count !=sizeof (sc))return -1 ; -if (cfg_debug) { -printf ("\nStatfs:\n" ); -lgfs2_statfs_change_print (&sc); - } +if (res) + *res = sc;return 0 ; }
gfs2/mkfs/main_mkfs.c +6 -2
@@ -1196,6 +1196,7 @@ static int open_dev(struct mkfs_dev *dev, int withprobe)#ifndef UNITTESTS int main (int argc,char *argv[]) { +struct gfs2_statfs_change sc;struct gfs2_sbd sbd;struct mkfs_opts opts;struct gfs2_inode *ip;
@@ -1355,8 +1356,11 @@ int main(int argc, char *argv[]) sbd.sd_locktable[GFS2_LOCKNAME_LEN -1 ] ='\0' ;do_init_inum (&sbd); -do_init_statfs (&sbd); - +do_init_statfs (&sbd, &sc); +if (opts.debug) { +printf ("\nStatfs:\n" ); +lgfs2_statfs_change_print (&sc); + }inode_put (&sbd.md.rooti);inode_put (&sbd.master_dir);inode_put (&sbd.md.inum);
Signature · 1 line
2.34.1
PATCH 14/18 libgfs2: Move debugging output out of do_init_inum()
In reply to Andrew Price--- gfs2/libgfs2/structures.c | 3 --- gfs2/mkfs/main_mkfs.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
gfs2/libgfs2/structures.c +0 -3
@@ -465,9 +465,6 @@ int do_init_inum(struct gfs2_sbd *sdp)if (count !=sizeof (uint64_t ))return -1 ; -if (cfg_debug) -printf ("\nNext Inum: %" PRIu64"\n" , - sdp->md.next_inum);return 0 ; }
gfs2/mkfs/main_mkfs.c +3 -0
@@ -1356,6 +1356,9 @@ int main(int argc, char *argv[]) sbd.sd_locktable[GFS2_LOCKNAME_LEN -1 ] ='\0' ;do_init_inum (&sbd); +if (opts.debug) +printf ("\nNext Inum: %" PRIu64"\n" , sbd.md.next_inum); +do_init_statfs (&sbd, &sc);if (opts.debug) {printf ("\nStatfs:\n" );
Signature · 1 line
2.34.1
PATCH 15/18 libgfs2: Remove debugging printfs from fix_device_geometry()
In reply to Andrew PriceThis block never gets executed as the only utils that enable cfg_debug don't call the function.
--- gfs2/libgfs2/device_geometry.c | 6 ------ 1 file changed, 6 deletions(-)
gfs2/libgfs2/device_geometry.c +0 -6
@@ -98,10 +98,4 @@ void fix_device_geometry(struct gfs2_sbd *sdp)struct device *device = &sdp->device; device->length = sdp->dinfo.size / sdp->sd_bsize; - -if (cfg_debug) { -printf ("\nDevice Geometry: (in FS blocks)\n" ); -printf (" length = %" PRIu64"\n" , device->length); -printf ("\nDevice Size: %" PRIu64"\n" , sdp->dinfo.size); - } }
Signature · 1 line
2.34.1
PATCH 16/18 libgfs2: Remove config.[ch]
In reply to Andrew PriceThe cfg_debug bits are no longer used.
--- gfs2/libgfs2/Makefile.am | 2 -- gfs2/libgfs2/checks.am | 1 - gfs2/libgfs2/config.c | 9 --------- gfs2/libgfs2/config.h | 6 ------ gfs2/libgfs2/device_geometry.c | 1 - gfs2/libgfs2/libgfs2.h | 3 --- gfs2/libgfs2/structures.c | 1 - gfs2/mkfs/main_jadd.c | 1 - gfs2/mkfs/main_mkfs.c | 1 - 9 files changed, 25 deletions(-) delete mode 100644 gfs2/libgfs2/config.c delete mode 100644 gfs2/libgfs2/config.h
gfs2/libgfs2/Makefile.am +0 -2
@@ -23,7 +23,6 @@ noinst_HEADERS = \ libgfs2.h \ crc32c.h \ lang.h \ - config.h \ rgrp.h noinst_LTLIBRARIES = libgfs2.la
@@ -40,7 +39,6 @@ libgfs2_la_SOURCES = \ buf.c \ gfs2_disk_hash.c \ ondisk.c \ - config.c \ device_geometry.c \ fs_ops.c \ recovery.c \
gfs2/libgfs2/checks.am +0 -1
@@ -12,7 +12,6 @@ check_libgfs2_SOURCES = \ device_geometry.c \ fs_ops.c \ structures.c \ - config.c \ fs_bits.c \ gfs1.c \ misc.c \
gfs2/libgfs2/config.c deleted +0 -9
@@ -1,9 +0,0 @@ -#include "libgfs2.h" -#include "config.h" - -int cfg_debug =0 ; - -void lgfs2_set_debug (int enable) -{ - cfg_debug = enable; -}
gfs2/libgfs2/config.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef __LGFS2_CONFIG_H__ -#define __LGFS2_CONFIG_H__ - -extern int cfg_debug; - -#endif /* __LGFS2_CONFIG_H__ */
gfs2/libgfs2/device_geometry.c +0 -1
@@ -14,7 +14,6 @@#include <linux/fs.h> #include "libgfs2.h" -#include "config.h" #ifndef BLKSSZGET #define BLKSSZGET _IO(0x12,104)/* logical_block_size */
gfs2/libgfs2/libgfs2.h +0 -3
@@ -471,9 +471,6 @@ extern uint32_t lgfs2_get_block_type(const char *buf);#define bread (bl, num) __bread(bl, num, __LINE__, __FUNCTION__)#define breadm (bl, bhs, n, block) __breadm(bl, bhs, n, block, __LINE__, __FUNCTION__) -/* config.c */ -extern void lgfs2_set_debug (int enable); -/* device_geometry.c */ extern int lgfs2_get_dev_info (int fd,struct lgfs2_dev_info *i);extern void fix_device_geometry (struct gfs2_sbd *sdp);
gfs2/libgfs2/structures.c +0 -1
@@ -14,7 +14,6 @@#include <uuid.h> #include "libgfs2.h" -#include "config.h" #include "crc32c.h" int build_master (struct gfs2_sbd *sdp)
gfs2/mkfs/main_jadd.c +0 -1
@@ -158,7 +158,6 @@ static int decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp, structbreak ;case 'D' : opts->debug =1 ; -lgfs2_set_debug (1 );break ;case 'h' :print_usage (argv[0 ]);
gfs2/mkfs/main_mkfs.c +0 -1
@@ -366,7 +366,6 @@ static int opts_get(int argc, char *argv[], struct mkfs_opts *opts)break ;case 'D' : opts->debug =1 ; -lgfs2_set_debug (1 );break ;case 'h' :print_usage (argv[0 ]);
Signature · 1 line
2.34.1
PATCH 17/18 libgfs2: Move struct printing functions out of libgfs2
In reply to Andrew PriceNow that libgfs2 itself doesn't use these functions, they can be moved into the two utils that use them. This does duplicate the code but that means the utils are free to change the way that they're printed to suit their interfaces. We're still using the "print_it" extern that libgfs2.h requires but that can be removed next.
--- gfs2/edit/Makefile.am | 2 + gfs2/edit/extended.c | 11 ++- gfs2/edit/gfs2hex.c | 33 ++++--- gfs2/edit/hexedit.c | 9 +- gfs2/edit/struct_print.c | 206 +++++++++++++++++++++++++++++++++++++++ gfs2/edit/struct_print.h | 19 ++++ gfs2/libgfs2/libgfs2.h | 15 --- gfs2/libgfs2/ondisk.c | 199 ------------------------------------- gfs2/mkfs/Makefile.am | 2 + gfs2/mkfs/main_mkfs.c | 27 ++--- gfs2/mkfs/struct_print.c | 206 +++++++++++++++++++++++++++++++++++++++ gfs2/mkfs/struct_print.h | 19 ++++ 12 files changed, 496 insertions(+), 252 deletions(-) create mode 100644 gfs2/edit/struct_print.c create mode 100644 gfs2/edit/struct_print.h create mode 100644 gfs2/mkfs/struct_print.c create mode 100644 gfs2/mkfs/struct_print.h
gfs2/edit/Makefile.am +2 -0
@@ -6,6 +6,7 @@ noinst_HEADERS = \ gfs2hex.h \ hexedit.h \ extended.h \ + struct_print.h \ journal.h gfs2_edit_SOURCES = \
@@ -13,6 +14,7 @@ gfs2_edit_SOURCES = \ hexedit.c \ savemeta.c \ extended.c \ + struct_print.c \ journal.c gfs2_edit_CPPFLAGS = \
gfs2/edit/extended.c +6 -5
@@ -17,13 +17,14 @@#include <sys/ioctl.h> #include <sys/mount.h> #include <dirent.h> +#include <libgfs2.h> #include "copyright.cf" #include "hexedit.h" -#include "libgfs2.h" #include "extended.h" #include "gfs2hex.h" +#include "struct_print.h" static void print_block_details (struct iinfo *ind,int level,int cur_height,int pndx,uint64_t file_offset);
@@ -534,7 +535,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)if (edit_row[dmode] == print_entry_ndx)COLORS_NORMAL ;if (print_rindex) -lgfs2_rindex_print (&ri); +rindex_print (&ri);else {struct gfs2_rgrp r = {0 };ssize_t ret;
@@ -545,7 +546,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex) }else if (sbd.gfs1) {gfs_rgrp_print (&r); }else { -lgfs2_rgrp_print (&r); +rgrp_print (&r); } } last_entry_onscreen[dmode] = print_entry_ndx;
@@ -597,7 +598,7 @@ static int print_statfs(struct gfs2_inode *dis) }print_gfs2 ("statfs file contents:" );eol (0 ); -lgfs2_statfs_change_print (&sc); +statfs_change_print (&sc);return 0 ; }
@@ -621,7 +622,7 @@ static int print_quota(struct gfs2_inode *diq) }print_gfs2 ("Entry #%d" , i +1 );eol (0 ); -lgfs2_quota_print (&q); +quota_print (&q); }return 0 ; }
gfs2/edit/gfs2hex.c +17 -16
@@ -11,11 +11,12 @@#include <errno.h> #include <curses.h> #include <uuid.h> +#include <libgfs2.h> #include "hexedit.h" #include "extended.h" #include "gfs2hex.h" -#include "libgfs2.h" +#include "struct_print.h" #define pv (struct, member, fmt, fmt2) do { \ print_it(" "#member, fmt, fmt2, struct->member); \
@@ -364,7 +365,7 @@ static void do_eattr_extended(char *buf)eol (0 ); buf += x; ea = (struct gfs2_ea_header *)buf; -lgfs2_ea_header_print (ea); +ea_header_print (ea); rec_len =be32_to_cpu (ea->ea_rec_len); } }
@@ -377,20 +378,20 @@ static void gfs_sb_print(void *sbp) {struct gfs_sb *sb = sbp; -lgfs2_meta_header_print (&sb->sb_header); +meta_header_print (&sb->sb_header);printbe32 (sb, sb_fs_format);printbe32 (sb, sb_multihost_format);printbe32 (sb, sb_flags);printbe32 (sb, sb_bsize);printbe32 (sb, sb_bsize_shift);printbe32 (sb, sb_seg_size); -lgfs2_inum_print (&sb->sb_jindex_di); -lgfs2_inum_print (&sb->sb_rindex_di); -lgfs2_inum_print (&sb->sb_root_di); +inum_print (&sb->sb_jindex_di); +inum_print (&sb->sb_rindex_di); +inum_print (&sb->sb_root_di);pv (sb, sb_lockproto,"%.64s" ,NULL );pv (sb, sb_locktable,"%.64s" ,NULL ); -lgfs2_inum_print (&sb->sb_quota_di); -lgfs2_inum_print (&sb->sb_license_di); +inum_print (&sb->sb_quota_di); +inum_print (&sb->sb_license_di); }void display_gfs2 (void *buf)
@@ -418,41 +419,41 @@ void display_gfs2(void *buf)if (sbd.gfs1)gfs_sb_print (buf);else -lgfs2_sb_print (buf); +sb_print (buf);break ;case GFS2_METATYPE_RG :if (sbd.gfs1)gfs_rgrp_print (buf);else -lgfs2_rgrp_print (buf); +rgrp_print (buf);break ;case GFS2_METATYPE_DI : -lgfs2_dinode_print (di); +dinode_print (di);break ;case GFS2_METATYPE_LF : -lgfs2_leaf_print (buf); +leaf_print (buf);break ;case GFS2_METATYPE_LH :if (sbd.gfs1)gfs_log_header_print (buf);else -lgfs2_log_header_print (buf); +log_header_print (buf);break ;case GFS2_METATYPE_LD : -lgfs2_log_descriptor_print (buf); +log_descriptor_print (buf);break ;case GFS2_METATYPE_EA :do_eattr_extended (buf);break ;case GFS2_METATYPE_QC : -lgfs2_quota_change_print (buf); +quota_change_print (buf);break ;case GFS2_METATYPE_RB :case GFS2_METATYPE_IN :case GFS2_METATYPE_JD :case GFS2_METATYPE_ED :case GFS2_METATYPE_LB : -lgfs2_meta_header_print (mh); +meta_header_print (mh);break ;default :print_gfs2 ("Unknown block type" );
gfs2/edit/hexedit.c +5 -4
@@ -25,6 +25,7 @@#include "gfs2hex.h" #include "extended.h" #include "journal.h" +#include "struct_print.h" #define printbe32 (struct, member) do { \ print_it(" "#member, "%"PRIu32, "0x%"PRIx32, be32_to_cpu(struct->member)); \
@@ -733,12 +734,12 @@ void gfs_rgrp_print(void *rgp) {struct gfs_rgrp *rg = rgp; -lgfs2_meta_header_print (&rg->rg_header); +meta_header_print (&rg->rg_header);printbe32 (rg, rg_flags);printbe32 (rg, rg_free);printbe32 (rg, rg_useddi);printbe32 (rg, rg_freedi); -lgfs2_inum_print (&rg->rg_freedi_list); +inum_print (&rg->rg_freedi_list);printbe32 (rg, rg_usedmeta);printbe32 (rg, rg_freemeta); }
@@ -799,7 +800,7 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)if (sbd.gfs1)gfs_rgrp_print (rg);else -lgfs2_rgrp_print (rg); +rgrp_print (rg); }else printf("RG #%d (block %"PRIu64" / 0x%"PRIx64") rg_flags = 0x%08x\n",
@@ -2034,7 +2035,7 @@ void gfs_log_header_print(void *lhp) {struct gfs_log_header *lh = lhp; -lgfs2_meta_header_print (&lh->lh_header); +meta_header_print (&lh->lh_header);print_it (" lh_flags" ,"%" PRIu32,"0x%.8" PRIx32,be32_to_cpu (lh->lh_flags));print_it (" lh_pad" ,"%" PRIu32,"0x%" PRIx32,be32_to_cpu (lh->lh_pad));print_it (" lh_first" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (lh->lh_first));
gfs2/edit/struct_print.c new file +206 -0
206 lines not on this page · raw message
gfs2/edit/struct_print.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef STRUCT_PRINT_H +#define STRUCT_PRINT_H + +/* Printing functions. These expect on-disk data */ +extern void inum_print (void *nop); +extern void meta_header_print (void *mhp); +extern void sb_print (void *sbp); +extern void dinode_print (void *dip); +extern void log_header_print (void *lhp); +extern void log_descriptor_print (void *ldp); +extern void quota_print (void *qp); +extern void quota_change_print (void *qcp); +extern void statfs_change_print (void *scp); +extern void ea_header_print (void *eap); +extern void leaf_print (void *lfp); +extern void rindex_print (void *rip); +extern void rgrp_print (void *rgp); + +#endif /* STRUCT_PRINT_H */
gfs2/libgfs2/libgfs2.h +0 -15
@@ -816,21 +816,6 @@ extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep);extern void lgfs2_leaf_in (struct lgfs2_leaf *lf,void *lfp);extern void lgfs2_leaf_out (struct lgfs2_leaf *lf,void *lfp); -/* Printing functions. These expect on-disk data */ -extern void lgfs2_inum_print (void *nop); -extern void lgfs2_meta_header_print (void *mhp); -extern void lgfs2_sb_print (void *sbp); -extern void lgfs2_dinode_print (void *dip); -extern void lgfs2_log_header_print (void *lhp); -extern void lgfs2_log_descriptor_print (void *ldp); -extern void lgfs2_quota_print (void *qp); -extern void lgfs2_quota_change_print (void *qcp); -extern void lgfs2_statfs_change_print (void *scp); -extern void lgfs2_ea_header_print (void *eap); -extern void lgfs2_leaf_print (void *lfp); -extern void lgfs2_rindex_print (void *rip); -extern void lgfs2_rgrp_print (void *rgp); - __END_DECLS#endif /* __LIBGFS2_DOT_H__ */
gfs2/libgfs2/ondisk.c +0 -199
238 lines not on this page · raw message
gfs2/mkfs/Makefile.am +2 -0
@@ -14,10 +14,12 @@ sbin_PROGRAMS = \ noinst_HEADERS = \ gfs2_mkfs.h \ + struct_print.h \ metafs.h mkfs_gfs2_SOURCES = \ main_mkfs.c \ + struct_print.c \ progress.c \ progress.h
gfs2/mkfs/main_mkfs.c +14 -13
@@ -29,6 +29,7 @@#include "libgfs2.h" #include "gfs2_mkfs.h" #include "progress.h" +#include "struct_print.h" static void print_usage (const char *prog_name) {
@@ -702,7 +703,7 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) }if (opts->debug) {printf ("\nInum Range %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); +dinode_print (ip->i_bh->b_data); }inode_put (&ip);
@@ -714,7 +715,7 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) }if (opts->debug) {printf ("\nStatFS Change %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); +dinode_print (ip->i_bh->b_data); }inode_put (&ip);
@@ -726,13 +727,13 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts) }if (opts->debug) {printf ("\nQuota Change %u:\n" , j); -lgfs2_dinode_print (ip->i_bh->b_data); +dinode_print (ip->i_bh->b_data); }inode_put (&ip); }if (opts->debug) {printf ("\nper_node:\n" ); -lgfs2_dinode_print (per_node->i_bh->b_data); +dinode_print (per_node->i_bh->b_data); }inode_put (&per_node);return 0 ;
@@ -856,7 +857,7 @@ static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)return -1 ; }if (debug) { -lgfs2_rindex_print (&ri); +rindex_print (&ri);printf ("\n" ); } sdp->blks_total +=be32_to_cpu (ri.ri_data);
@@ -1009,7 +1010,7 @@ static int create_jindex(struct gfs2_sbd *sdp, struct mkfs_opts *opts, struct lg }if (opts->debug) {printf ("Jindex:\n" ); -lgfs2_dinode_print (jindex->i_bh->b_data); +dinode_print (jindex->i_bh->b_data); }inode_put (&jindex);return 0 ;
@@ -1284,7 +1285,7 @@ int main(int argc, char *argv[]) }if (opts.debug) {printf ("Metafs inode:\n" ); -lgfs2_dinode_print (sbd.master_dir->i_bh->b_data); +dinode_print (sbd.master_dir->i_bh->b_data); } sbd.sd_meta_dir = sbd.master_dir->i_num;
@@ -1304,7 +1305,7 @@ int main(int argc, char *argv[]) }if (opts.debug) {printf ("\nInum Inode:\n" ); -lgfs2_dinode_print (sbd.md.inum->i_bh->b_data); +dinode_print (sbd.md.inum->i_bh->b_data); } sbd.md.statfs =build_statfs (&sbd);if (sbd.md.statfs ==NULL ) {
@@ -1313,7 +1314,7 @@ int main(int argc, char *argv[]) }if (opts.debug) {printf ("\nStatFS Inode:\n" ); -lgfs2_dinode_print (sbd.md.statfs->i_bh->b_data); +dinode_print (sbd.md.statfs->i_bh->b_data); } ip =build_rindex (&sbd);if (ip ==NULL ) {
@@ -1322,7 +1323,7 @@ int main(int argc, char *argv[]) }if (opts.debug) {printf ("\nResource Index:\n" ); -lgfs2_dinode_print (ip->i_bh->b_data); +dinode_print (ip->i_bh->b_data); }inode_put (&ip);if (!opts.quiet) {
@@ -1336,7 +1337,7 @@ int main(int argc, char *argv[]) }if (opts.debug) {printf ("\nQuota:\n" ); -lgfs2_dinode_print (ip->i_bh->b_data); +dinode_print (ip->i_bh->b_data); }inode_put (&ip);if (!opts.quiet)
@@ -1345,7 +1346,7 @@ int main(int argc, char *argv[])build_root (&sbd);if (opts.debug) {printf ("\nRoot directory:\n" ); -lgfs2_dinode_print (sbd.md.rooti->i_bh->b_data); +dinode_print (sbd.md.rooti->i_bh->b_data); } sbd.sd_root_dir = sbd.md.rooti->i_num;
@@ -1361,7 +1362,7 @@ int main(int argc, char *argv[])do_init_statfs (&sbd, &sc);if (opts.debug) {printf ("\nStatfs:\n" ); -lgfs2_statfs_change_print (&sc); +statfs_change_print (&sc); }inode_put (&sbd.md.rooti);inode_put (&sbd.master_dir);
gfs2/mkfs/struct_print.c new file +206 -0
206 lines not on this page · raw message
gfs2/mkfs/struct_print.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef STRUCT_PRINT_H +#define STRUCT_PRINT_H + +/* Printing functions. These expect on-disk data */ +extern void inum_print (void *nop); +extern void meta_header_print (void *mhp); +extern void sb_print (void *sbp); +extern void dinode_print (void *dip); +extern void log_header_print (void *lhp); +extern void log_descriptor_print (void *ldp); +extern void quota_print (void *qp); +extern void quota_change_print (void *qcp); +extern void statfs_change_print (void *scp); +extern void ea_header_print (void *eap); +extern void leaf_print (void *lfp); +extern void rindex_print (void *rip); +extern void rgrp_print (void *rgp); + +#endif /* STRUCT_PRINT_H */
Signature · 1 line
2.34.1
PATCH 18/18 libgfs2: Remove print_it extern requirement
In reply to Andrew PriceNow that libgfs2 doesn't depend on a print_it() function being provided by the utils, the extern declaration can be removed from libgfs2.h. The print_it functions in mkfs.gfs2 and gfs2_edit are moved into their struct_print.c files and made static. All other print_it definitions are removed or made static.
--- gfs2/convert/gfs2_convert.c | 13 --- gfs2/edit/extended.c | 7 -- gfs2/edit/gfs2hex.c | 135 ----------------------- gfs2/edit/hexedit.c | 33 ------ gfs2/edit/hexedit.h | 4 +- gfs2/edit/struct_print.c | 200 +++++++++++++++++++++++++++++++---- gfs2/edit/struct_print.h | 4 + gfs2/fsck/main.c | 11 -- gfs2/glocktop/glocktop.c | 3 +- gfs2/libgfs2/check_libgfs2.c | 3 - gfs2/libgfs2/gfs2l.c | 3 - gfs2/libgfs2/libgfs2.h | 2 - gfs2/mkfs/gfs2_mkfs.h | 11 -- gfs2/mkfs/struct_print.c | 12 +++ tests/nukerg.c | 3 - 15 files changed, 198 insertions(+), 246 deletions(-)
gfs2/convert/gfs2_convert.c +0 -13
@@ -114,19 +114,6 @@ static unsigned orig_journals = 0;int print_level =MSG_NOTICE ; -/* ------------------------------------------------------------------------- */ -/* This function is for libgfs's sake. */ -/* ------------------------------------------------------------------------- */ -void print_it (const char *label,const char *fmt,const char *fmt2, ...) -{ -va_list args; - -va_start (args, fmt2); -printf ("%s: " , label); -vprintf (fmt, args); -va_end (args); -} -/* ------------------------------------------------------------------------- */ /* convert_bitmaps - Convert gfs1 bitmaps to gfs2 bitmaps. */ /* Fixes all unallocated metadata bitmap states (which are */
gfs2/edit/extended.c +0 -7
@@ -421,13 +421,6 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,free (more_indir); } -static void gfs_jindex_print (struct gfs_jindex *ji) -{ -print_it (" ji_addr" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (ji->ji_addr)); -print_it (" ji_nsegment" ,"%" PRIu32,"0x%" PRIx32,be32_to_cpu (ji->ji_nsegment)); -print_it (" ji_pad" ,"%" PRIu32,"0x%" PRIx32,be32_to_cpu (ji->ji_pad)); -} -static int print_gfs_jindex (struct gfs2_inode *dij) {int error, start_line;
gfs2/edit/gfs2hex.c +0 -135
153 lines not on this page · raw message
gfs2/edit/hexedit.c +0 -33
@@ -727,23 +727,6 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)return be64_to_cpu (ri.ri_addr); } -/* ------------------------------------------------------------------------ */ -/* gfs_rgrp_print - print a gfs1 resource group */ -/* ------------------------------------------------------------------------ */ -void gfs_rgrp_print (void *rgp) -{ -struct gfs_rgrp *rg = rgp; - -meta_header_print (&rg->rg_header); -printbe32 (rg, rg_flags); -printbe32 (rg, rg_free); -printbe32 (rg, rg_useddi); -printbe32 (rg, rg_freedi); -inum_print (&rg->rg_freedi_list); -printbe32 (rg, rg_usedmeta); -printbe32 (rg, rg_freemeta); -} -/* ------------------------------------------------------------------------ */ /* get_rg_addr */ /* ------------------------------------------------------------------------ */
@@ -2028,22 +2011,6 @@ static void interactive_mode(void)endwin (); }/* interactive_mode */ -/* ------------------------------------------------------------------------ */ -/* gfs_log_header_print - print a gfs1-style log header */ -/* ------------------------------------------------------------------------ */ -void gfs_log_header_print (void *lhp) -{ -struct gfs_log_header *lh = lhp; - -meta_header_print (&lh->lh_header); -print_it (" lh_flags" ,"%" PRIu32,"0x%.8" PRIx32,be32_to_cpu (lh->lh_flags)); -print_it (" lh_pad" ,"%" PRIu32,"0x%" PRIx32,be32_to_cpu (lh->lh_pad)); -print_it (" lh_first" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (lh->lh_first)); -print_it (" lh_sequence" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (lh->lh_sequence)); -print_it (" lh_tail" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (lh->lh_tail)); -print_it (" lh_last_dump" ,"%" PRIu64,"0x%" PRIx64,be64_to_cpu (lh->lh_last_dump)); -} -/* ------------------------------------------------------------------------ */ /* usage - print command line usage */ /* ------------------------------------------------------------------------ */
gfs2/edit/hexedit.h +1 -3
@@ -5,6 +5,7 @@#include <inttypes.h> #include <limits.h> #include <string.h> +#include <ncurses.h> #include "libgfs2.h" #include "copyright.cf"
@@ -20,9 +21,6 @@enum dsp_mode {HEX_MODE =0 ,GFS2_MODE =1 ,EXTENDED_MODE =2 ,INIT_MODE =3 };#define BLOCK_STACK_SIZE 256 -#define pv (struct, member, fmt, fmt2) do { \ - print_it(" "#member, fmt, fmt2, struct->member); \ - } while (FALSE);#define RGLIST_DUMMY_BLOCK -2#define JOURNALS_DUMMY_BLOCK -3
gfs2/edit/struct_print.c +179 -21
241 lines not on this page · raw message
gfs2/edit/struct_print.h +4 -0
@@ -5,8 +5,10 @@extern void inum_print (void *nop);extern void meta_header_print (void *mhp);extern void sb_print (void *sbp); +extern void gfs_sb_print (void *sbp);extern void dinode_print (void *dip);extern void log_header_print (void *lhp); +extern void gfs_log_header_print (void *lhp);extern void log_descriptor_print (void *ldp);extern void quota_print (void *qp);extern void quota_change_print (void *qcp);
@@ -15,5 +17,7 @@ extern void ea_header_print(void *eap);extern void leaf_print (void *lfp);extern void rindex_print (void *rip);extern void rgrp_print (void *rgp); +extern void gfs_rgrp_print (void *rgp); +extern void gfs_jindex_print (struct gfs_jindex *ji);#endif /* STRUCT_PRINT_H */
gfs2/fsck/main.c +0 -11
@@ -45,17 +45,6 @@ static int preen = 0;static int force_check =0 ;static const char *pass_name ="" ; -/* This function is for libgfs2's sake. */ -void print_it (const char *label,const char *fmt,const char *fmt2, ...) -{ -va_list args; - -va_start (args, fmt2); -printf ("%s: " , label); -vprintf (fmt, args); -va_end (args); -} -static void usage (char *name) {printf ("Usage: %s [-afhnpqvVy] <device> \n" ,basename (name));
gfs2/glocktop/glocktop.c +2 -1
@@ -550,7 +550,8 @@ static void eol(int col) /* end of line */ } } -void print_it (const char *label,const char *fmt,const char *fmt2, ...) +__attribute__((format (printf,2 ,4 ))) +static void print_it (const char *label,const char *fmt,const char *fmt2, ...) {va_list args;char tmp_string[128 ];
gfs2/libgfs2/check_libgfs2.c +0 -3
@@ -1,9 +1,6 @@#include <check.h> #include "libgfs2.h" -// TODO: Remove this when the extern is removed from libgfs2 -void print_it (const char *label,const char *fmt,const char *fmt2, ...) {} -extern Suite *suite_meta (void );extern Suite *suite_ondisk (void );extern Suite *suite_rgrp (void );
gfs2/libgfs2/gfs2l.c +0 -3
@@ -197,6 +197,3 @@ int main(int argc, char *argv[])free (opts.fspath);return 0 ; } - -// libgfs2 still requires an external print_it function -void print_it (const char *label,const char *fmt,const char *fmt2, ...) {return ; }
gfs2/libgfs2/libgfs2.h +0 -2
@@ -796,8 +796,6 @@ extern int write_sb(struct gfs2_sbd *sdp);/* ondisk.c */ extern uint32_t gfs2_disk_hash (const char *data,int len); -extern void print_it (const char *label,const char *fmt,const char *fmt2, ...) - __attribute__((format (printf,2 ,4 )));/* Translation functions */
gfs2/mkfs/gfs2_mkfs.h +0 -11
@@ -4,17 +4,6 @@#include <stdarg.h> #include "copyright.cf" -/* This function is for libgfs2's sake. */ -void print_it (const char *label,const char *fmt,const char *fmt2, ...) -{ -va_list args; - -va_start (args, fmt2); -printf ("%s: " , label); -vprintf (fmt, args); -va_end (args); -} -/* * The following inode IOCTL macros and inode flags * are copied from linux/fs.h, because we have duplicate
gfs2/mkfs/struct_print.c +12 -0
@@ -2,10 +2,22 @@#include <string.h> #include <inttypes.h> #include <uuid.h> +#include <stdarg.h> #include <libgfs2.h> #include "struct_print.h" +__attribute__((format (printf,2 ,4 ))) +static void print_it (const char *label,const char *fmt,const char *fmt2, ...) +{ +va_list args; + +va_start (args, fmt2); +printf ("%s: " , label); +vprintf (fmt, args); +va_end (args); +} +#define printbe16 (struct, member) do { \ print_it(" "#member, "%"PRIu16, "0x%"PRIx16, be16_to_cpu(struct->member)); \ } while(0)
tests/nukerg.c +0 -3
@@ -343,6 +343,3 @@ int main(int argc, char **argv)close (sbd.device_fd);exit (0 ); } - -/* This function is for libgfs2's sake. */ -void print_it (const char *label,const char *fmt,const char *fmt2, ...) {}
Signature · 1 line
2.34.1