This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit c841138f81925674bd309197c3f84940cade5710
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Apr 27 10:41:03 2021 +0100
libgfs2: Remove gfs2_quota_{in,out}
Update users to avoid storing cpu-endian data in an on-disk struct and
remove the functions. Replace the gfs2_quota_print() function with one
that expects big-endian data.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 11 +++++------
gfs2/libgfs2/libgfs2.h | 4 +---
gfs2/libgfs2/ondisk.c | 28 +++++-----------------------
gfs2/libgfs2/structures.c | 10 ++++------
4 files changed, 15 insertions(+), 38 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 79a5ec86..b0a75465 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -610,26 +610,25 @@ static int print_statfs(struct gfs2_inode *dis)
static int print_quota(struct gfs2_inode *diq)
{
- struct gfs2_quota qbuf, q;
+ struct gfs2_quota q;
int i, error;
-
+
print_gfs2("quota file contents:");
eol(0);
print_gfs2("quota entries found: %"PRIu64".", diq->i_di.di_size /
sizeof(q));
eol(0);
for (i=0; ; i++) {
- error = gfs2_readi(diq, (void *)&qbuf, i * sizeof(q), sizeof(qbuf));
+ error = gfs2_readi(diq, &q, i * sizeof(q), sizeof(q));
if (!error)
break;
- if (error != sizeof(qbuf)) {
+ if (error != sizeof(q)) {
print_gfs2("Error reading quota file.");
eol(0);
return -1;
}
- gfs2_quota_in(&q, (char *)&qbuf);
print_gfs2("Entry #%d", i + 1);
eol(0);
- gfs2_quota_print(&q);
+ lgfs2_quota_print(&q);
}
return 0;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e861a8b9..ab4c7320 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -705,8 +705,6 @@ extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
extern void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf);
extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf);
extern void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf);
-extern void gfs2_quota_in(struct gfs2_quota *qu, char *buf);
-extern void gfs2_quota_out(struct gfs2_quota *qu, char *buf);
extern void gfs2_dinode_in(struct gfs2_dinode *di, char *buf);
extern void gfs2_dinode_out(struct gfs2_dinode *di, char *buf);
extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
@@ -723,12 +721,12 @@ extern void gfs2_meta_header_print(const struct gfs2_meta_header
*mh);
extern void gfs2_sb_print(const struct gfs2_sb *sb);
extern void gfs2_rindex_print(const struct gfs2_rindex *ri);
extern void gfs2_rgrp_print(const struct gfs2_rgrp *rg);
-extern void gfs2_quota_print(const struct gfs2_quota *qu);
extern void gfs2_dinode_print(const struct gfs2_dinode *di);
extern void gfs2_log_header_print(const struct gfs2_log_header *lh);
/* These expect on-disk data instead of native-endian structs */
extern void lgfs2_meta_header_print(void *mhp);
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);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 1450d973..0e51a582 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -269,31 +269,13 @@ void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
pv(rg, rg_crc, "%"PRIu32, "0x%"PRIx32);
}
-void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
+void lgfs2_quota_print(void *qp)
{
- struct gfs2_quota *str = (struct gfs2_quota *)buf;
+ struct gfs2_quota *q = qp;
- CPIN_64(qu, str, qu_limit);
- CPIN_64(qu, str, qu_warn);
- CPIN_64(qu, str, qu_value);
- CPIN_08(qu, str, qu_reserved, sizeof(qu->qu_reserved));
-}
-
-void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
-{
- struct gfs2_quota *str = (struct gfs2_quota *)buf;
-
- CPOUT_64(qu, str, qu_limit);
- CPOUT_64(qu, str, qu_warn);
- CPOUT_64(qu, str, qu_value);
- memset(qu->qu_reserved, 0, sizeof(qu->qu_reserved));
-}
-
-void gfs2_quota_print(const struct gfs2_quota *qu)
-{
- pv(qu, qu_limit, "%"PRIu64, "0x%"PRIx64);
- pv(qu, qu_warn, "%"PRIu64, "0x%"PRIx64);
- pv(qu, qu_value, "%"PRIu64, "0x%"PRIx64);
+ printbe64(q, qu_limit);
+ printbe64(q, qu_warn);
+ printbe64(q, qu_value);
}
void gfs2_dinode_in(struct gfs2_dinode *di, char *buf)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 4b25f05a..79d99ba1 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -554,7 +554,6 @@ int build_quota(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip;
struct gfs2_quota qu;
- char buf[sizeof(struct gfs2_quota)];
int count;
ip = createi(sdp->master_dir, "quota", S_IFREG | 0600,
@@ -566,19 +565,18 @@ int build_quota(struct gfs2_sbd *sdp)
bmodified(ip->i_bh);
memset(&qu, 0, sizeof(struct gfs2_quota));
- qu.qu_value = 1;
- gfs2_quota_out(&qu, buf);
+ qu.qu_value = cpu_to_be64(1);
- count = gfs2_writei(ip, buf, ip->i_di.di_size, sizeof(struct gfs2_quota));
+ count = gfs2_writei(ip, &qu, ip->i_di.di_size, sizeof(struct gfs2_quota));
if (count != sizeof(struct gfs2_quota))
return -1;
- count = gfs2_writei(ip, buf, ip->i_di.di_size, sizeof(struct gfs2_quota));
+ count = gfs2_writei(ip, &qu, ip->i_di.di_size, sizeof(struct gfs2_quota));
if (count != sizeof(struct gfs2_quota))
return -1;
if (cfg_debug) {
printf("\nRoot quota:\n");
- gfs2_quota_print(&qu);
+ lgfs2_quota_print(&qu);
}
inode_put(&ip);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.