Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   libgfs2: move gfs1 functions from edit to libgfs2 (http://www.linux-archive.org/cluster-development/563339-libgfs2-move-gfs1-functions-edit-libgfs2.html)

Bob Peterson 08-11-2011 09:16 PM

libgfs2: move gfs1 functions from edit to libgfs2
 
>From 6fc9e595a6eb140c097cf0aafe203c40d44a8863 Mon Sep 17 00:00:00 2001
From: Bob Peterson <rpeterso@redhat.com>
Date: Wed, 10 Aug 2011 15:27:10 -0500
Subject: [PATCH 39/44] libgfs2: move gfs1 functions from edit to libgfs2

This patch moves some gfs1-specific functions from gfs2_edit to
libgfs2 so that other utils can eventually operate on gfs1 file
systems.

rhbz#675723
---
gfs2/edit/hexedit.c | 47 ------------------------------------------
gfs2/edit/hexedit.h | 1 -
gfs2/libgfs2/gfs1.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
gfs2/libgfs2/libgfs2.h | 3 ++
4 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 94b7df8..0936bce 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1498,40 +1498,6 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
}

/* ------------------------------------------------------------------------ */
-/* gfs_rgrp_in - Read in a resource group header */
-/* ------------------------------------------------------------------------ */
-void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
-
- gfs2_meta_header_in(&rgrp->rg_header, rbh);
- rgrp->rg_flags = be32_to_cpu(str->rg_flags);
- rgrp->rg_free = be32_to_cpu(str->rg_free);
- rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
- rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
- gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
- rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
-}
-
-/* ------------------------------------------------------------------------ */
-/* gfs_rgrp_out */
-/* ------------------------------------------------------------------------ */
-static void gfs_rgrp_out(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
-
- gfs2_meta_header_out(&rgrp->rg_header, rbh);
- str->rg_flags = cpu_to_be32(rgrp->rg_flags);
- str->rg_free = cpu_to_be32(rgrp->rg_free);
- str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
- str->rg_freedi = cpu_to_be32(rgrp->rg_freedi);
- gfs2_inum_out(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- str->rg_usedmeta = cpu_to_be32(rgrp->rg_usedmeta);
- str->rg_freemeta = cpu_to_be32(rgrp->rg_freemeta);
-}
-
-/* ------------------------------------------------------------------------ */
/* gfs_rgrp_print - print a gfs1 resource group */
/* ------------------------------------------------------------------------ */
void gfs_rgrp_print(struct gfs_rgrp *rg)
@@ -1622,19 +1588,6 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
}

/* ------------------------------------------------------------------------ */
-/* gfs_jindex_in - read in a gfs1 jindex structure. */
-/* ------------------------------------------------------------------------ */
-void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
-{
- struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
-
- jindex->ji_addr = be64_to_cpu(str->ji_addr);
- jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
- jindex->ji_pad = be32_to_cpu(str->ji_pad);
- memcpy(jindex->ji_reserved, str->ji_reserved, 64);
-}
-
-/* ------------------------------------------------------------------------ */
/* has_indirect_blocks */
/* ------------------------------------------------------------------------ */
int has_indirect_blocks(void)
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f7b539e..07125bd 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -221,7 +221,6 @@ extern int display(int identify_only);
extern uint64_t check_keywords(const char *kword);
extern uint64_t masterblock(const char *fn);
extern void gfs_rgrp_print(struct gfs_rgrp *rg);
-extern void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh);
extern int has_indirect_blocks(void);

#endif /* __HEXVIEW_DOT_H__ */
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index c807e80..0cc1293 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -251,3 +251,56 @@ struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
{
return __gfs_inode_get(sdp, NULL, di_addr);
}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_jindex_in - read in a gfs1 jindex structure. */
+/* ------------------------------------------------------------------------ */
+void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
+{
+ struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
+
+ jindex->ji_addr = be64_to_cpu(str->ji_addr);
+ jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
+ jindex->ji_pad = be32_to_cpu(str->ji_pad);
+ memcpy(jindex->ji_reserved, str->ji_reserved, 64);
+}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_rgrp_in - Read in a resource group header */
+/* ------------------------------------------------------------------------ */
+void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
+{
+ struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
+
+ gfs2_meta_header_in(&rgrp->rg_header, rbh);
+ rgrp->rg_flags = be32_to_cpu(str->rg_flags);
+ rgrp->rg_free = be32_to_cpu(str->rg_free);
+ rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
+ rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
+ gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
+ rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
+ rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
+
+ memcpy(rgrp->rg_reserved, str->rg_reserved, 64);
+}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_rgrp_out */
+/* ------------------------------------------------------------------------ */
+void gfs_rgrp_out(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
+{
+ struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
+
+ gfs2_meta_header_out(&rgrp->rg_header, rbh);
+ str->rg_flags = cpu_to_be32(rgrp->rg_flags);
+ str->rg_free = cpu_to_be32(rgrp->rg_free);
+ str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
+ str->rg_freedi = cpu_to_be32(rgrp->rg_freedi);
+ gfs2_inum_out(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
+ str->rg_usedmeta = cpu_to_be32(rgrp->rg_usedmeta);
+ str->rg_freemeta = cpu_to_be32(rgrp->rg_freemeta);
+
+ memcpy(str->rg_reserved, rgrp->rg_reserved, 64);
+ bmodified(rbh);
+}
+
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d1581f9..0babc20 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -593,6 +593,9 @@ extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh);
extern struct gfs2_inode *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);
+extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);

