LCOV - code coverage report
Current view: top level - libgfs2 - ondisk.c (source / functions) Hit Total Coverage
Test: gfs2-utils.info Lines: 159 179 88.8 %
Date: 2023-10-25 12:04:14 Functions: 12 14 85.7 %

          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       69671 : void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
      13             : {
      14       69671 :         struct gfs2_inum *in = inp;
      15             : 
      16       69671 :         i->in_formal_ino = be64_to_cpu(in->no_formal_ino);
      17       69671 :         i->in_addr = be64_to_cpu(in->no_addr);
      18       69671 : }
      19             : 
      20        1983 : void lgfs2_inum_out(const struct lgfs2_inum *i, void *inp)
      21             : {
      22        1983 :         struct gfs2_inum *in = inp;
      23             : 
      24        1983 :         in->no_formal_ino = cpu_to_be64(i->in_formal_ino);
      25        1983 :         in->no_addr = cpu_to_be64(i->in_addr);
      26        1983 : }
      27             : 
      28        4547 : void lgfs2_sb_in(struct lgfs2_sbd *sdp, void *buf)
      29             : {
      30        4547 :         struct gfs2_sb *sb = buf;
      31             : 
      32        4547 :         sdp->sd_fs_format = be32_to_cpu(sb->sb_fs_format);
      33        4547 :         sdp->sd_multihost_format = be32_to_cpu(sb->sb_multihost_format);
      34        4547 :         sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
      35        4547 :         sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
      36        4547 :         lgfs2_inum_in(&sdp->sd_meta_dir, &sb->sb_master_dir);
      37        4547 :         lgfs2_inum_in(&sdp->sd_root_dir, &sb->sb_root_dir);
      38        4547 :         memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
      39        4547 :         memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
      40        4547 :         memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
      41        4547 : }
      42             : 
      43         110 : void lgfs2_sb_out(const struct lgfs2_sbd *sdp, void *buf)
      44             : {
      45         110 :         struct gfs2_sb *sb = buf;
      46             : 
      47         110 :         sb->sb_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
      48         110 :         sb->sb_header.mh_type = cpu_to_be32(GFS2_METATYPE_SB);
      49         110 :         sb->sb_header.mh_format = cpu_to_be32(GFS2_FORMAT_SB);
      50         110 :         sb->sb_fs_format = cpu_to_be32(sdp->sd_fs_format);
      51         110 :         sb->sb_multihost_format = cpu_to_be32(sdp->sd_multihost_format);
      52         110 :         sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
      53         110 :         sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
      54         110 :         lgfs2_inum_out(&sdp->sd_meta_dir, &sb->sb_master_dir);
      55         110 :         lgfs2_inum_out(&sdp->sd_root_dir, &sb->sb_root_dir);
      56         110 :         memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
      57         110 :         memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
      58         110 :         memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
      59         110 : }
      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       19481 : void lgfs2_rindex_out(const lgfs2_rgrp_t rg, void *buf)
      73             : {
      74       19481 :         struct gfs2_rindex *ri = buf;
      75             : 
      76       19481 :         ri->ri_addr = cpu_to_be64(rg->rt_addr);
      77       19481 :         ri->ri_length = cpu_to_be32(rg->rt_length);
      78       19481 :         ri->ri_data0 = cpu_to_be64(rg->rt_data0);
      79       19481 :         ri->ri_data = cpu_to_be32(rg->rt_data);
      80       19481 :         ri->ri_bitbytes = cpu_to_be32(rg->rt_bitbytes);
      81       19481 : }
      82             : 
      83       42645 : void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf)
      84             : {
      85       42645 :         struct gfs2_rgrp *r = buf;
      86             : 
      87       42645 :         rg->rt_flags = be32_to_cpu(r->rg_flags);
      88       42645 :         rg->rt_free = be32_to_cpu(r->rg_free);
      89       42645 :         rg->rt_dinodes = be32_to_cpu(r->rg_dinodes);
      90       42645 :         rg->rt_skip = be32_to_cpu(r->rg_skip);
      91       42645 :         rg->rt_igeneration = be64_to_cpu(r->rg_igeneration);
      92       42645 :         rg->rt_rg_data0 = be64_to_cpu(r->rg_data0);
      93       42645 :         rg->rt_rg_data = be32_to_cpu(r->rg_data);
      94       42645 :         rg->rt_rg_bitbytes = be32_to_cpu(r->rg_bitbytes);
      95       42645 : }
      96             : 
      97       77291 : void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
      98             : {
      99       77291 :         struct gfs2_rgrp *r = buf;
     100             : 
     101       77291 :         r->rg_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
     102       77291 :         r->rg_header.mh_type = cpu_to_be32(GFS2_METATYPE_RG);
     103       77291 :         r->rg_header.mh_format = cpu_to_be32(GFS2_FORMAT_RG);
     104       77291 :         r->rg_flags = cpu_to_be32(rg->rt_flags);
     105       77291 :         r->rg_free = cpu_to_be32(rg->rt_free);
     106       77291 :         r->rg_dinodes = cpu_to_be32(rg->rt_dinodes);
     107       77291 :         r->rg_skip = cpu_to_be32(rg->rt_skip);
     108       77291 :         r->rg_igeneration = cpu_to_be64(rg->rt_igeneration);
     109       77291 :         r->rg_data0 = cpu_to_be64(rg->rt_rg_data0);
     110       77291 :         r->rg_data = cpu_to_be32(rg->rt_rg_data);
     111       77291 :         r->rg_bitbytes = cpu_to_be32(rg->rt_rg_bitbytes);
     112       77291 :         lgfs2_rgrp_crc_set(buf);
     113       77291 : }
     114             : 
     115       15191 : void lgfs2_dinode_in(struct lgfs2_inode *ip, char *buf)
     116             : {
     117       15191 :         struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
     118             : 
     119       15191 :         ip->i_magic = be32_to_cpu(di->di_header.mh_magic);
     120       15191 :         ip->i_mh_type = be32_to_cpu(di->di_header.mh_type);
     121       15191 :         ip->i_format = be32_to_cpu(di->di_header.mh_format);
     122       15191 :         lgfs2_inum_in(&ip->i_num, &di->di_num);
     123       15191 :         ip->i_mode = be32_to_cpu(di->di_mode);
     124       15191 :         ip->i_uid = be32_to_cpu(di->di_uid);
     125       15191 :         ip->i_gid = be32_to_cpu(di->di_gid);
     126       15191 :         ip->i_nlink = be32_to_cpu(di->di_nlink);
     127       15191 :         ip->i_size = be64_to_cpu(di->di_size);
     128       15191 :         ip->i_blocks = be64_to_cpu(di->di_blocks);
     129       15191 :         ip->i_atime = be64_to_cpu(di->di_atime);
     130       15191 :         ip->i_mtime = be64_to_cpu(di->di_mtime);
     131       15191 :         ip->i_ctime = be64_to_cpu(di->di_ctime);
     132       15191 :         ip->i_major = be32_to_cpu(di->di_major);
     133       15191 :         ip->i_minor = be32_to_cpu(di->di_minor);
     134       15191 :         ip->i_goal_meta = be64_to_cpu(di->di_goal_meta);
     135       15191 :         ip->i_goal_data = be64_to_cpu(di->di_goal_data);
     136       15191 :         ip->i_generation = be64_to_cpu(di->di_generation);
     137       15191 :         ip->i_flags = be32_to_cpu(di->di_flags);
     138       15191 :         ip->i_payload_format = be32_to_cpu(di->di_payload_format);
     139       15191 :         ip->i_height = be16_to_cpu(di->di_height);
     140       15191 :         ip->i_depth = be16_to_cpu(di->di_depth);
     141       15191 :         ip->i_entries = be32_to_cpu(di->di_entries);
     142       15191 :         ip->i_eattr = be64_to_cpu(di->di_eattr);
     143       15191 :         ip->i_atime_nsec = be32_to_cpu(di->di_atime_nsec);
     144       15191 :         ip->i_mtime_nsec = be32_to_cpu(di->di_mtime_nsec);
     145       15191 :         ip->i_ctime_nsec = be32_to_cpu(di->di_ctime_nsec);
     146       15191 : }
     147             : 
     148        1034 : void lgfs2_dinode_out(struct lgfs2_inode *ip, char *buf)
     149             : {
     150        1034 :         struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
     151             : 
     152        1034 :         di->di_header.mh_magic = cpu_to_be32(ip->i_magic);
     153        1034 :         di->di_header.mh_type = cpu_to_be32(ip->i_mh_type);
     154        1034 :         di->di_header.mh_format = cpu_to_be32(ip->i_format);
     155        1034 :         lgfs2_inum_out(&ip->i_num, &di->di_num);
     156        1034 :         di->di_mode = cpu_to_be32(ip->i_mode);
     157        1034 :         di->di_uid = cpu_to_be32(ip->i_uid);
     158        1034 :         di->di_gid = cpu_to_be32(ip->i_gid);
     159        1034 :         di->di_nlink = cpu_to_be32(ip->i_nlink);
     160        1034 :         di->di_size = cpu_to_be64(ip->i_size);
     161        1034 :         di->di_blocks = cpu_to_be64(ip->i_blocks);
     162        1034 :         di->di_atime = cpu_to_be64(ip->i_atime);
     163        1034 :         di->di_mtime = cpu_to_be64(ip->i_mtime);
     164        1034 :         di->di_ctime = cpu_to_be64(ip->i_ctime);
     165        1034 :         di->di_major = cpu_to_be32(ip->i_major);
     166        1034 :         di->di_minor = cpu_to_be32(ip->i_minor);
     167        1034 :         di->di_goal_meta = cpu_to_be64(ip->i_goal_meta);
     168        1034 :         di->di_goal_data = cpu_to_be64(ip->i_goal_data);
     169        1034 :         di->di_generation = cpu_to_be64(ip->i_generation);
     170        1034 :         di->di_flags = cpu_to_be32(ip->i_flags);
     171        1034 :         di->di_payload_format = cpu_to_be32(ip->i_payload_format);
     172        1034 :         di->di_height = cpu_to_be16(ip->i_height);
     173        1034 :         di->di_depth = cpu_to_be16(ip->i_depth);
     174        1034 :         di->di_entries = cpu_to_be32(ip->i_entries);
     175        1034 :         di->di_eattr = cpu_to_be64(ip->i_eattr);
     176        1034 :         di->di_atime_nsec = cpu_to_be32(ip->i_atime_nsec);
     177        1034 :         di->di_mtime_nsec = cpu_to_be32(ip->i_mtime_nsec);
     178        1034 :         di->di_ctime_nsec = cpu_to_be32(ip->i_ctime_nsec);
     179        1034 : }
     180             : 
     181        4518 : void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
     182             : {
     183        4518 :         struct gfs2_dirent *de = dep;
     184             : 
     185        4518 :         lgfs2_inum_in(&d->dr_inum, &de->de_inum);
     186        4518 :         d->dr_hash = be32_to_cpu(de->de_hash);
     187        4518 :         d->dr_rec_len = be16_to_cpu(de->de_rec_len);
     188        4518 :         d->dr_name_len = be16_to_cpu(de->de_name_len);
     189        4518 :         d->dr_type = be16_to_cpu(de->de_type);
     190        4518 :         d->dr_rahead = be16_to_cpu(de->de_rahead);
     191        4518 : }
     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 : }

Generated by: LCOV version 1.14