Line data Source code
1 : #include "clusterautoconfig.h"
2 :
3 : #include <stdio.h>
4 : #include <stdlib.h>
5 : #include <string.h>
6 : #include <stdint.h>
7 : #include <inttypes.h>
8 : #include <ctype.h>
9 : #include <uuid.h>
10 : #include "libgfs2.h"
11 :
12 69808 : void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
13 : {
14 69808 : struct gfs2_inum *in = inp;
15 :
16 69808 : i->in_formal_ino = be64_to_cpu(in->no_formal_ino);
17 69808 : i->in_addr = be64_to_cpu(in->no_addr);
18 69808 : }
19 :
20 2011 : void lgfs2_inum_out(const struct lgfs2_inum *i, void *inp)
21 : {
22 2011 : struct gfs2_inum *in = inp;
23 :
24 2011 : in->no_formal_ino = cpu_to_be64(i->in_formal_ino);
25 2011 : in->no_addr = cpu_to_be64(i->in_addr);
26 2011 : }
27 :
28 4550 : void lgfs2_sb_in(struct lgfs2_sbd *sdp, void *buf)
29 : {
30 4550 : struct gfs2_sb *sb = buf;
31 :
32 4550 : sdp->sd_fs_format = be32_to_cpu(sb->sb_fs_format);
33 4550 : sdp->sd_multihost_format = be32_to_cpu(sb->sb_multihost_format);
34 4550 : sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
35 4550 : sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
36 4550 : lgfs2_inum_in(&sdp->sd_meta_dir, &sb->sb_master_dir);
37 4550 : lgfs2_inum_in(&sdp->sd_root_dir, &sb->sb_root_dir);
38 4550 : memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
39 4550 : memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
40 4550 : memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
41 4550 : }
42 :
43 112 : void lgfs2_sb_out(const struct lgfs2_sbd *sdp, void *buf)
44 : {
45 112 : struct gfs2_sb *sb = buf;
46 :
47 112 : sb->sb_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
48 112 : sb->sb_header.mh_type = cpu_to_be32(GFS2_METATYPE_SB);
49 112 : sb->sb_header.mh_format = cpu_to_be32(GFS2_FORMAT_SB);
50 112 : sb->sb_fs_format = cpu_to_be32(sdp->sd_fs_format);
51 112 : sb->sb_multihost_format = cpu_to_be32(sdp->sd_multihost_format);
52 112 : sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
53 112 : sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
54 112 : lgfs2_inum_out(&sdp->sd_meta_dir, &sb->sb_master_dir);
55 112 : lgfs2_inum_out(&sdp->sd_root_dir, &sb->sb_root_dir);
56 112 : memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
57 112 : memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
58 112 : memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
59 112 : }
60 :
61 966 : void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf)
62 : {
63 966 : struct gfs2_rindex *ri = buf;
64 :
65 966 : rg->rt_addr = be64_to_cpu(ri->ri_addr);
66 966 : rg->rt_length = be32_to_cpu(ri->ri_length);
67 966 : rg->rt_data0 = be64_to_cpu(ri->ri_data0);
68 966 : rg->rt_data = be32_to_cpu(ri->ri_data);
69 966 : rg->rt_bitbytes = be32_to_cpu(ri->ri_bitbytes);
70 966 : }
71 :
72 19724 : void lgfs2_rindex_out(const lgfs2_rgrp_t rg, void *buf)
73 : {
74 19724 : struct gfs2_rindex *ri = buf;
75 :
76 19724 : ri->ri_addr = cpu_to_be64(rg->rt_addr);
77 19724 : ri->ri_length = cpu_to_be32(rg->rt_length);
78 19724 : ri->ri_data0 = cpu_to_be64(rg->rt_data0);
79 19724 : ri->ri_data = cpu_to_be32(rg->rt_data);
80 19724 : ri->ri_bitbytes = cpu_to_be32(rg->rt_bitbytes);
81 19724 : }
82 :
83 42995 : void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf)
84 : {
85 42995 : struct gfs2_rgrp *r = buf;
86 :
87 42995 : rg->rt_flags = be32_to_cpu(r->rg_flags);
88 42995 : rg->rt_free = be32_to_cpu(r->rg_free);
89 42995 : rg->rt_dinodes = be32_to_cpu(r->rg_dinodes);
90 42995 : rg->rt_skip = be32_to_cpu(r->rg_skip);
91 42995 : rg->rt_igeneration = be64_to_cpu(r->rg_igeneration);
92 42995 : rg->rt_rg_data0 = be64_to_cpu(r->rg_data0);
93 42995 : rg->rt_rg_data = be32_to_cpu(r->rg_data);
94 42995 : rg->rt_rg_bitbytes = be32_to_cpu(r->rg_bitbytes);
95 42995 : }
96 :
97 77642 : void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
98 : {
99 77642 : struct gfs2_rgrp *r = buf;
100 :
101 77642 : r->rg_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
102 77642 : r->rg_header.mh_type = cpu_to_be32(GFS2_METATYPE_RG);
103 77642 : r->rg_header.mh_format = cpu_to_be32(GFS2_FORMAT_RG);
104 77642 : r->rg_flags = cpu_to_be32(rg->rt_flags);
105 77642 : r->rg_free = cpu_to_be32(rg->rt_free);
106 77642 : r->rg_dinodes = cpu_to_be32(rg->rt_dinodes);
107 77642 : r->rg_skip = cpu_to_be32(rg->rt_skip);
108 77642 : r->rg_igeneration = cpu_to_be64(rg->rt_igeneration);
109 77642 : r->rg_data0 = cpu_to_be64(rg->rt_rg_data0);
110 77642 : r->rg_data = cpu_to_be32(rg->rt_rg_data);
111 77642 : r->rg_bitbytes = cpu_to_be32(rg->rt_rg_bitbytes);
112 77642 : lgfs2_rgrp_crc_set(buf);
113 77642 : }
114 :
115 15220 : void lgfs2_dinode_in(struct lgfs2_inode *ip, char *buf)
116 : {
117 15220 : struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
118 :
119 15220 : ip->i_magic = be32_to_cpu(di->di_header.mh_magic);
120 15220 : ip->i_mh_type = be32_to_cpu(di->di_header.mh_type);
121 15220 : ip->i_format = be32_to_cpu(di->di_header.mh_format);
122 15220 : lgfs2_inum_in(&ip->i_num, &di->di_num);
123 15220 : ip->i_mode = be32_to_cpu(di->di_mode);
124 15220 : ip->i_uid = be32_to_cpu(di->di_uid);
125 15220 : ip->i_gid = be32_to_cpu(di->di_gid);
126 15220 : ip->i_nlink = be32_to_cpu(di->di_nlink);
127 15220 : ip->i_size = be64_to_cpu(di->di_size);
128 15220 : ip->i_blocks = be64_to_cpu(di->di_blocks);
129 15220 : ip->i_atime = be64_to_cpu(di->di_atime);
130 15220 : ip->i_mtime = be64_to_cpu(di->di_mtime);
131 15220 : ip->i_ctime = be64_to_cpu(di->di_ctime);
132 15220 : ip->i_major = be32_to_cpu(di->di_major);
133 15220 : ip->i_minor = be32_to_cpu(di->di_minor);
134 15220 : ip->i_goal_meta = be64_to_cpu(di->di_goal_meta);
135 15220 : ip->i_goal_data = be64_to_cpu(di->di_goal_data);
136 15220 : ip->i_generation = be64_to_cpu(di->di_generation);
137 15220 : ip->i_flags = be32_to_cpu(di->di_flags);
138 15220 : ip->i_payload_format = be32_to_cpu(di->di_payload_format);
139 15220 : ip->i_height = be16_to_cpu(di->di_height);
140 15220 : ip->i_depth = be16_to_cpu(di->di_depth);
141 15220 : ip->i_entries = be32_to_cpu(di->di_entries);
142 15220 : ip->i_eattr = be64_to_cpu(di->di_eattr);
143 15220 : ip->i_atime_nsec = be32_to_cpu(di->di_atime_nsec);
144 15220 : ip->i_mtime_nsec = be32_to_cpu(di->di_mtime_nsec);
145 15220 : ip->i_ctime_nsec = be32_to_cpu(di->di_ctime_nsec);
146 15220 : }
147 :
148 1048 : void lgfs2_dinode_out(struct lgfs2_inode *ip, char *buf)
149 : {
150 1048 : struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
151 :
152 1048 : di->di_header.mh_magic = cpu_to_be32(ip->i_magic);
153 1048 : di->di_header.mh_type = cpu_to_be32(ip->i_mh_type);
154 1048 : di->di_header.mh_format = cpu_to_be32(ip->i_format);
155 1048 : lgfs2_inum_out(&ip->i_num, &di->di_num);
156 1048 : di->di_mode = cpu_to_be32(ip->i_mode);
157 1048 : di->di_uid = cpu_to_be32(ip->i_uid);
158 1048 : di->di_gid = cpu_to_be32(ip->i_gid);
159 1048 : di->di_nlink = cpu_to_be32(ip->i_nlink);
160 1048 : di->di_size = cpu_to_be64(ip->i_size);
161 1048 : di->di_blocks = cpu_to_be64(ip->i_blocks);
162 1048 : di->di_atime = cpu_to_be64(ip->i_atime);
163 1048 : di->di_mtime = cpu_to_be64(ip->i_mtime);
164 1048 : di->di_ctime = cpu_to_be64(ip->i_ctime);
165 1048 : di->di_major = cpu_to_be32(ip->i_major);
166 1048 : di->di_minor = cpu_to_be32(ip->i_minor);
167 1048 : di->di_goal_meta = cpu_to_be64(ip->i_goal_meta);
168 1048 : di->di_goal_data = cpu_to_be64(ip->i_goal_data);
169 1048 : di->di_generation = cpu_to_be64(ip->i_generation);
170 1048 : di->di_flags = cpu_to_be32(ip->i_flags);
171 1048 : di->di_payload_format = cpu_to_be32(ip->i_payload_format);
172 1048 : di->di_height = cpu_to_be16(ip->i_height);
173 1048 : di->di_depth = cpu_to_be16(ip->i_depth);
174 1048 : di->di_entries = cpu_to_be32(ip->i_entries);
175 1048 : di->di_eattr = cpu_to_be64(ip->i_eattr);
176 1048 : di->di_atime_nsec = cpu_to_be32(ip->i_atime_nsec);
177 1048 : di->di_mtime_nsec = cpu_to_be32(ip->i_mtime_nsec);
178 1048 : di->di_ctime_nsec = cpu_to_be32(ip->i_ctime_nsec);
179 1048 : }
180 :
181 4596 : void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
182 : {
183 4596 : struct gfs2_dirent *de = dep;
184 :
185 4596 : lgfs2_inum_in(&d->dr_inum, &de->de_inum);
186 4596 : d->dr_hash = be32_to_cpu(de->de_hash);
187 4596 : d->dr_rec_len = be16_to_cpu(de->de_rec_len);
188 4596 : d->dr_name_len = be16_to_cpu(de->de_name_len);
189 4596 : d->dr_type = be16_to_cpu(de->de_type);
190 4596 : d->dr_rahead = be16_to_cpu(de->de_rahead);
191 4596 : }
192 :
193 0 : void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
194 : {
195 0 : struct gfs2_dirent *de = dep;
196 :
197 0 : lgfs2_inum_out(&d->dr_inum, &de->de_inum);
198 0 : de->de_hash = cpu_to_be32(d->dr_hash);
199 0 : de->de_rec_len = cpu_to_be16(d->dr_rec_len);
200 0 : de->de_name_len = cpu_to_be16(d->dr_name_len);
201 0 : de->de_type = cpu_to_be16(d->dr_type);
202 0 : de->de_rahead = cpu_to_be16(d->dr_rahead);
203 0 : }
204 :
205 37 : void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp)
206 : {
207 37 : struct gfs2_leaf *l = lfp;
208 :
209 37 : lf->lf_depth = be16_to_cpu(l->lf_depth);
210 37 : lf->lf_entries = be16_to_cpu(l->lf_entries);
211 37 : lf->lf_dirent_format = be32_to_cpu(l->lf_dirent_format);
212 37 : lf->lf_next = be64_to_cpu(l->lf_next);
213 37 : lf->lf_inode = be64_to_cpu(l->lf_inode);
214 37 : lf->lf_dist = be32_to_cpu(l->lf_dist);
215 37 : lf->lf_nsec = be32_to_cpu(l->lf_nsec);
216 37 : lf->lf_sec = be64_to_cpu(l->lf_sec);
217 37 : }
218 :
219 0 : void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp)
220 : {
221 0 : struct gfs2_leaf *l = lfp;
222 :
223 0 : l->lf_depth = cpu_to_be16(lf->lf_depth);
224 0 : l->lf_entries = cpu_to_be16(lf->lf_entries);
225 0 : l->lf_dirent_format = cpu_to_be32(lf->lf_dirent_format);
226 0 : l->lf_next = cpu_to_be64(lf->lf_next);
227 0 : l->lf_inode = cpu_to_be64(lf->lf_inode);
228 0 : l->lf_dist = cpu_to_be32(lf->lf_dist);
229 0 : l->lf_nsec = cpu_to_be32(lf->lf_nsec);
230 0 : l->lf_sec = cpu_to_be64(lf->lf_sec);
231 0 : }
|