/* gfs2_log.c */
struct gfs2_options {
--
1.7.4.4

01-20-2012 02:10 PM

libgfs2: move gfs1 functions from edit to libgfs2
 
From: Bob Peterson <rpeterso@redhat.com>

This patch moves some gfs1-specific functions from gfs2_edit to
libgfs2 so that other utils can eventually operate on gfs1 file
systems.

rhbz#675723
---
gfs2/edit/hexedit.c | 47 -------------------------------------------
gfs2/edit/hexedit.h | 1 -
gfs2/libgfs2/gfs1.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
gfs2/libgfs2/libgfs2.h | 3 ++
4 files changed, 55 insertions(+), 48 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index abb8ef0..a2ccc60 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1498,40 +1498,6 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
}

/* ------------------------------------------------------------------------ */
-/* gfs_rgrp_in - Read in a resource group header */
-/* ------------------------------------------------------------------------ */
-void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
-
- gfs2_meta_header_in(&rgrp->rg_header, rbh);
- rgrp->rg_flags = be32_to_cpu(str->rg_flags);
- rgrp->rg_free = be32_to_cpu(str->rg_free);
- rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
- rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
- gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
- rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
-}
-
-/* ------------------------------------------------------------------------ */
-/* gfs_rgrp_out */
-/* ------------------------------------------------------------------------ */
-static void gfs_rgrp_out(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
-
- gfs2_meta_header_out(&rgrp->rg_header, rbh);
- str->rg_flags = cpu_to_be32(rgrp->rg_flags);
- str->rg_free = cpu_to_be32(rgrp->rg_free);
- str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
- str->rg_freedi = cpu_to_be32(rgrp->rg_freedi);
- gfs2_inum_out(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- str->rg_usedmeta = cpu_to_be32(rgrp->rg_usedmeta);
- str->rg_freemeta = cpu_to_be32(rgrp->rg_freemeta);
-}
-
-/* ------------------------------------------------------------------------ */
/* gfs_rgrp_print - print a gfs1 resource group */
/* ------------------------------------------------------------------------ */
void gfs_rgrp_print(struct gfs_rgrp *rg)
@@ -1622,19 +1588,6 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
}

/* ------------------------------------------------------------------------ */
-/* gfs_jindex_in - read in a gfs1 jindex structure. */
-/* ------------------------------------------------------------------------ */
-void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
-{
- struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
-
- jindex->ji_addr = be64_to_cpu(str->ji_addr);
- jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
- jindex->ji_pad = be32_to_cpu(str->ji_pad);
- memcpy(jindex->ji_reserved, str->ji_reserved, 64);
-}
-
-/* ------------------------------------------------------------------------ */
/* has_indirect_blocks */
/* ------------------------------------------------------------------------ */
int has_indirect_blocks(void)
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f7b539e..07125bd 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -221,7 +221,6 @@ extern int display(int identify_only);
extern uint64_t check_keywords(const char *kword);
extern uint64_t masterblock(const char *fn);
extern void gfs_rgrp_print(struct gfs_rgrp *rg);
-extern void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh);
extern int has_indirect_blocks(void);

#endif /* __HEXVIEW_DOT_H__ */
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index fb4acab..5b8d4ed 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -249,3 +249,55 @@ struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
{
return __gfs_inode_get(sdp, NULL, di_addr);
}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_jindex_in - read in a gfs1 jindex structure. */
+/* ------------------------------------------------------------------------ */
+void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
+{
+ struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
+
+ jindex->ji_addr = be64_to_cpu(str->ji_addr);
+ jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
+ jindex->ji_pad = be32_to_cpu(str->ji_pad);
+ memcpy(jindex->ji_reserved, str->ji_reserved, 64);
+}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_rgrp_in - Read in a resource group header */
+/* ------------------------------------------------------------------------ */
+void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
+{
+ struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
+
+ gfs2_meta_header_in(&rgrp->rg_header, rbh);
+ rgrp->rg_flags = be32_to_cpu(str->rg_flags);
+ rgrp->rg_free = be32_to_cpu(str->rg_free);
+ rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
+ rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
+ gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
+ rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
+ rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
+
+ memcpy(rgrp->rg_reserved, str->rg_reserved, 64);
+}
+
+/* ------------------------------------------------------------------------ */
+/* gfs_rgrp_out */
+/* ------------------------------------------------------------------------ */
+void gfs_rgrp_out(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
+{
+ struct gfs_rgrp *str = (struct gfs_rgrp *)rbh->b_data;
+
+ gfs2_meta_header_out(&rgrp->rg_header, rbh);
+ str->rg_flags = cpu_to_be32(rgrp->rg_flags);
+ str->rg_free = cpu_to_be32(rgrp->rg_free);
+ str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
+ str->rg_freedi = cpu_to_be32(rgrp->rg_freedi);
+ gfs2_inum_out(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
+ str->rg_usedmeta = cpu_to_be32(rgrp->rg_usedmeta);
+ str->rg_freemeta = cpu_to_be32(rgrp->rg_freemeta);
+
+ memcpy(str->rg_reserved, rgrp->rg_reserved, 64);
+ bmodified(rbh);
+}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index a2e1523..22c6552 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -589,6 +589,9 @@ extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh);
extern struct gfs2_inode *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);
+extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);

/* gfs2_log.c */
struct gfs2_options {
--
1.7.7.5


All times are GMT. The time now is 11:46 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.